Skip to content

Commit 46b68b0

Browse files
Emit errors in promote_consts when required promotion fails
1 parent 9bb9833 commit 46b68b0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/librustc_mir/transform/promote_consts.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,17 @@ pub fn validate_candidates(
743743
// FIXME(eddyb) also emit the errors for shuffle indices
744744
// and `#[rustc_args_required_const]` arguments here.
745745

746-
validator.validate_candidate(candidate).is_ok()
746+
let is_promotable = validator.validate_candidate(candidate).is_ok();
747+
match candidate {
748+
Candidate::Argument { bb, index } if !is_promotable => {
749+
let span = body[bb].terminator().source_info.span;
750+
let msg = format!("argument {} is required to be a constant", index + 1);
751+
tcx.sess.span_err(span, &msg);
752+
}
753+
_ => ()
754+
}
755+
756+
is_promotable
747757
}).collect()
748758
}
749759

0 commit comments

Comments
 (0)