Skip to content

Commit

Permalink
Document our sanity assertion around explicit promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Apr 17, 2020
1 parent f5c3315 commit 316a401
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/librustc_mir/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,10 @@ pub fn validate_candidates(

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

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

0 comments on commit 316a401

Please sign in to comment.