Skip to content

Commit c7c39ce

Browse files
committed
We should never see unevaluated type-level constants after monomorphization unless errors occurred
1 parent 1d56b8a commit c7c39ce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/rustc_mir/src/monomorphize/collector.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,13 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
648648
ty::ConstKind::Value(val) => collect_const_value(self.tcx, val, self.output),
649649
ty::ConstKind::Unevaluated(unevaluated) => {
650650
match self.tcx.const_eval_resolve(param_env, unevaluated, None) {
651-
Ok(val) => collect_const_value(self.tcx, val, self.output),
651+
// The `monomorphize` call should have evaluated that constant already.
652+
Ok(val) => span_bug!(
653+
self.body.source_info(location).span,
654+
"collection encountered the unevaluated constant {} which evaluated to {:?}",
655+
substituted_constant,
656+
val
657+
),
652658
Err(ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted) => {}
653659
Err(ErrorHandled::TooGeneric) => span_bug!(
654660
self.body.source_info(location).span,

0 commit comments

Comments
 (0)