Skip to content

Commit 1924cc8

Browse files
Remove QUALIF_ERROR_BIT checking
1 parent 1bd30ce commit 1924cc8

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

src/librustc_mir/transform/promote_consts.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -582,30 +582,9 @@ impl<'tcx> Validator<'_, 'tcx> {
582582
Operand::Copy(place) |
583583
Operand::Move(place) => self.validate_place(place.as_ref()),
584584

585-
Operand::Constant(constant) => {
586-
if let ty::ConstKind::Unevaluated(def_id, _) = constant.literal.val {
587-
if self.tcx.trait_of_item(def_id).is_some() {
588-
// Don't peek inside trait associated constants.
589-
// (see below what we do for other consts, for now)
590-
} else {
591-
// HACK(eddyb) ensure that errors propagate correctly.
592-
// FIXME(eddyb) remove this once the old promotion logic
593-
// is gone - we can always promote constants even if they
594-
// fail to pass const-checking, as compilation would've
595-
// errored independently and promotion can't change that.
596-
let bits = self.tcx.at(constant.span).mir_const_qualif(def_id);
597-
if bits == super::qualify_consts::QUALIF_ERROR_BIT {
598-
self.tcx.sess.delay_span_bug(
599-
constant.span,
600-
"promote_consts: MIR had errors",
601-
);
602-
return Err(Unpromotable);
603-
}
604-
}
605-
}
606-
607-
Ok(())
608-
}
585+
// The qualifs for a constant (e.g. `HasMutInterior`) are checked in
586+
// `validate_rvalue` upon access.
587+
Operand::Constant(_) => Ok(()),
609588
}
610589
}
611590

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> u8 {
12851285

12861286
if body.return_ty().references_error() {
12871287
tcx.sess.delay_span_bug(body.span, "mir_const_qualif: MIR had errors");
1288-
return QUALIF_ERROR_BIT;
1288+
return 0;
12891289
}
12901290

12911291
Checker::new(tcx, def_id, body, Mode::Const).check_const()

0 commit comments

Comments
 (0)