Skip to content

Commit 5999f34

Browse files
wesleywisercjgillot
authored andcommitted
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.
1 parent 7425fb2 commit 5999f34

File tree

1 file changed

+4
-16
lines changed
  • compiler/rustc_const_eval/src/interpret

1 file changed

+4
-16
lines changed

compiler/rustc_const_eval/src/interpret/util.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,10 @@ where
4444
let is_used = unused_params.contains(index).map_or(true, |unused| !unused);
4545
// Only recurse when generic parameters in fns, closures and generators
4646
// are used and require substitution.
47-
match (is_used, subst.needs_subst()) {
48-
// Just in case there are closures or generators within this subst,
49-
// recurse.
50-
(true, true) => return subst.visit_with(self),
51-
// Confirm that polymorphization replaced the parameter with
52-
// `ty::Param`/`ty::ConstKind::Param`.
53-
(false, true) if cfg!(debug_assertions) => match subst.unpack() {
54-
ty::subst::GenericArgKind::Type(ty) => {
55-
assert!(matches!(ty.kind(), ty::Param(_)))
56-
}
57-
ty::subst::GenericArgKind::Const(ct) => {
58-
assert!(matches!(ct.kind(), ty::ConstKind::Param(_)))
59-
}
60-
ty::subst::GenericArgKind::Lifetime(..) => (),
61-
},
62-
_ => {}
47+
// Just in case there are closures or generators within this subst,
48+
// recurse.
49+
if is_used && subst.needs_subst() {
50+
return subst.visit_with(self);
6351
}
6452
}
6553
ControlFlow::CONTINUE

0 commit comments

Comments
 (0)