Skip to content

Commit 4cdc31b

Browse files
committed
Document our sanity assertion around explicit promotion
1 parent 119c636 commit 4cdc31b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/librustc_mir/transform/promote_consts.rs

+4
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,10 @@ pub fn validate_candidates(
732732

733733
let is_promotable = validator.validate_candidate(candidate).is_ok();
734734

735+
// If we use explicit validation, we carry the risk of turning a legitimate run-time
736+
// operation into a failing compile-time operation. Make sure that does not happen
737+
// by asserting that there is no possible run-time behavior here in case promotion
738+
// fails.
735739
if validator.explicit && !is_promotable {
736740
ccx.tcx.sess.delay_span_bug(
737741
ccx.body.span,

0 commit comments

Comments
 (0)