Catch and fix explicit promotions that fail to actually promote

This commit is contained in:
Oliver Scherer 2020-04-06 18:37:26 +02:00
parent 22a53790ed
commit 119c6365e4

View file

@ -731,6 +731,14 @@ pub fn validate_candidates(
// and `#[rustc_args_required_const]` arguments here.
let is_promotable = validator.validate_candidate(candidate).is_ok();
if validator.explicit && !is_promotable {
ccx.tcx.sess.delay_span_bug(
ccx.body.span,
"Explicit promotion requested, but failed to promote",
);
}
match candidate {
Candidate::Argument { bb, index } if !is_promotable => {
let span = ccx.body[bb].terminator().source_info.span;