Remove path prefixes from NodeKind

This commit is contained in:
varkor 2018-08-22 23:05:26 +01:00
parent 4b12f700db
commit 11665ca45a
38 changed files with 186 additions and 164 deletions

View File

@ -10,6 +10,7 @@
use hir::def_id::DefId;
use hir;
use hir::map::NodeKind;
use infer::{self, InferCtxt, InferOk, TypeVariableOrigin};
use infer::outlives::free_region_map::FreeRegionRelations;
use rustc_data_structures::fx::FxHashMap;
@ -697,7 +698,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
parent_def_id == tcx.hir.local_def_id(anon_parent_node_id)
};
let in_definition_scope = match tcx.hir.find(anon_node_id) {
Some(hir::map::NodeKind::Item(item)) => match item.node {
Some(NodeKind::Item(item)) => match item.node {
// impl trait
hir::ItemKind::Existential(hir::ExistTy {
impl_trait_fn: Some(parent),
@ -714,7 +715,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
),
_ => def_scope_default(),
},
Some(hir::map::NodeKind::ImplItem(item)) => match item.node {
Some(NodeKind::ImplItem(item)) => match item.node {
hir::ImplItemKind::Existential(_) => may_define_existential_type(
tcx,
self.parent_def_id,

View File

@ -62,7 +62,7 @@ use super::lexical_region_resolve::RegionResolutionError;
use std::{cmp, fmt};
use hir;
use hir::map as hir_map;
use hir::map::NodeKind;
use hir::def_id::DefId;
use middle::region;
use traits::{ObligationCause, ObligationCauseCode};
@ -100,8 +100,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
};
let span = scope.span(self, region_scope_tree);
let tag = match self.hir.find(scope.node_id(self, region_scope_tree)) {
Some(hir_map::NodeKind::Block(_)) => "block",
Some(hir_map::NodeKind::Expr(expr)) => match expr.node {
Some(NodeKind::Block(_)) => "block",
Some(NodeKind::Expr(expr)) => match expr.node {
hir::ExprKind::Call(..) => "call",
hir::ExprKind::MethodCall(..) => "method call",
hir::ExprKind::Match(.., hir::MatchSource::IfLetDesugar { .. }) => "if let",
@ -110,10 +110,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
hir::ExprKind::Match(..) => "match",
_ => "expression",
},
Some(hir_map::NodeKind::Stmt(_)) => "statement",
Some(hir_map::NodeKind::Item(it)) => Self::item_scope_tag(&it),
Some(hir_map::NodeKind::TraitItem(it)) => Self::trait_item_scope_tag(&it),
Some(hir_map::NodeKind::ImplItem(it)) => Self::impl_item_scope_tag(&it),
Some(NodeKind::Stmt(_)) => "statement",
Some(NodeKind::Item(it)) => Self::item_scope_tag(&it),
Some(NodeKind::TraitItem(it)) => Self::trait_item_scope_tag(&it),
Some(NodeKind::ImplItem(it)) => Self::impl_item_scope_tag(&it),
Some(_) | None => {
err.span_note(span, &unknown_scope());
return;
@ -194,10 +194,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
let scope = region.free_region_binding_scope(self);
let node = self.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
let tag = match self.hir.find(node) {
Some(hir_map::NodeKind::Block(_)) | Some(hir_map::NodeKind::Expr(_)) => "body",
Some(hir_map::NodeKind::Item(it)) => Self::item_scope_tag(&it),
Some(hir_map::NodeKind::TraitItem(it)) => Self::trait_item_scope_tag(&it),
Some(hir_map::NodeKind::ImplItem(it)) => Self::impl_item_scope_tag(&it),
Some(NodeKind::Block(_)) | Some(NodeKind::Expr(_)) => "body",
Some(NodeKind::Item(it)) => Self::item_scope_tag(&it),
Some(NodeKind::TraitItem(it)) => Self::trait_item_scope_tag(&it),
Some(NodeKind::ImplItem(it)) => Self::impl_item_scope_tag(&it),
_ => unreachable!()
};
let (prefix, span) = match *region {
@ -1127,7 +1127,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
// instead we suggest `T: 'a + 'b` in that case.
let mut has_bounds = false;
if let hir_map::NodeKind::GenericParam(ref param) = hir.get(id) {
if let NodeKind::GenericParam(ref param) = hir.get(id) {
has_bounds = !param.bounds.is_empty();
}
let sp = hir.span(id);

View File

@ -10,7 +10,7 @@
use hir;
use ty::{self, Region, TyCtxt};
use hir::map as hir_map;
use hir::map::NodeKind;
use middle::resolve_lifetime as rl;
use hir::intravisit::{self, NestedVisitorMap, Visitor};
use infer::error_reporting::nice_region_error::NiceRegionError;
@ -40,15 +40,15 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
let def_id = anon_reg.def_id;
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
let fndecl = match self.tcx.hir.get(node_id) {
hir_map::NodeKind::Item(&hir::Item {
NodeKind::Item(&hir::Item {
node: hir::ItemKind::Fn(ref fndecl, ..),
..
}) => &fndecl,
hir_map::NodeKind::TraitItem(&hir::TraitItem {
NodeKind::TraitItem(&hir::TraitItem {
node: hir::TraitItemKind::Method(ref m, ..),
..
})
| hir_map::NodeKind::ImplItem(&hir::ImplItem {
| NodeKind::ImplItem(&hir::ImplItem {
node: hir::ImplItemKind::Method(ref m, ..),
..
}) => &m.decl,

View File

@ -10,11 +10,12 @@
//! Helper functions corresponding to lifetime errors due to
//! anonymous regions.
use hir;
use infer::error_reporting::nice_region_error::NiceRegionError;
use ty::{self, Region, Ty};
use hir::def_id::DefId;
use hir::map as hir_map;
use hir::map::NodeKind;
use syntax_pos::Span;
// The struct contains the information about the anonymous region
@ -137,8 +138,8 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
.as_local_node_id(suitable_region_binding_scope)
.unwrap();
let is_impl_item = match self.tcx.hir.find(node_id) {
Some(hir_map::NodeKind::Item(..)) | Some(hir_map::NodeKind::TraitItem(..)) => false,
Some(hir_map::NodeKind::ImplItem(..)) => {
Some(NodeKind::Item(..)) | Some(NodeKind::TraitItem(..)) => false,
Some(NodeKind::ImplItem(..)) => {
self.is_bound_region_in_impl_item(suitable_region_binding_scope)
}
_ => return None,

View File

@ -12,7 +12,7 @@
// closely. The idea is that all reachable symbols are live, codes called
// from live codes are live, and everything else is dead.
use hir::map as hir_map;
use hir::map::NodeKind;
use hir::{self, PatKind};
use hir::intravisit::{self, Visitor, NestedVisitorMap};
use hir::itemlikevisit::ItemLikeVisitor;
@ -35,10 +35,10 @@ use syntax_pos;
fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
node_id: ast::NodeId) -> bool {
match tcx.hir.find(node_id) {
Some(hir_map::NodeKind::Item(..)) |
Some(hir_map::NodeKind::ImplItem(..)) |
Some(hir_map::NodeKind::ForeignItem(..)) |
Some(hir_map::NodeKind::TraitItem(..)) =>
Some(NodeKind::Item(..)) |
Some(NodeKind::ImplItem(..)) |
Some(NodeKind::ForeignItem(..)) |
Some(NodeKind::TraitItem(..)) =>
true,
_ =>
false
@ -145,13 +145,13 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
}
fn visit_node(&mut self, node: &hir_map::NodeKind<'tcx>) {
fn visit_node(&mut self, node: &NodeKind<'tcx>) {
let had_repr_c = self.repr_has_repr_c;
self.repr_has_repr_c = false;
let had_inherited_pub_visibility = self.inherited_pub_visibility;
self.inherited_pub_visibility = false;
match *node {
hir_map::NodeKind::Item(item) => {
NodeKind::Item(item) => {
match item.node {
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
let def_id = self.tcx.hir.local_def_id(item.id);
@ -173,13 +173,13 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
_ => ()
}
}
hir_map::NodeKind::TraitItem(trait_item) => {
NodeKind::TraitItem(trait_item) => {
intravisit::walk_trait_item(self, trait_item);
}
hir_map::NodeKind::ImplItem(impl_item) => {
NodeKind::ImplItem(impl_item) => {
intravisit::walk_impl_item(self, impl_item);
}
hir_map::NodeKind::ForeignItem(foreign_item) => {
NodeKind::ForeignItem(foreign_item) => {
intravisit::walk_foreign_item(self, &foreign_item);
}
_ => ()

View File

@ -102,11 +102,13 @@
//! only dead if the end of the function's block can never be reached.
//! It is the responsibility of typeck to ensure that there are no
//! `return` expressions in a function declared as diverging.
use self::LoopKind::*;
use self::LiveNodeKind::*;
use self::VarKind::*;
use hir::def::*;
use hir::map::NodeKind;
use ty::{self, TyCtxt};
use lint;
use errors::Applicability;
@ -362,7 +364,7 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
// Don't run unused pass for #[derive()]
if let FnKind::Method(..) = fk {
let parent = ir.tcx.hir.get_parent(id);
if let Some(hir::map::NodeKind::Item(i)) = ir.tcx.hir.find(parent) {
if let Some(NodeKind::Item(i)) = ir.tcx.hir.find(parent) {
if i.attrs.iter().any(|a| a.check_name("automatically_derived")) {
return;
}

View File

@ -70,7 +70,7 @@ use self::Aliasability::*;
use middle::region;
use hir::def_id::{DefId, LocalDefId};
use hir::map as hir_map;
use hir::map::NodeKind;
use infer::InferCtxt;
use hir::def::{Def, CtorKind};
use ty::adjustment;
@ -343,7 +343,7 @@ impl MutabilityCategory {
fn from_local(tcx: TyCtxt, tables: &ty::TypeckTables, id: ast::NodeId) -> MutabilityCategory {
let ret = match tcx.hir.get(id) {
hir_map::NodeKind::Binding(p) => match p.node {
NodeKind::Binding(p) => match p.node {
PatKind::Binding(..) => {
let bm = *tables.pat_binding_modes()
.get(p.hir_id)

View File

@ -16,7 +16,7 @@
// reachable as well.
use hir::{CodegenFnAttrs, CodegenFnAttrFlags};
use hir::map as hir_map;
use hir::map::NodeKind;
use hir::def::Def;
use hir::def_id::{DefId, CrateNum};
use rustc_data_structures::sync::Lrc;
@ -64,7 +64,7 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) {
match tcx.hir.find(impl_node_id) {
Some(hir_map::NodeKind::Item(item)) =>
Some(NodeKind::Item(item)) =>
item_might_be_inlined(tcx, &item, codegen_fn_attrs),
Some(..) | None =>
span_bug!(impl_item.span, "impl did is not an item")
@ -156,14 +156,14 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
};
match self.tcx.hir.find(node_id) {
Some(hir_map::NodeKind::Item(item)) => {
Some(NodeKind::Item(item)) => {
match item.node {
hir::ItemKind::Fn(..) =>
item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)),
_ => false,
}
}
Some(hir_map::NodeKind::TraitItem(trait_method)) => {
Some(NodeKind::TraitItem(trait_method)) => {
match trait_method.node {
hir::TraitItemKind::Const(_, ref default) => default.is_some(),
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
@ -171,7 +171,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
hir::TraitItemKind::Type(..) => false,
}
}
Some(hir_map::NodeKind::ImplItem(impl_item)) => {
Some(NodeKind::ImplItem(impl_item)) => {
match impl_item.node {
hir::ImplItemKind::Const(..) => true,
hir::ImplItemKind::Method(..) => {
@ -219,12 +219,12 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
}
}
fn propagate_node(&mut self, node: &hir_map::NodeKind<'tcx>,
fn propagate_node(&mut self, node: &NodeKind<'tcx>,
search_item: ast::NodeId) {
if !self.any_library {
// If we are building an executable, only explicitly extern
// types need to be exported.
if let hir_map::NodeKind::Item(item) = *node {
if let NodeKind::Item(item) = *node {
let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.node {
header.abi != Abi::Rust
} else {
@ -248,7 +248,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
}
match *node {
hir_map::NodeKind::Item(item) => {
NodeKind::Item(item) => {
match item.node {
hir::ItemKind::Fn(.., body) => {
let def_id = self.tcx.hir.local_def_id(item.id);
@ -285,7 +285,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
hir::ItemKind::GlobalAsm(..) => {}
}
}
hir_map::NodeKind::TraitItem(trait_method) => {
NodeKind::TraitItem(trait_method) => {
match trait_method.node {
hir::TraitItemKind::Const(_, None) |
hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => {
@ -298,7 +298,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
hir::TraitItemKind::Type(..) => {}
}
}
hir_map::NodeKind::ImplItem(impl_item) => {
NodeKind::ImplItem(impl_item) => {
match impl_item.node {
hir::ImplItemKind::Const(_, body) => {
self.visit_nested_body(body);
@ -313,16 +313,16 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
hir::ImplItemKind::Type(_) => {}
}
}
hir_map::NodeKind::Expr(&hir::Expr { node: hir::ExprKind::Closure(.., body, _, _), .. }) => {
NodeKind::Expr(&hir::Expr { node: hir::ExprKind::Closure(.., body, _, _), .. }) => {
self.visit_nested_body(body);
}
// Nothing to recurse on for these
hir_map::NodeKind::ForeignItem(_) |
hir_map::NodeKind::Variant(_) |
hir_map::NodeKind::StructCtor(_) |
hir_map::NodeKind::Field(_) |
hir_map::NodeKind::Ty(_) |
hir_map::NodeKind::MacroDef(_) => {}
NodeKind::ForeignItem(_) |
NodeKind::Variant(_) |
NodeKind::StructCtor(_) |
NodeKind::Field(_) |
NodeKind::Ty(_) |
NodeKind::MacroDef(_) => {}
_ => {
bug!("found unexpected thingy in worklist: {}",
self.tcx.hir.node_to_string(search_item))

View File

@ -30,6 +30,7 @@ use ty::TyCtxt;
use ty::query::Providers;
use hir;
use hir::map::NodeKind;
use hir::def_id::DefId;
use hir::intravisit::{self, Visitor, NestedVisitorMap};
use hir::{Block, Arm, Pat, PatKind, Stmt, Expr, Local};
@ -257,7 +258,7 @@ impl Scope {
}
let span = tcx.hir.span(node_id);
if let ScopeData::Remainder(r) = self.data() {
if let hir::map::NodeKind::Block(ref blk) = tcx.hir.get(node_id) {
if let NodeKind::Block(ref blk) = tcx.hir.get(node_id) {
// Want span for scope starting after the
// indexed statement and ending at end of
// `blk`; reuse span of `blk` and shift `lo`
@ -1420,8 +1421,8 @@ fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
// record its impl/trait parent, as it can also have
// lifetime parameters free in this body.
match tcx.hir.get(id) {
hir::map::NodeKind::ImplItem(_) |
hir::map::NodeKind::TraitItem(_) => {
NodeKind::ImplItem(_) |
NodeKind::TraitItem(_) => {
visitor.scope_tree.root_parent = Some(tcx.hir.get_parent(id));
}
_ => {}

View File

@ -17,7 +17,7 @@
use hir::def::Def;
use hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
use hir::map::Map;
use hir::map::{NodeKind, Map};
use hir::{GenericArg, GenericParam, ItemLocalId, LifetimeName, ParamName};
use ty::{self, TyCtxt, GenericParamDefKind};
@ -1440,10 +1440,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
debug!("node id first={:?}", node_id);
if let Some((id, span, name)) = match self.tcx.hir.get(node_id) {
hir::map::NodeKind::Lifetime(hir_lifetime) => {
NodeKind::Lifetime(hir_lifetime) => {
Some((hir_lifetime.id, hir_lifetime.span, hir_lifetime.name.ident()))
}
hir::map::NodeKind::GenericParam(param) => {
NodeKind::GenericParam(param) => {
Some((param.id, param.span, param.name.ident()))
}
_ => None,
@ -1466,10 +1466,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
None => {
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
if let Some((id, span, name)) = match self.tcx.hir.get(node_id) {
hir::map::NodeKind::Lifetime(hir_lifetime) => {
NodeKind::Lifetime(hir_lifetime) => {
Some((hir_lifetime.id, hir_lifetime.span, hir_lifetime.name.ident()))
}
hir::map::NodeKind::GenericParam(param) => {
NodeKind::GenericParam(param) => {
Some((param.id, param.span, param.name.ident()))
}
_ => None,
@ -1643,15 +1643,15 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
} else if let Some(body_id) = outermost_body {
let fn_id = self.tcx.hir.body_owner(body_id);
match self.tcx.hir.get(fn_id) {
hir::map::NodeKind::Item(&hir::Item {
NodeKind::Item(&hir::Item {
node: hir::ItemKind::Fn(..),
..
})
| hir::map::NodeKind::TraitItem(&hir::TraitItem {
| NodeKind::TraitItem(&hir::TraitItem {
node: hir::TraitItemKind::Method(..),
..
})
| hir::map::NodeKind::ImplItem(&hir::ImplItem {
| NodeKind::ImplItem(&hir::ImplItem {
node: hir::ImplItemKind::Method(..),
..
}) => {
@ -1868,12 +1868,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let parent = self.tcx.hir.get_parent_node(output.id);
let body = match self.tcx.hir.get(parent) {
// `fn` definitions and methods.
hir::map::NodeKind::Item(&hir::Item {
NodeKind::Item(&hir::Item {
node: hir::ItemKind::Fn(.., body),
..
}) => Some(body),
hir::map::NodeKind::TraitItem(&hir::TraitItem {
NodeKind::TraitItem(&hir::TraitItem {
node: hir::TraitItemKind::Method(_, ref m),
..
}) => {
@ -1896,7 +1896,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
}
hir::map::NodeKind::ImplItem(&hir::ImplItem {
NodeKind::ImplItem(&hir::ImplItem {
node: hir::ImplItemKind::Method(_, body),
..
}) => {
@ -1918,7 +1918,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
// Foreign functions, `fn(...) -> R` and `Trait(...) -> R` (both types and bounds).
hir::map::NodeKind::ForeignItem(_) | hir::map::NodeKind::Ty(_) | hir::map::NodeKind::TraitRef(_) => None,
NodeKind::ForeignItem(_) | NodeKind::Ty(_) | NodeKind::TraitRef(_) => None,
// Everything else (only closures?) doesn't
// actually enjoy elision in return types.
_ => {

View File

@ -29,6 +29,7 @@ use super::{
use errors::{Applicability, DiagnosticBuilder};
use hir;
use hir::map::NodeKind;
use hir::def_id::DefId;
use infer::{self, InferCtxt};
use infer::type_variable::TypeVariableOrigin;
@ -864,7 +865,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
err: &mut DiagnosticBuilder<'tcx>) {
if let &ObligationCauseCode::VariableType(node_id) = code {
let parent_node = self.tcx.hir.get_parent_node(node_id);
if let Some(hir::map::NodeKind::Local(ref local)) = self.tcx.hir.find(parent_node) {
if let Some(NodeKind::Local(ref local)) = self.tcx.hir.find(parent_node) {
if let Some(ref expr) = local.init {
if let hir::ExprKind::Index(_, _) = expr.node {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
@ -932,9 +933,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
/// returns a span and `ArgKind` information that describes the
/// arguments it expects. This can be supplied to
/// `report_arg_count_mismatch`.
pub fn get_fn_like_arguments(&self, node: hir::map::NodeKind) -> (Span, Vec<ArgKind>) {
pub fn get_fn_like_arguments(&self, node: NodeKind) -> (Span, Vec<ArgKind>) {
match node {
hir::map::NodeKind::Expr(&hir::Expr {
NodeKind::Expr(&hir::Expr {
node: hir::ExprKind::Closure(_, ref _decl, id, span, _),
..
}) => {
@ -961,17 +962,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
})
.collect::<Vec<ArgKind>>())
}
hir::map::NodeKind::Item(&hir::Item {
NodeKind::Item(&hir::Item {
span,
node: hir::ItemKind::Fn(ref decl, ..),
..
}) |
hir::map::NodeKind::ImplItem(&hir::ImplItem {
NodeKind::ImplItem(&hir::ImplItem {
span,
node: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _),
..
}) |
hir::map::NodeKind::TraitItem(&hir::TraitItem {
NodeKind::TraitItem(&hir::TraitItem {
span,
node: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _),
..
@ -987,7 +988,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
_ => ArgKind::Arg("_".to_owned(), "_".to_owned())
}).collect::<Vec<ArgKind>>())
}
hir::map::NodeKind::Variant(&hir::Variant {
NodeKind::Variant(&hir::Variant {
span,
node: hir::VariantKind {
data: hir::VariantData::Tuple(ref fields, _),
@ -1000,7 +1001,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
ArgKind::Arg(field.ident.to_string(), "_".to_string())
}).collect::<Vec<_>>())
}
hir::map::NodeKind::StructCtor(ref variant_data) => {
NodeKind::StructCtor(ref variant_data) => {
(self.tcx.sess.source_map().def_span(self.tcx.hir.span(variant_data.id())),
variant_data.fields()
.iter().map(|_| ArgKind::Arg("_".to_owned(), "_".to_owned()))

View File

@ -15,6 +15,7 @@ pub use self::IntVarValue::*;
pub use self::fold::TypeFoldable;
use hir::{map as hir_map, FreevarMap, TraitMap};
use hir::map::NodeKind;
use hir::def::{Def, CtorKind, ExportMap};
use hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use hir::map::DefPathData;
@ -2478,7 +2479,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn expr_span(self, id: NodeId) -> Span {
match self.hir.find(id) {
Some(hir_map::NodeKind::Expr(e)) => {
Some(NodeKind::Expr(e)) => {
e.span
}
Some(f) => {
@ -2505,7 +2506,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn opt_associated_item(self, def_id: DefId) -> Option<AssociatedItem> {
let is_associated_item = if let Some(node_id) = self.hir.as_local_node_id(def_id) {
match self.hir.get(node_id) {
hir_map::NodeKind::TraitItem(_) | hir_map::NodeKind::ImplItem(_) => true,
NodeKind::TraitItem(_) | NodeKind::ImplItem(_) => true,
_ => false,
}
} else {
@ -2895,7 +2896,7 @@ fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option
/// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition
pub fn is_impl_trait_defn(tcx: TyCtxt, def_id: DefId) -> Option<DefId> {
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
if let hir::map::NodeKind::Item(item) = tcx.hir.get(node_id) {
if let NodeKind::Item(item) = tcx.hir.get(node_id) {
if let hir::ItemKind::Existential(ref exist_ty) = item.node {
return exist_ty.impl_trait_fn;
}

View File

@ -16,6 +16,7 @@
// 2. loans made in overlapping scopes do not conflict
// 3. assignments do not affect things loaned out as immutable
// 4. moves do not affect things loaned out in any way
use self::UseError::*;
use borrowck::*;
@ -29,6 +30,7 @@ use rustc::ty::{self, TyCtxt, RegionKind};
use syntax::ast;
use syntax_pos::Span;
use rustc::hir;
use rustc::hir::map::NodeKind;
use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin};
use std::rc::Rc;
@ -201,7 +203,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
let node_id = bccx.tcx.hir.as_local_node_id(def_id).unwrap();
let movable_generator = !match bccx.tcx.hir.get(node_id) {
hir::map::NodeKind::Expr(&hir::Expr {
NodeKind::Expr(&hir::Expr {
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
..
}) => true,

View File

@ -21,7 +21,7 @@ pub use self::MovedValueUseKind::*;
use self::InteriorKind::*;
use rustc::hir::HirId;
use rustc::hir::map as hir_map;
use rustc::hir::map::NodeKind;
use rustc::hir::map::blocks::FnLikeNode;
use rustc::cfg;
use rustc::middle::borrowck::{BorrowCheckResult, SignalledError};
@ -95,8 +95,8 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
let owner_id = tcx.hir.as_local_node_id(owner_def_id).unwrap();
match tcx.hir.get(owner_id) {
hir_map::NodeKind::StructCtor(_) |
hir_map::NodeKind::Variant(_) => {
NodeKind::StructCtor(_) |
NodeKind::Variant(_) => {
// We get invoked with anything that has MIR, but some of
// those things (notably the synthesized constructors from
// tuple structs/variants) do not have an associated body
@ -419,7 +419,7 @@ fn closure_to_block(closure_id: LocalDefId,
tcx: TyCtxt) -> ast::NodeId {
let closure_id = tcx.hir.local_def_id_to_node_id(closure_id);
match tcx.hir.get(closure_id) {
hir_map::NodeKind::Expr(expr) => match expr.node {
NodeKind::Expr(expr) => match expr.node {
hir::ExprKind::Closure(.., body_id, _, _) => {
body_id.node_id
}
@ -908,7 +908,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
let node = self.tcx.hir.get(node_id);
// This pattern probably always matches.
if let hir_map::NodeKind::Expr(
if let NodeKind::Expr(
hir::Expr { node: hir::ExprKind::Index(lhs, _), ..}
) = node {
let ty = self.tables.expr_ty(lhs);
@ -1032,7 +1032,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
if let ty::ReScope(scope) = *super_scope {
let node_id = scope.node_id(self.tcx, &self.region_scope_tree);
match self.tcx.hir.find(node_id) {
Some(hir_map::NodeKind::Stmt(_)) => {
Some(NodeKind::Stmt(_)) => {
if *sub_scope != ty::ReStatic {
db.note("consider using a `let` binding to increase its lifetime");
}
@ -1183,7 +1183,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
fn local_binding_mode(&self, node_id: ast::NodeId) -> ty::BindingMode {
let pat = match self.tcx.hir.get(node_id) {
hir_map::NodeKind::Binding(pat) => pat,
NodeKind::Binding(pat) => pat,
node => bug!("bad node for local: {:?}", node)
};
@ -1259,7 +1259,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
None => return
};
if let hir_map::NodeKind::Field(ref field) = self.tcx.hir.get(node_id) {
if let NodeKind::Field(ref field) = self.tcx.hir.get(node_id) {
if let Some(msg) = self.suggest_mut_for_immutable(&field.ty, false) {
db.span_label(field.ty.span, msg);
}

View File

@ -13,6 +13,7 @@ use std::sync::Arc;
use monomorphize::Instance;
use rustc::hir;
use rustc::hir::map::NodeKind;
use rustc::hir::CodegenFnAttrFlags;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE, CRATE_DEF_INDEX};
use rustc_data_structures::fingerprint::Fingerprint;
@ -94,7 +95,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// As a result, if this id is an FFI item (foreign item) then we only
// let it through if it's included statically.
match tcx.hir.get(node_id) {
hir::map::NodeKind::ForeignItem(..) => {
NodeKind::ForeignItem(..) => {
let def_id = tcx.hir.local_def_id(node_id);
if tcx.is_statically_included_foreign_item(def_id) {
Some(def_id)
@ -104,14 +105,14 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
// Only consider nodes that actually have exported symbols.
hir::map::NodeKind::Item(&hir::Item {
NodeKind::Item(&hir::Item {
node: hir::ItemKind::Static(..),
..
}) |
hir::map::NodeKind::Item(&hir::Item {
NodeKind::Item(&hir::Item {
node: hir::ItemKind::Fn(..), ..
}) |
hir::map::NodeKind::ImplItem(&hir::ImplItem {
NodeKind::ImplItem(&hir::ImplItem {
node: hir::ImplItemKind::Method(..),
..
}) => {

View File

@ -11,7 +11,7 @@
use libc::c_uint;
use llvm::{self, SetUnnamedAddr, True};
use rustc::hir::def_id::DefId;
use rustc::hir::map as hir_map;
use rustc::hir::map::NodeKind;
use debuginfo;
use base;
use monomorphize::MonoItem;
@ -135,7 +135,7 @@ pub fn get_static(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll Value {
let llty = cx.layout_of(ty).llvm_type(cx);
let (g, attrs) = match cx.tcx.hir.get(id) {
hir_map::NodeKind::Item(&hir::Item {
NodeKind::Item(&hir::Item {
ref attrs, span, node: hir::ItemKind::Static(..), ..
}) => {
if declare::get_declared_value(cx, &sym[..]).is_some() {
@ -153,7 +153,7 @@ pub fn get_static(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll Value {
(g, attrs)
}
hir_map::NodeKind::ForeignItem(&hir::ForeignItem {
NodeKind::ForeignItem(&hir::ForeignItem {
ref attrs, span, node: hir::ForeignItemKind::Static(..), ..
}) => {
let fn_attrs = cx.tcx.codegen_fn_attrs(def_id);

View File

@ -98,7 +98,7 @@
//! DefPaths which are much more robust in the face of changes to the code base.
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::hir::map as hir_map;
use rustc::hir::map::NodeKind;
use rustc::hir::CodegenFnAttrFlags;
use rustc::hir::map::definitions::DefPathData;
use rustc::ich::NodeIdHashingMode;
@ -261,7 +261,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
// FIXME(eddyb) Precompute a custom symbol name based on attributes.
let is_foreign = if let Some(id) = node_id {
match tcx.hir.get(id) {
hir_map::NodeKind::ForeignItem(_) => true,
NodeKind::ForeignItem(_) => true,
_ => false,
}
} else {

View File

@ -399,7 +399,8 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
_ => self.tcx.sess.span_fatal(
attr.span,
&format!(
"clean/dirty auto-assertions not yet defined for NodeKind::Item.node={:?}",
"clean/dirty auto-assertions not yet defined \
for NodeKind::Item.node={:?}",
item.node
)
),

View File

@ -34,7 +34,7 @@ use rustc::cfg;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty};
use rustc::traits;
use rustc::hir::map as hir_map;
use hir::map::NodeKind;
use util::nodemap::NodeSet;
use lint::{LateContext, LintContext, LintArray};
use lint::{LintPass, LateLintPass, EarlyLintPass, EarlyContext};
@ -427,7 +427,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
let real_trait = trait_ref.path.def.def_id();
if let Some(node_id) = cx.tcx.hir.as_local_node_id(real_trait) {
match cx.tcx.hir.find(node_id) {
Some(hir_map::NodeKind::Item(item)) => {
Some(NodeKind::Item(item)) => {
if let hir::VisibilityKind::Inherited = item.vis.node {
for impl_item_ref in impl_item_refs {
self.private_traits.insert(impl_item_ref.id.node_id);
@ -981,7 +981,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
fn expr_refers_to_this_fn(cx: &LateContext, fn_id: ast::NodeId, id: ast::NodeId) -> bool {
match cx.tcx.hir.get(id) {
hir_map::NodeKind::Expr(&hir::Expr { node: hir::ExprKind::Call(ref callee, _), .. }) => {
NodeKind::Expr(&hir::Expr { node: hir::ExprKind::Call(ref callee, _), .. }) => {
let def = if let hir::ExprKind::Path(ref qpath) = callee.node {
cx.tables.qpath_def(qpath, callee.hir_id)
} else {
@ -1004,7 +1004,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
use rustc::ty::adjustment::*;
// Ignore non-expressions.
let expr = if let hir_map::NodeKind::Expr(e) = cx.tcx.hir.get(id) {
let expr = if let NodeKind::Expr(e) = cx.tcx.hir.get(id) {
e
} else {
return false;
@ -1864,7 +1864,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestFunctions {
if attr.name() == "test" {
let parent = cx.tcx.hir.get_parent(it.id);
match cx.tcx.hir.find(parent) {
Some(hir_map::NodeKind::Item(hir::Item {node: hir::ItemKind::Mod(_), ..})) |
Some(NodeKind::Item(hir::Item {node: hir::ItemKind::Mod(_), ..})) |
None => {}
_ => {
cx.struct_span_lint(

View File

@ -10,7 +10,7 @@
#![allow(non_snake_case)]
use rustc::hir::map as hir_map;
use rustc::hir::map::NodeKind;
use rustc::ty::subst::Substs;
use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
use rustc::ty::layout::{self, IntegerExt, LayoutOf};
@ -137,7 +137,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
};
if lit_val < min || lit_val > max {
let parent_id = cx.tcx.hir.get_parent_node(e.id);
if let hir_map::NodeKind::Expr(parent_expr) = cx.tcx.hir.get(parent_id) {
if let NodeKind::Expr(parent_expr) = cx.tcx.hir.get(parent_id) {
if let hir::ExprKind::Cast(..) = parent_expr.node {
if let ty::Char = cx.tables.expr_ty(parent_expr).sty {
let mut err = cx.struct_span_lint(

View File

@ -12,6 +12,7 @@
use borrow_check::nll::region_infer::RegionInferenceContext;
use rustc::hir;
use rustc::hir::map::NodeKind;
use rustc::hir::def_id::DefId;
use rustc::hir::map::definitions::DefPathData;
use rustc::infer::InferCtxt;
@ -232,7 +233,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
));
let movable_generator = match tcx.hir.get(id) {
hir::map::NodeKind::Expr(&hir::Expr {
NodeKind::Expr(&hir::Expr {
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
..
}) => false,

View File

@ -9,6 +9,7 @@
// except according to those terms.
use rustc::hir;
use rustc::hir::map::NodeKind;
use rustc::mir::{self, BindingForm, ClearCrossCrate, Local, Location, Mir};
use rustc::mir::{Mutability, Place, Projection, ProjectionElem, Static};
use rustc::ty::{self, TyCtxt};
@ -246,7 +247,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
.var_hir_id
.assert_crate_local();
let upvar_node_id = self.tcx.hir.hir_to_node_id(upvar_hir_id);
if let Some(hir::map::NodeKind::Binding(pat)) = self.tcx.hir.find(upvar_node_id) {
if let Some(NodeKind::Binding(pat)) = self.tcx.hir.find(upvar_node_id) {
if let hir::PatKind::Binding(
hir::BindingAnnotation::Unannotated,
_,

View File

@ -14,6 +14,7 @@ use build::scope::{CachedBlock, DropKind};
use hair::cx::Cx;
use hair::{LintLevel, BindingMode, PatternKind};
use rustc::hir;
use rustc::hir::map::NodeKind;
use rustc::hir::def_id::{DefId, LocalDefId};
use rustc::middle::region;
use rustc::mir::*;
@ -40,9 +41,9 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
// Figure out what primary body this item has.
let body_id = match tcx.hir.get(id) {
hir::map::NodeKind::Variant(variant) =>
NodeKind::Variant(variant) =>
return create_constructor_shim(tcx, id, &variant.node.data),
hir::map::NodeKind::StructCtor(ctor) =>
NodeKind::StructCtor(ctor) =>
return create_constructor_shim(tcx, id, ctor),
_ => match tcx.hir.maybe_body_owned_by(id) {
@ -520,7 +521,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
by_ref,
mutability: Mutability::Not,
};
if let Some(hir::map::NodeKind::Binding(pat)) = tcx.hir.find(var_id) {
if let Some(NodeKind::Binding(pat)) = tcx.hir.find(var_id) {
if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
decl.debug_name = ident.name;

View File

@ -19,6 +19,7 @@ use hair::*;
use rustc_data_structures::indexed_vec::Idx;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::hir::map::blocks::FnLikeNode;
use rustc::hir::map::NodeKind;
use rustc::middle::region;
use rustc::infer::InferCtxt;
use rustc::ty::subst::Subst;
@ -202,7 +203,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> {
let tcx = self.tcx.global_tcx();
let p = match tcx.hir.get(p.id) {
hir::map::NodeKind::Pat(p) | hir::map::NodeKind::Binding(p) => p,
NodeKind::Pat(p) | NodeKind::Binding(p) => p,
node => bug!("pattern became {:?}", node)
};
Pattern::from_hir(tcx,

View File

@ -191,7 +191,7 @@
use rustc::hir::{self, CodegenFnAttrFlags};
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::hir::map as hir_map;
use rustc::hir::map::NodeKind;
use rustc::hir::def_id::DefId;
use rustc::mir::interpret::{AllocId, ConstValue, ScalarMaybeUndef};
use rustc::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem};
@ -740,7 +740,7 @@ fn should_monomorphize_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance:
};
return match tcx.hir.get_if_local(def_id) {
Some(hir_map::NodeKind::ForeignItem(..)) => {
Some(NodeKind::ForeignItem(..)) => {
false // foreign items are linked against, not codegened.
}
Some(_) => true,

View File

@ -15,6 +15,7 @@ use rustc_data_structures::sync::Lrc;
use rustc::ty::query::Providers;
use rustc::ty::{self, TyCtxt};
use rustc::hir;
use rustc::hir::map::NodeKind;
use rustc::hir::def_id::DefId;
use rustc::lint::builtin::{SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, UNUSED_UNSAFE};
use rustc::mir::*;
@ -407,7 +408,7 @@ fn is_enclosed(tcx: TyCtxt,
if parent_id != id {
if used_unsafe.contains(&parent_id) {
Some(("block".to_string(), parent_id))
} else if let Some(hir::map::NodeKind::Item(&hir::Item {
} else if let Some(NodeKind::Item(&hir::Item {
node: hir::ItemKind::Fn(_, header, _, _),
..
})) = tcx.hir.find(parent_id) {

View File

@ -11,7 +11,7 @@ use self::Context::*;
use rustc::session::Session;
use rustc::hir::map::Map;
use rustc::hir::map::{Map, NodeKind};
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
use rustc::hir::{self, Destination};
use syntax::ast;
@ -115,7 +115,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
if loop_id != ast::DUMMY_NODE_ID {
match self.hir_map.find(loop_id).unwrap() {
hir::map::NodeKind::Block(_) => return,
NodeKind::Block(_) => return,
_=> (),
}
}
@ -158,7 +158,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
match label.target_id {
Ok(loop_id) => {
if let hir::map::NodeKind::Block(block) = self.hir_map.find(loop_id).unwrap() {
if let NodeKind::Block(block) = self.hir_map.find(loop_id).unwrap() {
struct_span_err!(self.sess, e.span, E0696,
"`continue` pointing to a labeled block")
.span_label(e.span,

View File

@ -25,6 +25,7 @@ extern crate syntax_pos;
extern crate rustc_data_structures;
use rustc::hir::{self, PatKind};
use hir::map::NodeKind;
use rustc::hir::def::Def;
use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, CrateNum, DefId};
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
@ -659,17 +660,17 @@ impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> {
match self.tcx.hir.as_local_node_id(did) {
Some(node_id) => {
let vis = match self.tcx.hir.get(node_id) {
hir::map::NodeKind::Item(item) => &item.vis,
hir::map::NodeKind::ForeignItem(foreign_item) => &foreign_item.vis,
hir::map::NodeKind::ImplItem(impl_item) => &impl_item.vis,
hir::map::NodeKind::TraitItem(..) |
hir::map::NodeKind::Variant(..) => {
NodeKind::Item(item) => &item.vis,
NodeKind::ForeignItem(foreign_item) => &foreign_item.vis,
NodeKind::ImplItem(impl_item) => &impl_item.vis,
NodeKind::TraitItem(..) |
NodeKind::Variant(..) => {
return self.def_id_visibility(self.tcx.hir.get_parent_did(node_id));
}
hir::map::NodeKind::StructCtor(vdata) => {
NodeKind::StructCtor(vdata) => {
let struct_node_id = self.tcx.hir.get_parent(node_id);
let struct_vis = match self.tcx.hir.get(struct_node_id) {
hir::map::NodeKind::Item(item) => &item.vis,
NodeKind::Item(item) => &item.vis,
node => bug!("unexpected node kind: {:?}", node),
};
let mut ctor_vis
@ -1037,7 +1038,7 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
// .. and it corresponds to a private type in the AST (this returns
// None for type parameters)
match self.tcx.hir.find(node_id) {
Some(hir::map::NodeKind::Item(ref item)) => !item.vis.node.is_pub(),
Some(NodeKind::Item(ref item)) => !item.vis.node.is_pub(),
Some(_) | None => false,
}
} else {
@ -1469,8 +1470,8 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'
// Non-local means public (private items can't leave their crate, modulo bugs)
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
let hir_vis = match self.tcx.hir.find(node_id) {
Some(hir::map::NodeKind::Item(item)) => &item.vis,
Some(hir::map::NodeKind::ForeignItem(item)) => &item.vis,
Some(NodeKind::Item(item)) => &item.vis,
Some(NodeKind::ForeignItem(item)) => &item.vis,
_ => bug!("expected item of foreign item"),
};

View File

@ -13,6 +13,7 @@
use check::FnCtxt;
use rustc::hir::map as hir_map;
use hir::map::NodeKind;
use rustc_data_structures::sync::Lrc;
use rustc::ty::{self, Ty, TyCtxt, ToPolyTraitRef, ToPredicate, TypeFoldable};
use hir::def::Def;
@ -275,7 +276,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
);
match (filename, parent_node) {
(FileName::Real(_), hir_map::NodeKind::Local(hir::Local {
(FileName::Real(_), NodeKind::Local(hir::Local {
source: hir::LocalSource::Normal,
ty,
..

View File

@ -761,7 +761,7 @@ fn primary_body_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-> Option<(hir::BodyId, Option<&'tcx hir::FnDecl>)>
{
match tcx.hir.get(id) {
hir::map::NodeKind::Item(item) => {
NodeKind::Item(item) => {
match item.node {
hir::ItemKind::Const(_, body) |
hir::ItemKind::Static(_, _, body) =>
@ -772,7 +772,7 @@ fn primary_body_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
None,
}
}
hir::map::NodeKind::TraitItem(item) => {
NodeKind::TraitItem(item) => {
match item.node {
hir::TraitItemKind::Const(_, Some(body)) =>
Some((body, None)),
@ -782,7 +782,7 @@ fn primary_body_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
None,
}
}
hir::map::NodeKind::ImplItem(item) => {
NodeKind::ImplItem(item) => {
match item.node {
hir::ImplItemKind::Const(_, body) =>
Some((body, None)),
@ -792,7 +792,7 @@ fn primary_body_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
None,
}
}
hir::map::NodeKind::AnonConst(constant) => Some((constant.body, None)),
NodeKind::AnonConst(constant) => Some((constant.body, None)),
_ => None,
}
}

View File

@ -23,7 +23,7 @@ use rustc::ty::util::CopyImplementationError;
use rustc::infer;
use rustc::hir::def_id::DefId;
use rustc::hir::map as hir_map;
use hir::map::NodeKind;
use rustc::hir::{self, ItemKind};
pub fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_def_id: DefId) {
@ -60,7 +60,7 @@ fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did:
// Destructors only work on nominal types.
if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_did) {
match tcx.hir.find(impl_node_id) {
Some(hir_map::NodeKind::Item(item)) => {
Some(NodeKind::Item(item)) => {
let span = match item.node {
ItemKind::Impl(.., ref ty, _) => ty.span,
_ => item.span,

View File

@ -50,10 +50,11 @@ use syntax::symbol::{keywords, Symbol};
use syntax_pos::{Span, DUMMY_SP};
use rustc::hir::def::{CtorKind, Def};
use rustc::hir::map::NodeKind;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc::hir::GenericParamKind;
use rustc::hir::{self, map as hir_map, CodegenFnAttrFlags, CodegenFnAttrs, Unsafety};
use rustc::hir::{self, CodegenFnAttrFlags, CodegenFnAttrs, Unsafety};
///////////////////////////////////////////////////////////////////////////
// Main entry point
@ -671,7 +672,7 @@ fn super_predicates_of<'a, 'tcx>(
let trait_node_id = tcx.hir.as_local_node_id(trait_def_id).unwrap();
let item = match tcx.hir.get(trait_node_id) {
hir_map::NodeKind::Item(item) => item,
NodeKind::Item(item) => item,
_ => bug!("trait_node_id {} is not an item", trait_node_id),
};
@ -740,7 +741,7 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::
fn has_late_bound_regions<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
node: hir_map::NodeKind<'tcx>,
node: NodeKind<'tcx>,
) -> Option<Span> {
struct LateBoundRegionsDetector<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
@ -826,25 +827,25 @@ fn has_late_bound_regions<'a, 'tcx>(
}
match node {
hir_map::NodeKind::TraitItem(item) => match item.node {
NodeKind::TraitItem(item) => match item.node {
hir::TraitItemKind::Method(ref sig, _) => {
has_late_bound_regions(tcx, &item.generics, &sig.decl)
}
_ => None,
},
hir_map::NodeKind::ImplItem(item) => match item.node {
NodeKind::ImplItem(item) => match item.node {
hir::ImplItemKind::Method(ref sig, _) => {
has_late_bound_regions(tcx, &item.generics, &sig.decl)
}
_ => None,
},
hir_map::NodeKind::ForeignItem(item) => match item.node {
NodeKind::ForeignItem(item) => match item.node {
hir::ForeignItemKind::Fn(ref fn_decl, _, ref generics) => {
has_late_bound_regions(tcx, generics, fn_decl)
}
_ => None,
},
hir_map::NodeKind::Item(item) => match item.node {
NodeKind::Item(item) => match item.node {
hir::ItemKind::Fn(ref fn_decl, .., ref generics, _) => {
has_late_bound_regions(tcx, generics, fn_decl)
}
@ -1396,29 +1397,29 @@ fn find_existential_constraints<'a, 'tcx>(
}
fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig<'tcx> {
use rustc::hir::map::*;
use rustc::hir::*;
use rustc::hir::map::NodeKind::*;
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
let icx = ItemCtxt::new(tcx, def_id);
match tcx.hir.get(node_id) {
NodeKind::TraitItem(hir::TraitItem {
TraitItem(hir::TraitItem {
node: TraitItemKind::Method(sig, _),
..
})
| NodeKind::ImplItem(hir::ImplItem {
| ImplItem(hir::ImplItem {
node: ImplItemKind::Method(sig, _),
..
}) => AstConv::ty_of_fn(&icx, sig.header.unsafety, sig.header.abi, &sig.decl),
NodeKind::Item(hir::Item {
Item(hir::Item {
node: ItemKind::Fn(decl, header, _, _),
..
}) => AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl),
NodeKind::ForeignItem(&hir::ForeignItem {
ForeignItem(&hir::ForeignItem {
node: ForeignItemKind::Fn(ref fn_decl, _, _),
..
}) => {
@ -1426,8 +1427,8 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig
compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi)
}
NodeKind::StructCtor(&VariantData::Tuple(ref fields, _))
| NodeKind::Variant(&Spanned {
StructCtor(&VariantData::Tuple(ref fields, _))
| Variant(&Spanned {
node:
hir::VariantKind {
data: VariantData::Tuple(ref fields, _),
@ -1448,7 +1449,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig
))
}
NodeKind::Expr(&hir::Expr {
Expr(&hir::Expr {
node: hir::ExprKind::Closure(..),
..
}) => {
@ -2027,7 +2028,7 @@ fn compute_sig_of_foreign_fn_decl<'a, 'tcx>(
fn is_foreign_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
match tcx.hir.get_if_local(def_id) {
Some(hir_map::NodeKind::ForeignItem(..)) => true,
Some(NodeKind::ForeignItem(..)) => true,
Some(_) => false,
_ => bug!("is_foreign_item applied to non-local def-id {:?}", def_id),
}

View File

@ -103,7 +103,7 @@ use rustc::middle;
use rustc::session;
use rustc::util;
use hir::map as hir_map;
use hir::map::NodeKind;
use rustc::infer::InferOk;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt};
@ -187,7 +187,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
match main_t.sty {
ty::FnDef(..) => {
match tcx.hir.find(main_id) {
Some(hir_map::NodeKind::Item(it)) => {
Some(NodeKind::Item(it)) => {
match it.node {
hir::ItemKind::Fn(.., ref generics, _) => {
let mut error = false;
@ -259,7 +259,7 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
match start_t.sty {
ty::FnDef(..) => {
match tcx.hir.find(start_id) {
Some(hir_map::NodeKind::Item(it)) => {
Some(NodeKind::Item(it)) => {
match it.node {
hir::ItemKind::Fn(.., ref generics, _) => {
let mut error = false;

View File

@ -9,6 +9,7 @@
// except according to those terms.
use rustc::hir;
use hir::map::NodeKind;
use rustc::hir::def_id::DefId;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::ty::subst::{Kind, Subst, UnpackedKind};
@ -70,7 +71,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
.as_local_node_id(item_did)
.expect("expected local def-id");
let item = match self.tcx.hir.get(node_id) {
hir::map::NodeKind::Item(item) => item,
NodeKind::Item(item) => item,
_ => bug!(),
};

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use hir::map as hir_map;
use hir::map::NodeKind;
use rustc::hir;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::ty::query::Providers;
@ -40,7 +40,7 @@ fn inferred_outlives_of<'a, 'tcx>(
.expect("expected local def-id");
match tcx.hir.get(id) {
hir_map::NodeKind::Item(item) => match item.node {
NodeKind::Item(item) => match item.node {
hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => {
let crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE);

View File

@ -15,6 +15,7 @@
use arena;
use rustc::hir;
use hir::map::NodeKind;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::ty::{self, CrateVariancesMap, TyCtxt};
use rustc::ty::query::Providers;
@ -61,7 +62,7 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId)
span_bug!(tcx.hir.span(id), "asked to compute variance for wrong kind of item")
};
match tcx.hir.get(id) {
hir::map::NodeKind::Item(item) => match item.node {
NodeKind::Item(item) => match item.node {
hir::ItemKind::Enum(..) |
hir::ItemKind::Struct(..) |
hir::ItemKind::Union(..) |
@ -70,25 +71,25 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId)
_ => unsupported()
},
hir::map::NodeKind::TraitItem(item) => match item.node {
NodeKind::TraitItem(item) => match item.node {
hir::TraitItemKind::Method(..) => {}
_ => unsupported()
},
hir::map::NodeKind::ImplItem(item) => match item.node {
NodeKind::ImplItem(item) => match item.node {
hir::ImplItemKind::Method(..) => {}
_ => unsupported()
},
hir::map::NodeKind::ForeignItem(item) => match item.node {
NodeKind::ForeignItem(item) => match item.node {
hir::ForeignItemKind::Fn(..) => {}
_ => unsupported()
},
hir::map::NodeKind::Variant(_) | hir::map::NodeKind::StructCtor(_) => {}
NodeKind::Variant(_) | NodeKind::StructCtor(_) => {}
_ => unsupported()
}

View File

@ -18,7 +18,7 @@ use syntax::attr;
use syntax::source_map::Spanned;
use syntax_pos::{self, Span};
use rustc::hir::map as hir_map;
use rustc::hir::map::NodeKind;
use rustc::hir::def::Def;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::middle::privacy::AccessLevel;
@ -295,7 +295,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
if !self.view_item_stack.insert(def_node_id) { return false }
let ret = match tcx.hir.get(def_node_id) {
hir_map::NodeKind::Item(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => {
NodeKind::Item(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => {
let prev = mem::replace(&mut self.inlining, true);
for i in &m.item_ids {
let i = self.cx.tcx.hir.expect_item(i.id);
@ -304,13 +304,13 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
self.inlining = prev;
true
}
hir_map::NodeKind::Item(it) if !glob => {
NodeKind::Item(it) if !glob => {
let prev = mem::replace(&mut self.inlining, true);
self.visit_item(it, renamed, om);
self.inlining = prev;
true
}
hir_map::NodeKind::ForeignItem(it) if !glob => {
NodeKind::ForeignItem(it) if !glob => {
// generate a fresh `extern {}` block if we want to inline a foreign item.
om.foreigns.push(hir::ForeignMod {
abi: tcx.hir.get_foreign_abi(it.id),

View File

@ -27,6 +27,7 @@ use syntax::symbol::Symbol;
use rustc::hir;
use rustc::hir::intravisit;
use rustc::hir::map as hir_map;
use hir::map::NodeKind;
use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext};
use rustc::ty;
use syntax::{ast, source_map};
@ -58,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingWhitelistedAttrPass {
id: ast::NodeId) {
let item = match cx.tcx.hir.get(id) {
hir_map::NodeKind::Item(item) => item,
NodeKind::Item(item) => item,
_ => cx.tcx.hir.expect_item(cx.tcx.hir.get_parent(id)),
};