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

Commit 850a60d

Browse files
committed
Auto merge of rust-lang#139291 - compiler-errors:folder-experiment-5, r=<try>
Folder experiment: Account for flags in const folders **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 These are probably actually neutral given that we're not often folding large consts in the wild (since we're not in a GCE world), but they do run somewhat often, so let's see what perf says. I'm not actually totally certain when the abstract const expander runs, tbh.
2 parents d5b4c2e + fec2276 commit 850a60d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

compiler/rustc_middle/src/ty/abstract_const.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ impl<'tcx> TyCtxt<'tcx> {
6363
},
6464
_ => c,
6565
};
66-
ct.super_fold_with(self)
66+
67+
if ct.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) {
68+
ct.super_fold_with(self)
69+
} else {
70+
ct
71+
}
6772
}
6873
}
6974
ac.fold_with(&mut Expander { tcx: self })

compiler/rustc_trait_selection/src/traits/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,22 @@ pub fn normalize_param_env_or_error<'tcx>(
376376

377377
c
378378
}
379+
380+
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
381+
if t.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) {
382+
t.super_fold_with(self)
383+
} else {
384+
t
385+
}
386+
}
387+
388+
fn fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> {
389+
if p.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) {
390+
p.super_fold_with(self)
391+
} else {
392+
p
393+
}
394+
}
379395
}
380396

381397
// This whole normalization step is a hack to work around the fact that

0 commit comments

Comments
 (0)