Skip to content

Commit f5c3315

Browse files
committed
Catch and fix explicit promotions that fail to actually promote
1 parent 29aebf4 commit f5c3315

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
@@ -735,6 +735,14 @@ pub fn validate_candidates(
735735
// and `#[rustc_args_required_const]` arguments here.
736736

737737
let is_promotable = validator.validate_candidate(candidate).is_ok();
738+
739+
if validator.explicit && !is_promotable {
740+
ccx.tcx.sess.delay_span_bug(
741+
ccx.body.span,
742+
"Explicit promotion requested, but failed to promote",
743+
);
744+
}
745+
738746
match candidate {
739747
Candidate::Argument { bb, index } if !is_promotable => {
740748
let span = ccx.body[bb].terminator().source_info.span;

0 commit comments

Comments
 (0)