match destination.target_id {
Ok(loop_id) => {
for b in &self.breakable_block_scopes {
- if b.block_expr_id == self.tcx.hir().node_to_hir_id(loop_id).local_id {
+ if b.block_expr_id == loop_id.local_id {
let scope = region::Scope {
- id: self.tcx.hir().node_to_hir_id(loop_id).local_id,
+ id: loop_id.local_id,
data: region::ScopeData::Node
};
return (scope, match scope_cf_kind {
}
}
for l in &self.loop_scopes {
- if l.loop_id == self.tcx.hir().node_to_hir_id(loop_id).local_id {
+ if l.loop_id == loop_id.local_id {
let scope = region::Scope {
- id: self.tcx.hir().node_to_hir_id(loop_id).local_id,
+ id: loop_id.local_id,
data: region::ScopeData::Node
};
return (scope, match scope_cf_kind {
ExprKind::Break(ref destination, ref opt_expr) => {
if let Some(ref label) = destination.label {
visitor.visit_label(label);
+ /*
if let Ok(node_id) = destination.target_id {
visitor.visit_def_mention(Def::Label(node_id))
}
+ */
}
walk_list!(visitor, visit_expr, opt_expr);
}
ExprKind::Continue(ref destination) => {
if let Some(ref label) = destination.label {
visitor.visit_label(label);
+ /*
if let Ok(node_id) = destination.target_id {
visitor.visit_def_mention(Def::Label(node_id))
}
+ */
}
}
ExprKind::Ret(ref optional_expression) => {
let target_id = match destination {
Some((id, _)) => {
if let Def::Label(loop_id) = self.expect_full_def(id) {
- Ok(self.lower_node_id(loop_id).node_id)
+ Ok(self.lower_node_id(loop_id).hir_id)
} else {
Err(hir::LoopIdError::UnresolvedLabel)
}
self.loop_scopes
.last()
.cloned()
- .map(|id| Ok(self.lower_node_id(id).node_id))
+ .map(|id| Ok(self.lower_node_id(id).hir_id))
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope))
.into()
}
let thin_attrs = ThinVec::from(attrs);
let catch_scope = self.catch_scopes.last().map(|x| *x);
let ret_expr = if let Some(catch_node) = catch_scope {
+ let target_id = Ok(self.lower_node_id(catch_node).hir_id);
P(self.expr(
e.span,
hir::ExprKind::Break(
hir::Destination {
label: None,
- target_id: Ok(catch_node),
+ target_id,
},
Some(from_err_expr),
),
// These errors are caught and then reported during the diagnostics pass in
// librustc_passes/loops.rs
- pub target_id: Result<NodeId, LoopIdError>,
+ pub target_id: Result<HirId, LoopIdError>,
}
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
use crate::ty::{self, TyCtxt};
use crate::ty::query::Providers;
use crate::lint;
-use crate::util::nodemap::{NodeMap, HirIdMap, HirIdSet};
+use crate::util::nodemap::{HirIdMap, HirIdSet};
use errors::Applicability;
use std::collections::{BTreeMap, VecDeque};
// mappings from loop node ID to LiveNode
// ("break" label should map to loop node ID,
// it probably doesn't now)
- break_ln: NodeMap<LiveNode>,
- cont_ln: NodeMap<LiveNode>,
+ break_ln: HirIdMap<LiveNode>,
+ cont_ln: HirIdMap<LiveNode>,
}
impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn propagate_through_block(&mut self, blk: &hir::Block, succ: LiveNode)
-> LiveNode {
if blk.targeted_by_break {
- let node_id = self.ir.tcx.hir().hir_to_node_id(blk.hir_id);
- self.break_ln.insert(node_id, succ);
+ self.break_ln.insert(blk.hir_id, succ);
}
let succ = self.propagate_through_opt_expr(blk.expr.as_ref().map(|e| &**e), succ);
blk.stmts.iter().rev().fold(succ, |succ, stmt| {
hir::ExprKind::Break(label, ref opt_expr) => {
// Find which label this break jumps to
let target = match label.target_id {
- Ok(node_id) => self.break_ln.get(&node_id),
+ Ok(hir_id) => self.break_ln.get(&hir_id),
Err(err) => span_bug!(expr.span, "loop scope error: {}", err),
}.cloned();
debug!("propagate_through_loop: using id for loop body {} {}",
expr.hir_id, self.ir.tcx.hir().hir_to_pretty_string(body.hir_id));
- let node_id = self.ir.tcx.hir().hir_to_node_id(expr.hir_id);
- self.break_ln.insert(node_id, succ);
+ self.break_ln.insert(expr.hir_id, succ);
let cond_ln = match kind {
LoopLoop => ln,
WhileLoop(ref cond) => self.propagate_through_expr(&cond, ln),
};
- self.cont_ln.insert(node_id, cond_ln);
+ self.cont_ln.insert(expr.hir_id, cond_ln);
let body_ln = self.propagate_through_block(body, cond_ln);
match dest.target_id {
Ok(target_id) => ExprKind::Break {
label: region::Scope {
- id: cx.tcx.hir().node_to_hir_id(target_id).local_id,
+ id: target_id.local_id,
data: region::ScopeData::Node
},
value: value.to_ref(),
match dest.target_id {
Ok(loop_id) => ExprKind::Continue {
label: region::Scope {
- id: cx.tcx.hir().node_to_hir_id(loop_id).local_id,
+ id: loop_id.local_id,
data: region::ScopeData::Node
},
},
use rustc::hir::map::Map;
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
use rustc::hir::{self, Node, Destination};
-use syntax::ast;
use syntax::struct_span_err;
use syntax_pos::Span;
use errors::Applicability;
let loop_id = match label.target_id.into() {
Ok(loop_id) => loop_id,
- Err(hir::LoopIdError::OutsideLoopScope) => ast::DUMMY_NODE_ID,
+ Err(hir::LoopIdError::OutsideLoopScope) => hir::DUMMY_HIR_ID,
Err(hir::LoopIdError::UnlabeledCfInWhileCondition) => {
self.emit_unlabled_cf_in_while_condition(e.span, "break");
- ast::DUMMY_NODE_ID
+ hir::DUMMY_HIR_ID
},
- Err(hir::LoopIdError::UnresolvedLabel) => ast::DUMMY_NODE_ID,
+ Err(hir::LoopIdError::UnresolvedLabel) => hir::DUMMY_HIR_ID,
};
- if loop_id != ast::DUMMY_NODE_ID {
- if let Node::Block(_) = self.hir_map.find(loop_id).unwrap() {
+ if loop_id != hir::DUMMY_HIR_ID {
+ if let Node::Block(_) = self.hir_map.find_by_hir_id(loop_id).unwrap() {
return
}
}
if opt_expr.is_some() {
- let loop_kind = if loop_id == ast::DUMMY_NODE_ID {
+ let loop_kind = if loop_id == hir::DUMMY_HIR_ID {
None
} else {
- Some(match self.hir_map.expect_expr(loop_id).node {
+ Some(match self.hir_map.expect_expr_by_hir_id(loop_id).node {
hir::ExprKind::While(..) => LoopKind::WhileLoop,
hir::ExprKind::Loop(_, _, source) => LoopKind::Loop(source),
ref r => span_bug!(e.span,
match destination.target_id {
Ok(loop_id) => {
- if let Node::Block(block) = self.hir_map.find(loop_id).unwrap() {
+ if let Node::Block(block) = self.hir_map.find_by_hir_id(loop_id).unwrap() {
struct_span_err!(self.sess, e.span, E0696,
"`continue` pointing to a labeled block")
.span_label(e.span,
}
ExprKind::Break(destination, ref expr_opt) => {
if let Ok(target_id) = destination.target_id {
- let target_id = tcx.hir().node_to_hir_id(target_id);
let (e_ty, cause);
if let Some(ref e) = *expr_opt {
// If this is a break with a value, we need to type-check