Skip to content

Commit

Permalink
Don't assert polymorphization has taken effect in const eval
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wesleywiser committed Oct 1, 2021
1 parent 448815d commit d28bda0
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions compiler/rustc_const_eval/src/interpret/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d28bda0

Please sign in to comment.