diff --git a/compiler/rustc_type_ir/src/binder.rs b/compiler/rustc_type_ir/src/binder.rs index e9055940310d0..7512e032fe73a 100644 --- a/compiler/rustc_type_ir/src/binder.rs +++ b/compiler/rustc_type_ir/src/binder.rs @@ -697,12 +697,24 @@ impl<'a, I: Interner> TypeFolder for ArgFolder<'a, I> { } fn fold_const(&mut self, c: I::Const) -> I::Const { + if !c.has_param() { + return c; + } + if let ty::ConstKind::Param(p) = c.kind() { self.const_for_param(p, c) } else { c.super_fold_with(self) } } + + fn fold_predicate(&mut self, p: I::Predicate) -> I::Predicate { + if !p.has_param() { + return p; + } + + p.super_fold_with(self) + } } impl<'a, I: Interner> ArgFolder<'a, I> {