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> {
98
98
}
99
99
100
100
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
+
101
106
TraitRef :: new (
102
107
interner,
103
108
self . def_id ,
@@ -646,6 +651,10 @@ impl<I: Interner> AliasTerm<I> {
646
651
}
647
652
648
653
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
+
649
658
AliasTerm :: new (
650
659
interner,
651
660
self . def_id ,
Original file line number Diff line number Diff line change @@ -481,6 +481,11 @@ impl<I: Interner> AliasTy<I> {
481
481
}
482
482
483
483
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
+
484
489
AliasTy :: new (
485
490
interner,
486
491
self . def_id ,
You can’t perform that action at this time.
0 commit comments