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 authored and cjgillot committed Jun 30, 2022
1 parent 7425fb2 commit 5999f34
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions compiler/rustc_const_eval/src/interpret/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5999f34

Please sign in to comment.