use std::collections::HashSet;
-use hir::map as ast_map;
+use hir::map as hir_map;
use hir;
use lint;
format!("{}unknown scope: {:?}{}. Please report a bug.",
prefix, scope, suffix)
};
- let span = match scope.span(&self.region_maps, &self.map) {
+ let span = match scope.span(&self.region_maps, &self.hir) {
Some(s) => s,
None => {
err.note(&unknown_scope());
return;
}
};
- let tag = match self.map.find(scope.node_id(&self.region_maps)) {
- Some(ast_map::NodeBlock(_)) => "block",
- Some(ast_map::NodeExpr(expr)) => match expr.node {
+ let tag = match self.hir.find(scope.node_id(&self.region_maps)) {
+ Some(hir_map::NodeBlock(_)) => "block",
+ Some(hir_map::NodeExpr(expr)) => match expr.node {
hir::ExprCall(..) => "call",
hir::ExprMethodCall(..) => "method call",
hir::ExprMatch(.., hir::MatchSource::IfLetDesugar { .. }) => "if let",
hir::ExprMatch(..) => "match",
_ => "expression",
},
- Some(ast_map::NodeStmt(_)) => "statement",
- Some(ast_map::NodeItem(it)) => item_scope_tag(&it),
- Some(ast_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
- Some(ast_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
+ Some(hir_map::NodeStmt(_)) => "statement",
+ Some(hir_map::NodeItem(it)) => item_scope_tag(&it),
+ Some(hir_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
+ Some(hir_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
Some(_) | None => {
err.span_note(span, &unknown_scope());
return;
let node = fr.scope.node_id(&self.region_maps);
let unknown;
- let tag = match self.map.find(node) {
- Some(ast_map::NodeBlock(_)) |
- Some(ast_map::NodeExpr(_)) => "body",
- Some(ast_map::NodeItem(it)) => item_scope_tag(&it),
- Some(ast_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
- Some(ast_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
+ let tag = match self.hir.find(node) {
+ Some(hir_map::NodeBlock(_)) |
+ Some(hir_map::NodeExpr(_)) => "body",
+ Some(hir_map::NodeItem(it)) => item_scope_tag(&it),
+ Some(hir_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
+ Some(hir_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
// this really should not happen, but it does:
// FIXME(#27942)
Some(_) => {
unknown = format!("unexpected node ({}) for scope {:?}. \
Please report a bug.",
- self.map.node_to_string(node), fr.scope);
+ self.hir.node_to_string(node), fr.scope);
&unknown
}
None => {
&unknown
}
};
- let (msg, opt_span) = explain_span(self, tag, self.map.span(node));
+ let (msg, opt_span) = explain_span(self, tag, self.hir.span(node));
(format!("{} {}", prefix, msg), opt_span)
}
},
_ => return None
};
- let parent = tcx.map.get_parent(scope_id);
- let parent_node = tcx.map.find(parent);
+ let parent = tcx.hir.get_parent(scope_id);
+ let parent_node = tcx.hir.find(parent);
match parent_node {
Some(node) => match node {
- ast_map::NodeItem(item) => match item.node {
+ hir_map::NodeItem(item) => match item.node {
hir::ItemFn(..) => {
Some(FreeRegionsFromSameFn::new(fr1, fr2, scope_id))
},
_ => None
},
- ast_map::NodeImplItem(..) |
- ast_map::NodeTraitItem(..) => {
+ hir_map::NodeImplItem(..) |
+ hir_map::NodeTraitItem(..) => {
Some(FreeRegionsFromSameFn::new(fr1, fr2, scope_id))
},
_ => None
fn give_suggestion(&self, err: &mut DiagnosticBuilder, same_regions: &[SameRegions]) {
let scope_id = same_regions[0].scope_id;
- let parent = self.tcx.map.get_parent(scope_id);
- let parent_node = self.tcx.map.find(parent);
+ let parent = self.tcx.hir.get_parent(scope_id);
+ let parent_node = self.tcx.hir.find(parent);
let taken = lifetimes_in_scope(self.tcx, scope_id);
let life_giver = LifeGiver::with_taken(&taken[..]);
let node_inner = match parent_node {
Some(ref node) => match *node {
- ast_map::NodeItem(ref item) => {
+ hir_map::NodeItem(ref item) => {
match item.node {
hir::ItemFn(ref fn_decl, unsafety, constness, _, ref gen, body) => {
Some((fn_decl, gen, unsafety, constness, item.name, item.span, body))
_ => None,
}
}
- ast_map::NodeImplItem(item) => {
- let id = self.tcx.map.get_parent(item.id);
- if let Some(ast_map::NodeItem(parent_scope)) = self.tcx.map.find(id) {
+ hir_map::NodeImplItem(item) => {
+ let id = self.tcx.hir.get_parent(item.id);
+ if let Some(hir_map::NodeItem(parent_scope)) = self.tcx.hir.find(id) {
if let hir::ItemImpl(_, _, _, None, _, _) = parent_scope.node {
// this impl scope implements a trait, do not recomend
// using explicit lifetimes (#37363)
None
}
},
- ast_map::NodeTraitItem(item) => {
+ hir_map::NodeTraitItem(item) => {
match item.node {
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
Some((&sig.decl,
generics: &hir::Generics,
span: Span,
body: hir::BodyId) {
- let s = hir::print::to_string(&self.tcx.map, |s| {
+ let s = hir::print::to_string(&self.tcx.hir, |s| {
use syntax::abi::Abi;
use syntax::print::pprust::PrintState;
scope_id: ast::NodeId)
-> Vec<hir::LifetimeDef> {
let mut taken = Vec::new();
- let parent = tcx.map.get_parent(scope_id);
- let method_id_opt = match tcx.map.find(parent) {
+ let parent = tcx.hir.get_parent(scope_id);
+ let method_id_opt = match tcx.hir.find(parent) {
Some(node) => match node {
- ast_map::NodeItem(item) => match item.node {
+ hir_map::NodeItem(item) => match item.node {
hir::ItemFn(.., ref gen, _) => {
taken.extend_from_slice(&gen.lifetimes);
None
},
_ => None
},
- ast_map::NodeImplItem(ii) => {
+ hir_map::NodeImplItem(ii) => {
match ii.node {
hir::ImplItemKind::Method(ref sig, _) => {
taken.extend_from_slice(&sig.generics.lifetimes);
None => None
};
if let Some(method_id) = method_id_opt {
- let parent = tcx.map.get_parent(method_id);
- if let Some(node) = tcx.map.find(parent) {
+ let parent = tcx.hir.get_parent(method_id);
+ if let Some(node) = tcx.hir.find(parent) {
match node {
- ast_map::NodeItem(item) => match item.node {
+ hir_map::NodeItem(item) => match item.node {
hir::ItemImpl(_, _, ref gen, ..) => {
taken.extend_from_slice(&gen.lifetimes);
}