From 119c6365e4bade30fa2b2b6ca201144c9ac9d39e Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Mon, 6 Apr 2020 18:37:26 +0200 Subject: [PATCH] Catch and fix explicit promotions that fail to actually promote --- src/librustc_mir/transform/promote_consts.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 3506abc8e24b..7aaa96e2f844 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -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;