Skip to content

Commit 9cd4e17

Browse files
Don't re-intern in with_self_ty if self ty didn't change
1 parent c31cccb commit 9cd4e17

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

compiler/rustc_type_ir/src/predicate.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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,

compiler/rustc_type_ir/src/ty_kind.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)