Skip to content

Commit 11665ca

Browse files
committed
Remove path prefixes from NodeKind
1 parent 4b12f70 commit 11665ca

File tree

38 files changed

+186
-164
lines changed

38 files changed

+186
-164
lines changed

src/librustc/infer/anon_types/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use hir::def_id::DefId;
1212
use hir;
13+
use hir::map::NodeKind;
1314
use infer::{self, InferCtxt, InferOk, TypeVariableOrigin};
1415
use infer::outlives::free_region_map::FreeRegionRelations;
1516
use rustc_data_structures::fx::FxHashMap;
@@ -697,7 +698,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
697698
parent_def_id == tcx.hir.local_def_id(anon_parent_node_id)
698699
};
699700
let in_definition_scope = match tcx.hir.find(anon_node_id) {
700-
Some(hir::map::NodeKind::Item(item)) => match item.node {
701+
Some(NodeKind::Item(item)) => match item.node {
701702
// impl trait
702703
hir::ItemKind::Existential(hir::ExistTy {
703704
impl_trait_fn: Some(parent),
@@ -714,7 +715,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
714715
),
715716
_ => def_scope_default(),
716717
},
717-
Some(hir::map::NodeKind::ImplItem(item)) => match item.node {
718+
Some(NodeKind::ImplItem(item)) => match item.node {
718719
hir::ImplItemKind::Existential(_) => may_define_existential_type(
719720
tcx,
720721
self.parent_def_id,

src/librustc/infer/error_reporting/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use super::lexical_region_resolve::RegionResolutionError;
6262

6363
use std::{cmp, fmt};
6464
use hir;
65-
use hir::map as hir_map;
65+
use hir::map::NodeKind;
6666
use hir::def_id::DefId;
6767
use middle::region;
6868
use traits::{ObligationCause, ObligationCauseCode};
@@ -100,8 +100,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
100100
};
101101
let span = scope.span(self, region_scope_tree);
102102
let tag = match self.hir.find(scope.node_id(self, region_scope_tree)) {
103-
Some(hir_map::NodeKind::Block(_)) => "block",
104-
Some(hir_map::NodeKind::Expr(expr)) => match expr.node {
103+
Some(NodeKind::Block(_)) => "block",
104+
Some(NodeKind::Expr(expr)) => match expr.node {
105105
hir::ExprKind::Call(..) => "call",
106106
hir::ExprKind::MethodCall(..) => "method call",
107107
hir::ExprKind::Match(.., hir::MatchSource::IfLetDesugar { .. }) => "if let",
@@ -110,10 +110,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
110110
hir::ExprKind::Match(..) => "match",
111111
_ => "expression",
112112
},
113-
Some(hir_map::NodeKind::Stmt(_)) => "statement",
114-
Some(hir_map::NodeKind::Item(it)) => Self::item_scope_tag(&it),
115-
Some(hir_map::NodeKind::TraitItem(it)) => Self::trait_item_scope_tag(&it),
116-
Some(hir_map::NodeKind::ImplItem(it)) => Self::impl_item_scope_tag(&it),
113+
Some(NodeKind::Stmt(_)) => "statement",
114+
Some(NodeKind::Item(it)) => Self::item_scope_tag(&it),
115+
Some(NodeKind::TraitItem(it)) => Self::trait_item_scope_tag(&it),
116+
Some(NodeKind::ImplItem(it)) => Self::impl_item_scope_tag(&it),
117117
Some(_) | None => {
118118
err.span_note(span, &unknown_scope());
119119
return;
@@ -194,10 +194,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
194194
let scope = region.free_region_binding_scope(self);
195195
let node = self.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
196196
let tag = match self.hir.find(node) {
197-
Some(hir_map::NodeKind::Block(_)) | Some(hir_map::NodeKind::Expr(_)) => "body",
198-
Some(hir_map::NodeKind::Item(it)) => Self::item_scope_tag(&it),
199-
Some(hir_map::NodeKind::TraitItem(it)) => Self::trait_item_scope_tag(&it),
200-
Some(hir_map::NodeKind::ImplItem(it)) => Self::impl_item_scope_tag(&it),
197+
Some(NodeKind::Block(_)) | Some(NodeKind::Expr(_)) => "body",
198+
Some(NodeKind::Item(it)) => Self::item_scope_tag(&it),
199+
Some(NodeKind::TraitItem(it)) => Self::trait_item_scope_tag(&it),
200+
Some(NodeKind::ImplItem(it)) => Self::impl_item_scope_tag(&it),
201201
_ => unreachable!()
202202
};
203203
let (prefix, span) = match *region {
@@ -1127,7 +1127,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11271127
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
11281128
// instead we suggest `T: 'a + 'b` in that case.
11291129
let mut has_bounds = false;
1130-
if let hir_map::NodeKind::GenericParam(ref param) = hir.get(id) {
1130+
if let NodeKind::GenericParam(ref param) = hir.get(id) {
11311131
has_bounds = !param.bounds.is_empty();
11321132
}
11331133
let sp = hir.span(id);

src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use hir;
1212
use ty::{self, Region, TyCtxt};
13-
use hir::map as hir_map;
13+
use hir::map::NodeKind;
1414
use middle::resolve_lifetime as rl;
1515
use hir::intravisit::{self, NestedVisitorMap, Visitor};
1616
use infer::error_reporting::nice_region_error::NiceRegionError;
@@ -40,15 +40,15 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
4040
let def_id = anon_reg.def_id;
4141
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
4242
let fndecl = match self.tcx.hir.get(node_id) {
43-
hir_map::NodeKind::Item(&hir::Item {
43+
NodeKind::Item(&hir::Item {
4444
node: hir::ItemKind::Fn(ref fndecl, ..),
4545
..
4646
}) => &fndecl,
47-
hir_map::NodeKind::TraitItem(&hir::TraitItem {
47+
NodeKind::TraitItem(&hir::TraitItem {
4848
node: hir::TraitItemKind::Method(ref m, ..),
4949
..
5050
})
51-
| hir_map::NodeKind::ImplItem(&hir::ImplItem {
51+
| NodeKind::ImplItem(&hir::ImplItem {
5252
node: hir::ImplItemKind::Method(ref m, ..),
5353
..
5454
}) => &m.decl,

src/librustc/infer/error_reporting/nice_region_error/util.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010

1111
//! Helper functions corresponding to lifetime errors due to
1212
//! anonymous regions.
13+
1314
use hir;
1415
use infer::error_reporting::nice_region_error::NiceRegionError;
1516
use ty::{self, Region, Ty};
1617
use hir::def_id::DefId;
17-
use hir::map as hir_map;
18+
use hir::map::NodeKind;
1819
use syntax_pos::Span;
1920

2021
// The struct contains the information about the anonymous region
@@ -137,8 +138,8 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
137138
.as_local_node_id(suitable_region_binding_scope)
138139
.unwrap();
139140
let is_impl_item = match self.tcx.hir.find(node_id) {
140-
Some(hir_map::NodeKind::Item(..)) | Some(hir_map::NodeKind::TraitItem(..)) => false,
141-
Some(hir_map::NodeKind::ImplItem(..)) => {
141+
Some(NodeKind::Item(..)) | Some(NodeKind::TraitItem(..)) => false,
142+
Some(NodeKind::ImplItem(..)) => {
142143
self.is_bound_region_in_impl_item(suitable_region_binding_scope)
143144
}
144145
_ => return None,

src/librustc/middle/dead.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// closely. The idea is that all reachable symbols are live, codes called
1313
// from live codes are live, and everything else is dead.
1414

15-
use hir::map as hir_map;
15+
use hir::map::NodeKind;
1616
use hir::{self, PatKind};
1717
use hir::intravisit::{self, Visitor, NestedVisitorMap};
1818
use hir::itemlikevisit::ItemLikeVisitor;
@@ -35,10 +35,10 @@ use syntax_pos;
3535
fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
3636
node_id: ast::NodeId) -> bool {
3737
match tcx.hir.find(node_id) {
38-
Some(hir_map::NodeKind::Item(..)) |
39-
Some(hir_map::NodeKind::ImplItem(..)) |
40-
Some(hir_map::NodeKind::ForeignItem(..)) |
41-
Some(hir_map::NodeKind::TraitItem(..)) =>
38+
Some(NodeKind::Item(..)) |
39+
Some(NodeKind::ImplItem(..)) |
40+
Some(NodeKind::ForeignItem(..)) |
41+
Some(NodeKind::TraitItem(..)) =>
4242
true,
4343
_ =>
4444
false
@@ -145,13 +145,13 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
145145
}
146146
}
147147

148-
fn visit_node(&mut self, node: &hir_map::NodeKind<'tcx>) {
148+
fn visit_node(&mut self, node: &NodeKind<'tcx>) {
149149
let had_repr_c = self.repr_has_repr_c;
150150
self.repr_has_repr_c = false;
151151
let had_inherited_pub_visibility = self.inherited_pub_visibility;
152152
self.inherited_pub_visibility = false;
153153
match *node {
154-
hir_map::NodeKind::Item(item) => {
154+
NodeKind::Item(item) => {
155155
match item.node {
156156
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
157157
let def_id = self.tcx.hir.local_def_id(item.id);
@@ -173,13 +173,13 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
173173
_ => ()
174174
}
175175
}
176-
hir_map::NodeKind::TraitItem(trait_item) => {
176+
NodeKind::TraitItem(trait_item) => {
177177
intravisit::walk_trait_item(self, trait_item);
178178
}
179-
hir_map::NodeKind::ImplItem(impl_item) => {
179+
NodeKind::ImplItem(impl_item) => {
180180
intravisit::walk_impl_item(self, impl_item);
181181
}
182-
hir_map::NodeKind::ForeignItem(foreign_item) => {
182+
NodeKind::ForeignItem(foreign_item) => {
183183
intravisit::walk_foreign_item(self, &foreign_item);
184184
}
185185
_ => ()

src/librustc/middle/liveness.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@
102102
//! only dead if the end of the function's block can never be reached.
103103
//! It is the responsibility of typeck to ensure that there are no
104104
//! `return` expressions in a function declared as diverging.
105+
105106
use self::LoopKind::*;
106107
use self::LiveNodeKind::*;
107108
use self::VarKind::*;
108109

109110
use hir::def::*;
111+
use hir::map::NodeKind;
110112
use ty::{self, TyCtxt};
111113
use lint;
112114
use errors::Applicability;
@@ -362,7 +364,7 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
362364
// Don't run unused pass for #[derive()]
363365
if let FnKind::Method(..) = fk {
364366
let parent = ir.tcx.hir.get_parent(id);
365-
if let Some(hir::map::NodeKind::Item(i)) = ir.tcx.hir.find(parent) {
367+
if let Some(NodeKind::Item(i)) = ir.tcx.hir.find(parent) {
366368
if i.attrs.iter().any(|a| a.check_name("automatically_derived")) {
367369
return;
368370
}

src/librustc/middle/mem_categorization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use self::Aliasability::*;
7070

7171
use middle::region;
7272
use hir::def_id::{DefId, LocalDefId};
73-
use hir::map as hir_map;
73+
use hir::map::NodeKind;
7474
use infer::InferCtxt;
7575
use hir::def::{Def, CtorKind};
7676
use ty::adjustment;
@@ -343,7 +343,7 @@ impl MutabilityCategory {
343343

344344
fn from_local(tcx: TyCtxt, tables: &ty::TypeckTables, id: ast::NodeId) -> MutabilityCategory {
345345
let ret = match tcx.hir.get(id) {
346-
hir_map::NodeKind::Binding(p) => match p.node {
346+
NodeKind::Binding(p) => match p.node {
347347
PatKind::Binding(..) => {
348348
let bm = *tables.pat_binding_modes()
349349
.get(p.hir_id)

src/librustc/middle/reachable.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// reachable as well.
1717

1818
use hir::{CodegenFnAttrs, CodegenFnAttrFlags};
19-
use hir::map as hir_map;
19+
use hir::map::NodeKind;
2020
use hir::def::Def;
2121
use hir::def_id::{DefId, CrateNum};
2222
use rustc_data_structures::sync::Lrc;
@@ -64,7 +64,7 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
6464
}
6565
if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) {
6666
match tcx.hir.find(impl_node_id) {
67-
Some(hir_map::NodeKind::Item(item)) =>
67+
Some(NodeKind::Item(item)) =>
6868
item_might_be_inlined(tcx, &item, codegen_fn_attrs),
6969
Some(..) | None =>
7070
span_bug!(impl_item.span, "impl did is not an item")
@@ -156,22 +156,22 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
156156
};
157157

158158
match self.tcx.hir.find(node_id) {
159-
Some(hir_map::NodeKind::Item(item)) => {
159+
Some(NodeKind::Item(item)) => {
160160
match item.node {
161161
hir::ItemKind::Fn(..) =>
162162
item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)),
163163
_ => false,
164164
}
165165
}
166-
Some(hir_map::NodeKind::TraitItem(trait_method)) => {
166+
Some(NodeKind::TraitItem(trait_method)) => {
167167
match trait_method.node {
168168
hir::TraitItemKind::Const(_, ref default) => default.is_some(),
169169
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
170170
hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) |
171171
hir::TraitItemKind::Type(..) => false,
172172
}
173173
}
174-
Some(hir_map::NodeKind::ImplItem(impl_item)) => {
174+
Some(NodeKind::ImplItem(impl_item)) => {
175175
match impl_item.node {
176176
hir::ImplItemKind::Const(..) => true,
177177
hir::ImplItemKind::Method(..) => {
@@ -219,12 +219,12 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
219219
}
220220
}
221221

222-
fn propagate_node(&mut self, node: &hir_map::NodeKind<'tcx>,
222+
fn propagate_node(&mut self, node: &NodeKind<'tcx>,
223223
search_item: ast::NodeId) {
224224
if !self.any_library {
225225
// If we are building an executable, only explicitly extern
226226
// types need to be exported.
227-
if let hir_map::NodeKind::Item(item) = *node {
227+
if let NodeKind::Item(item) = *node {
228228
let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.node {
229229
header.abi != Abi::Rust
230230
} else {
@@ -248,7 +248,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
248248
}
249249

250250
match *node {
251-
hir_map::NodeKind::Item(item) => {
251+
NodeKind::Item(item) => {
252252
match item.node {
253253
hir::ItemKind::Fn(.., body) => {
254254
let def_id = self.tcx.hir.local_def_id(item.id);
@@ -285,7 +285,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
285285
hir::ItemKind::GlobalAsm(..) => {}
286286
}
287287
}
288-
hir_map::NodeKind::TraitItem(trait_method) => {
288+
NodeKind::TraitItem(trait_method) => {
289289
match trait_method.node {
290290
hir::TraitItemKind::Const(_, None) |
291291
hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => {
@@ -298,7 +298,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
298298
hir::TraitItemKind::Type(..) => {}
299299
}
300300
}
301-
hir_map::NodeKind::ImplItem(impl_item) => {
301+
NodeKind::ImplItem(impl_item) => {
302302
match impl_item.node {
303303
hir::ImplItemKind::Const(_, body) => {
304304
self.visit_nested_body(body);
@@ -313,16 +313,16 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
313313
hir::ImplItemKind::Type(_) => {}
314314
}
315315
}
316-
hir_map::NodeKind::Expr(&hir::Expr { node: hir::ExprKind::Closure(.., body, _, _), .. }) => {
316+
NodeKind::Expr(&hir::Expr { node: hir::ExprKind::Closure(.., body, _, _), .. }) => {
317317
self.visit_nested_body(body);
318318
}
319319
// Nothing to recurse on for these
320-
hir_map::NodeKind::ForeignItem(_) |
321-
hir_map::NodeKind::Variant(_) |
322-
hir_map::NodeKind::StructCtor(_) |
323-
hir_map::NodeKind::Field(_) |
324-
hir_map::NodeKind::Ty(_) |
325-
hir_map::NodeKind::MacroDef(_) => {}
320+
NodeKind::ForeignItem(_) |
321+
NodeKind::Variant(_) |
322+
NodeKind::StructCtor(_) |
323+
NodeKind::Field(_) |
324+
NodeKind::Ty(_) |
325+
NodeKind::MacroDef(_) => {}
326326
_ => {
327327
bug!("found unexpected thingy in worklist: {}",
328328
self.tcx.hir.node_to_string(search_item))

src/librustc/middle/region.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use ty::TyCtxt;
3030
use ty::query::Providers;
3131

3232
use hir;
33+
use hir::map::NodeKind;
3334
use hir::def_id::DefId;
3435
use hir::intravisit::{self, Visitor, NestedVisitorMap};
3536
use hir::{Block, Arm, Pat, PatKind, Stmt, Expr, Local};
@@ -257,7 +258,7 @@ impl Scope {
257258
}
258259
let span = tcx.hir.span(node_id);
259260
if let ScopeData::Remainder(r) = self.data() {
260-
if let hir::map::NodeKind::Block(ref blk) = tcx.hir.get(node_id) {
261+
if let NodeKind::Block(ref blk) = tcx.hir.get(node_id) {
261262
// Want span for scope starting after the
262263
// indexed statement and ending at end of
263264
// `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)
14201421
// record its impl/trait parent, as it can also have
14211422
// lifetime parameters free in this body.
14221423
match tcx.hir.get(id) {
1423-
hir::map::NodeKind::ImplItem(_) |
1424-
hir::map::NodeKind::TraitItem(_) => {
1424+
NodeKind::ImplItem(_) |
1425+
NodeKind::TraitItem(_) => {
14251426
visitor.scope_tree.root_parent = Some(tcx.hir.get_parent(id));
14261427
}
14271428
_ => {}

0 commit comments

Comments
 (0)