Skip to content

Commit d28bda0

Browse files
committed
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 448815d commit d28bda0

File tree

1 file changed

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

1 file changed

+3
-16
lines changed

compiler/rustc_const_eval/src/interpret/util.rs

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

0 commit comments

Comments
 (0)