Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 723e1f0

Browse files
committed
Auto merge of rust-lang#139290 - compiler-errors:folder-experiment-4, r=<try>
Folder experiment: Account for flags in ArgFolder **NOTE:** This is one of a series of perf experiments that I've come up with while sick in bed. I'm assigning them to lqd b/c you're a good reviewer and you'll hopefully be awake when these experiments finish, lol. r? lqd The arg folder is very hot and this hopefully avoids unnecessarily substituting predicates and consts when they have no consts in them :>
2 parents d5b4c2e + fa912f4 commit 723e1f0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler/rustc_type_ir/src/binder.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,24 @@ impl<'a, I: Interner> TypeFolder<I> for ArgFolder<'a, I> {
697697
}
698698

699699
fn fold_const(&mut self, c: I::Const) -> I::Const {
700+
if !c.has_param() {
701+
return c;
702+
}
703+
700704
if let ty::ConstKind::Param(p) = c.kind() {
701705
self.const_for_param(p, c)
702706
} else {
703707
c.super_fold_with(self)
704708
}
705709
}
710+
711+
fn fold_predicate(&mut self, p: I::Predicate) -> I::Predicate {
712+
if !p.has_param() {
713+
return p;
714+
}
715+
716+
p.super_fold_with(self)
717+
}
706718
}
707719

708720
impl<'a, I: Interner> ArgFolder<'a, I> {

0 commit comments

Comments
 (0)