Skip to content

Commit 864d2f3

Browse files
committed
eagerly check for bound vars of predicates
1 parent 39a990d commit 864d2f3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

compiler/rustc_middle/src/ty/fold.rs

+4
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for BoundVarReplacer<'a, 'tcx> {
448448
_ => ct.super_fold_with(self),
449449
}
450450
}
451+
452+
fn fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> {
453+
if p.has_vars_bound_at_or_above(self.current_index) { p.super_fold_with(self) } else { p }
454+
}
451455
}
452456

453457
impl<'tcx> TyCtxt<'tcx> {

compiler/rustc_trait_selection/src/traits/project.rs

+4
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,10 @@ impl<'tcx> TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> {
756756
_ => ct.super_fold_with(self),
757757
}
758758
}
759+
760+
fn fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> {
761+
if p.has_vars_bound_at_or_above(self.current_index) { p.super_fold_with(self) } else { p }
762+
}
759763
}
760764

761765
// The inverse of `BoundVarReplacer`: replaces placeholders with the bound vars from which they came.

0 commit comments

Comments
 (0)