From: Wesley Wiser Date: Fri, 1 Oct 2021 01:58:49 +0000 (-0400) Subject: Don't assert polymorphization has taken effect in const eval X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;ds=sidebyside;h=5999f34ff600b64c208e9d7cff6e1e7d1bb1662d;p=rust.git 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. --- diff --git a/compiler/rustc_const_eval/src/interpret/util.rs b/compiler/rustc_const_eval/src/interpret/util.rs index b9866995e9f..9d7905ed9a8 100644 --- a/compiler/rustc_const_eval/src/interpret/util.rs +++ b/compiler/rustc_const_eval/src/interpret/util.rs @@ -44,22 +44,10 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { 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.needs_subst()) { - // Just in case there are closures or generators within this subst, - // recurse. - (true, true) => return subst.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.kind(), ty::ConstKind::Param(_))) - } - ty::subst::GenericArgKind::Lifetime(..) => (), - }, - _ => {} + // Just in case there are closures or generators within this subst, + // recurse. + if is_used && subst.needs_subst() { + return subst.visit_with(self); } } ControlFlow::CONTINUE