Skip to content

Commit 119c636

Browse files
committed
Catch and fix explicit promotions that fail to actually promote
1 parent 22a5379 commit 119c636

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/librustc_mir/transform/promote_consts.rs

+8
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,14 @@ pub fn validate_candidates(
731731
// and `#[rustc_args_required_const]` arguments here.
732732

733733
let is_promotable = validator.validate_candidate(candidate).is_ok();
734+
735+
if validator.explicit && !is_promotable {
736+
ccx.tcx.sess.delay_span_bug(
737+
ccx.body.span,
738+
"Explicit promotion requested, but failed to promote",
739+
);
740+
}
741+
734742
match candidate {
735743
Candidate::Argument { bb, index } if !is_promotable => {
736744
let span = ccx.body[bb].terminator().source_info.span;

0 commit comments

Comments
 (0)