diff options
| author | Wesley Wiser <wesleywiser@microsoft.com> | 2021-09-30 21:58:49 -0400 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-06-30 21:45:29 +0200 |
| commit | 5999f34ff600b64c208e9d7cff6e1e7d1bb1662d (patch) | |
| tree | 4446a29542842fe28911036187a3ced7b9d27e6b | |
| parent | 7425fb293f510a6f138e82a963a3bc599a5b9e1c (diff) | |
| download | rust-5999f34ff600b64c208e9d7cff6e1e7d1bb1662d.tar.gz rust-5999f34ff600b64c208e9d7cff6e1e7d1bb1662d.zip | |
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.
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/util.rs | 20 |
1 files changed, 4 insertions, 16 deletions
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 @@ 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.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 |
