// Collect all the temps we need to promote.
let mut promoted_temps = BitSet::new_empty(self.temp_promotion_state.len());
- // HACK(eddyb) don't try to validate promotion candidates if any
- // parts of the control-flow graph were skipped due to an error.
- let promotion_candidates = if has_controlflow_error {
- let unleash_miri = self
- .tcx
- .sess
- .opts
- .debugging_opts
- .unleash_the_miri_inside_of_you;
- if !unleash_miri {
- self.tcx.sess.delay_span_bug(
- body.span,
- "check_const: expected control-flow error(s)",
- );
- }
- self.promotion_candidates.clone()
+ // HACK: if parts of the control-flow graph were skipped due to an error, don't try to
+ // promote anything, since that can cause errors in a `const` if e.g. rvalue static
+ // promotion is attempted within a loop body.
+ let unleash_miri = self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you;
+ let promotion_candidates = if has_controlflow_error && !unleash_miri {
+ self.tcx.sess.delay_span_bug(
+ body.span,
+ "check_const: expected control-flow error(s)",
+ );
+
+ vec![]
} else {
- self.valid_promotion_candidates()
+ promote_consts::validate_candidates(
+ self.tcx,
+ self.body,
+ self.def_id,
+ &self.temp_promotion_state,
+ &self.unchecked_promotion_candidates,
+ )
};
+
debug!("qualify_const: promotion_candidates={:?}", promotion_candidates);
for candidate in promotion_candidates {
match candidate {