From d7bf358dbd778f2c0a32936b959e868918e082ca Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 7 May 2018 11:30:41 +0200 Subject: [PATCH] Be more explicit about what's skipped --- src/librustc_mir/transform/qualify_consts.rs | 67 ++++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index e79f3ac9d112..97acfbbe8fd7 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -366,42 +366,41 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { TerminatorKind::Return => { if self.tcx.sess.features_untracked().const_let { - break; - } - // Check for unused values. This usually means - // there are extra statements in the AST. - for temp in mir.temps_iter() { - if self.local_qualif[temp].is_none() { - continue; + // Check for unused values. This usually means + // there are extra statements in the AST. + for temp in mir.temps_iter() { + if self.local_qualif[temp].is_none() { + continue; + } + + let state = self.temp_promotion_state[temp]; + if let TempState::Defined { location, uses: 0 } = state { + let data = &mir[location.block]; + let stmt_idx = location.statement_index; + + // Get the span for the initialization. + let source_info = if stmt_idx < data.statements.len() { + data.statements[stmt_idx].source_info + } else { + data.terminator().source_info + }; + self.span = source_info.span; + + // Treat this as a statement in the AST. + self.statement_like(); + } } - let state = self.temp_promotion_state[temp]; - if let TempState::Defined { location, uses: 0 } = state { - let data = &mir[location.block]; - let stmt_idx = location.statement_index; - - // Get the span for the initialization. - let source_info = if stmt_idx < data.statements.len() { - data.statements[stmt_idx].source_info - } else { - data.terminator().source_info - }; - self.span = source_info.span; - - // Treat this as a statement in the AST. - self.statement_like(); - } - } - - // Make sure there are no extra unassigned variables. - self.qualif = Qualif::NOT_CONST; - for index in mir.vars_iter() { - if !self.const_fn_arg_vars.contains(index.index()) { - debug!("unassigned variable {:?}", index); - self.assign(&Place::Local(index), Location { - block: bb, - statement_index: usize::MAX, - }); + // Make sure there are no extra unassigned variables. + self.qualif = Qualif::NOT_CONST; + for index in mir.vars_iter() { + if !self.const_fn_arg_vars.contains(index.index()) { + debug!("unassigned variable {:?}", index); + self.assign(&Place::Local(index), Location { + block: bb, + statement_index: usize::MAX, + }); + } } }