From d28bda056aa47f79d55c6a9c88117c8911eb5db2 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 30 Sep 2021 21:58:49 -0400 Subject: [PATCH] Don't assert polymorphization has taken effect in const eval Const eval no longer runs MIR optimizations so unless this is getting run as part of a MIR optimization like const-prop, there can be unused type parameters even if polymorphization is enabled. --- .../rustc_const_eval/src/interpret/util.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/util.rs b/compiler/rustc_const_eval/src/interpret/util.rs index eb0fdebb665fa..8685aba393fd1 100644 --- a/compiler/rustc_const_eval/src/interpret/util.rs +++ b/compiler/rustc_const_eval/src/interpret/util.rs @@ -43,22 +43,9 @@ where let is_used = unused_params.contains(index).map_or(true, |unused| !unused); // Only recurse when generic parameters in fns, closures and generators // are used and require substitution. - match (is_used, subst.definitely_needs_subst(self.tcx)) { - // Just in case there are closures or generators within this subst, - // recurse. - (true, true) => return subst.super_visit_with(self), - // Confirm that polymorphization replaced the parameter with - // `ty::Param`/`ty::ConstKind::Param`. - (false, true) if cfg!(debug_assertions) => match subst.unpack() { - ty::subst::GenericArgKind::Type(ty) => { - assert!(matches!(ty.kind(), ty::Param(_))) - } - ty::subst::GenericArgKind::Const(ct) => { - assert!(matches!(ct.val, ty::ConstKind::Param(_))) - } - ty::subst::GenericArgKind::Lifetime(..) => (), - }, - _ => {} + // Just in case there are closures or generators within this subst, recurse. + if is_used && subst.definitely_needs_subst(self.tcx) { + return subst.super_visit_with(self); } } ControlFlow::CONTINUE