File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
compiler/rustc_type_ir/src Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,11 @@ impl<I: Interner> TraitRef<I> {
9898 }
9999
100100 pub fn with_self_ty ( self , interner : I , self_ty : I :: Ty ) -> Self {
101+ // Don't re-intern if the self ty didn't change.
102+ if self_ty == self . args . type_at ( 0 ) {
103+ return self ;
104+ }
105+
101106 TraitRef :: new (
102107 interner,
103108 self . def_id ,
@@ -646,6 +651,10 @@ impl<I: Interner> AliasTerm<I> {
646651 }
647652
648653 pub fn with_self_ty ( self , interner : I , self_ty : I :: Ty ) -> Self {
654+ if self_ty == self . args . type_at ( 0 ) {
655+ return self ;
656+ }
657+
649658 AliasTerm :: new (
650659 interner,
651660 self . def_id ,
Original file line number Diff line number Diff line change @@ -481,6 +481,11 @@ impl<I: Interner> AliasTy<I> {
481481 }
482482
483483 pub fn with_self_ty ( self , interner : I , self_ty : I :: Ty ) -> Self {
484+ // Don't re-intern if the self ty didn't change.
485+ if self_ty == self . args . type_at ( 0 ) {
486+ return self ;
487+ }
488+
484489 AliasTy :: new (
485490 interner,
486491 self . def_id ,
You can’t perform that action at this time.
0 commit comments