Skip to content

Commit e2a1cce

Browse files
committed
Rename hir::map::NodeKind to hir::Node
1 parent ecbdfb4 commit e2a1cce

File tree

48 files changed

+500
-507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+500
-507
lines changed

src/librustc/hir/map/blocks.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
//! for the `Code` associated with a particular NodeId.
2323
2424
use hir as ast;
25-
use hir::map::{self, NodeKind};
26-
use hir::{Expr, FnDecl};
25+
use hir::map;
26+
use hir::{Expr, FnDecl, Node};
2727
use hir::intravisit::FnKind;
2828
use syntax::ast::{Attribute, Ident, Name, NodeId};
2929
use syntax_pos::Span;
@@ -39,7 +39,7 @@ use syntax_pos::Span;
3939
///
4040
/// To construct one, use the `Code::from_node` function.
4141
#[derive(Copy, Clone, Debug)]
42-
pub struct FnLikeNode<'a> { node: NodeKind<'a> }
42+
pub struct FnLikeNode<'a> { node: Node<'a> }
4343

4444
/// MaybeFnLike wraps a method that indicates if an object
4545
/// corresponds to some FnLikeNode.
@@ -95,11 +95,11 @@ impl<'a> Code<'a> {
9595
/// Attempts to construct a Code from presumed FnLike or Expr node input.
9696
pub fn from_node(map: &map::Map<'a>, id: NodeId) -> Option<Code<'a>> {
9797
match map.get(id) {
98-
map::NodeKind::Block(_) => {
98+
map::Node::Block(_) => {
9999
// Use the parent, hopefully an expression node.
100100
Code::from_node(map, map.get_parent_node(id))
101101
}
102-
map::NodeKind::Expr(expr) => Some(Code::Expr(expr)),
102+
map::Node::Expr(expr) => Some(Code::Expr(expr)),
103103
node => FnLikeNode::from_node(node).map(Code::FnLike)
104104
}
105105
}
@@ -143,12 +143,12 @@ impl<'a> ClosureParts<'a> {
143143

144144
impl<'a> FnLikeNode<'a> {
145145
/// Attempts to construct a FnLikeNode from presumed FnLike node input.
146-
pub fn from_node(node: NodeKind) -> Option<FnLikeNode> {
146+
pub fn from_node(node: Node) -> Option<FnLikeNode> {
147147
let fn_like = match node {
148-
map::NodeKind::Item(item) => item.is_fn_like(),
149-
map::NodeKind::TraitItem(tm) => tm.is_fn_like(),
150-
map::NodeKind::ImplItem(it) => it.is_fn_like(),
151-
map::NodeKind::Expr(e) => e.is_fn_like(),
148+
map::Node::Item(item) => item.is_fn_like(),
149+
map::Node::TraitItem(tm) => tm.is_fn_like(),
150+
map::Node::ImplItem(it) => it.is_fn_like(),
151+
map::Node::Expr(e) => e.is_fn_like(),
152152
_ => false
153153
};
154154
if fn_like {
@@ -234,7 +234,7 @@ impl<'a> FnLikeNode<'a> {
234234
C: FnOnce(ClosureParts<'a>) -> A,
235235
{
236236
match self.node {
237-
map::NodeKind::Item(i) => match i.node {
237+
map::Node::Item(i) => match i.node {
238238
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
239239
item_fn(ItemFnParts {
240240
id: i.id,
@@ -249,13 +249,13 @@ impl<'a> FnLikeNode<'a> {
249249
}),
250250
_ => bug!("item FnLikeNode that is not fn-like"),
251251
},
252-
map::NodeKind::TraitItem(ti) => match ti.node {
252+
map::Node::TraitItem(ti) => match ti.node {
253253
ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => {
254254
method(ti.id, ti.ident, sig, None, body, ti.span, &ti.attrs)
255255
}
256256
_ => bug!("trait method FnLikeNode that is not fn-like"),
257257
},
258-
map::NodeKind::ImplItem(ii) => {
258+
map::Node::ImplItem(ii) => {
259259
match ii.node {
260260
ast::ImplItemKind::Method(ref sig, body) => {
261261
method(ii.id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
@@ -265,7 +265,7 @@ impl<'a> FnLikeNode<'a> {
265265
}
266266
}
267267
},
268-
map::NodeKind::Expr(e) => match e.node {
268+
map::Node::Expr(e) => match e.node {
269269
ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) =>
270270
closure(ClosureParts::new(&decl, block, e.id, e.span, &e.attrs)),
271271
_ => bug!("expr FnLikeNode that is not fn-like"),

src/librustc/hir/map/collector.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
117117
collector.insert_entry(CRATE_NODE_ID, Entry {
118118
parent: ast::DUMMY_NODE_ID,
119119
dep_node: root_mod_sig_dep_index,
120-
node: NodeKind::Crate,
120+
node: Node::Crate,
121121
});
122122

123123
collector
@@ -190,7 +190,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
190190
self.map[id.as_usize()] = Some(entry);
191191
}
192192

193-
fn insert(&mut self, id: NodeId, node: NodeKind<'hir>) {
193+
fn insert(&mut self, id: NodeId, node: Node<'hir>) {
194194
let entry = Entry {
195195
parent: self.parent_node,
196196
dep_node: if self.currently_in_body {
@@ -309,13 +309,13 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
309309
debug_assert_eq!(i.hir_id.owner,
310310
self.definitions.opt_def_index(i.id).unwrap());
311311
self.with_dep_node_owner(i.hir_id.owner, i, |this| {
312-
this.insert(i.id, NodeKind::Item(i));
312+
this.insert(i.id, Node::Item(i));
313313
this.with_parent(i.id, |this| {
314314
match i.node {
315315
ItemKind::Struct(ref struct_def, _) => {
316316
// If this is a tuple-like struct, register the constructor.
317317
if !struct_def.is_struct() {
318-
this.insert(struct_def.id(), NodeKind::StructCtor(struct_def));
318+
this.insert(struct_def.id(), Node::StructCtor(struct_def));
319319
}
320320
}
321321
_ => {}
@@ -326,23 +326,23 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
326326
}
327327

328328
fn visit_foreign_item(&mut self, foreign_item: &'hir ForeignItem) {
329-
self.insert(foreign_item.id, NodeKind::ForeignItem(foreign_item));
329+
self.insert(foreign_item.id, Node::ForeignItem(foreign_item));
330330

331331
self.with_parent(foreign_item.id, |this| {
332332
intravisit::walk_foreign_item(this, foreign_item);
333333
});
334334
}
335335

336336
fn visit_generic_param(&mut self, param: &'hir GenericParam) {
337-
self.insert(param.id, NodeKind::GenericParam(param));
337+
self.insert(param.id, Node::GenericParam(param));
338338
intravisit::walk_generic_param(self, param);
339339
}
340340

341341
fn visit_trait_item(&mut self, ti: &'hir TraitItem) {
342342
debug_assert_eq!(ti.hir_id.owner,
343343
self.definitions.opt_def_index(ti.id).unwrap());
344344
self.with_dep_node_owner(ti.hir_id.owner, ti, |this| {
345-
this.insert(ti.id, NodeKind::TraitItem(ti));
345+
this.insert(ti.id, Node::TraitItem(ti));
346346

347347
this.with_parent(ti.id, |this| {
348348
intravisit::walk_trait_item(this, ti);
@@ -354,7 +354,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
354354
debug_assert_eq!(ii.hir_id.owner,
355355
self.definitions.opt_def_index(ii.id).unwrap());
356356
self.with_dep_node_owner(ii.hir_id.owner, ii, |this| {
357-
this.insert(ii.id, NodeKind::ImplItem(ii));
357+
this.insert(ii.id, Node::ImplItem(ii));
358358

359359
this.with_parent(ii.id, |this| {
360360
intravisit::walk_impl_item(this, ii);
@@ -364,9 +364,9 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
364364

365365
fn visit_pat(&mut self, pat: &'hir Pat) {
366366
let node = if let PatKind::Binding(..) = pat.node {
367-
NodeKind::Binding(pat)
367+
Node::Binding(pat)
368368
} else {
369-
NodeKind::Pat(pat)
369+
Node::Pat(pat)
370370
};
371371
self.insert(pat.id, node);
372372

@@ -376,15 +376,15 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
376376
}
377377

378378
fn visit_anon_const(&mut self, constant: &'hir AnonConst) {
379-
self.insert(constant.id, NodeKind::AnonConst(constant));
379+
self.insert(constant.id, Node::AnonConst(constant));
380380

381381
self.with_parent(constant.id, |this| {
382382
intravisit::walk_anon_const(this, constant);
383383
});
384384
}
385385

386386
fn visit_expr(&mut self, expr: &'hir Expr) {
387-
self.insert(expr.id, NodeKind::Expr(expr));
387+
self.insert(expr.id, Node::Expr(expr));
388388

389389
self.with_parent(expr.id, |this| {
390390
intravisit::walk_expr(this, expr);
@@ -393,23 +393,23 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
393393

394394
fn visit_stmt(&mut self, stmt: &'hir Stmt) {
395395
let id = stmt.node.id();
396-
self.insert(id, NodeKind::Stmt(stmt));
396+
self.insert(id, Node::Stmt(stmt));
397397

398398
self.with_parent(id, |this| {
399399
intravisit::walk_stmt(this, stmt);
400400
});
401401
}
402402

403403
fn visit_ty(&mut self, ty: &'hir Ty) {
404-
self.insert(ty.id, NodeKind::Ty(ty));
404+
self.insert(ty.id, Node::Ty(ty));
405405

406406
self.with_parent(ty.id, |this| {
407407
intravisit::walk_ty(this, ty);
408408
});
409409
}
410410

411411
fn visit_trait_ref(&mut self, tr: &'hir TraitRef) {
412-
self.insert(tr.ref_id, NodeKind::TraitRef(tr));
412+
self.insert(tr.ref_id, Node::TraitRef(tr));
413413

414414
self.with_parent(tr.ref_id, |this| {
415415
intravisit::walk_trait_ref(this, tr);
@@ -423,21 +423,21 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
423423
}
424424

425425
fn visit_block(&mut self, block: &'hir Block) {
426-
self.insert(block.id, NodeKind::Block(block));
426+
self.insert(block.id, Node::Block(block));
427427
self.with_parent(block.id, |this| {
428428
intravisit::walk_block(this, block);
429429
});
430430
}
431431

432432
fn visit_local(&mut self, l: &'hir Local) {
433-
self.insert(l.id, NodeKind::Local(l));
433+
self.insert(l.id, Node::Local(l));
434434
self.with_parent(l.id, |this| {
435435
intravisit::walk_local(this, l)
436436
})
437437
}
438438

439439
fn visit_lifetime(&mut self, lifetime: &'hir Lifetime) {
440-
self.insert(lifetime.id, NodeKind::Lifetime(lifetime));
440+
self.insert(lifetime.id, Node::Lifetime(lifetime));
441441
}
442442

443443
fn visit_vis(&mut self, visibility: &'hir Visibility) {
@@ -446,7 +446,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
446446
VisibilityKind::Crate(_) |
447447
VisibilityKind::Inherited => {}
448448
VisibilityKind::Restricted { id, .. } => {
449-
self.insert(id, NodeKind::Visibility(visibility));
449+
self.insert(id, Node::Visibility(visibility));
450450
self.with_parent(id, |this| {
451451
intravisit::walk_vis(this, visibility);
452452
});
@@ -458,20 +458,20 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
458458
let def_index = self.definitions.opt_def_index(macro_def.id).unwrap();
459459

460460
self.with_dep_node_owner(def_index, macro_def, |this| {
461-
this.insert(macro_def.id, NodeKind::MacroDef(macro_def));
461+
this.insert(macro_def.id, Node::MacroDef(macro_def));
462462
});
463463
}
464464

465465
fn visit_variant(&mut self, v: &'hir Variant, g: &'hir Generics, item_id: NodeId) {
466466
let id = v.node.data.id();
467-
self.insert(id, NodeKind::Variant(v));
467+
self.insert(id, Node::Variant(v));
468468
self.with_parent(id, |this| {
469469
intravisit::walk_variant(this, v, g, item_id);
470470
});
471471
}
472472

473473
fn visit_struct_field(&mut self, field: &'hir StructField) {
474-
self.insert(field.id, NodeKind::Field(field));
474+
self.insert(field.id, Node::Field(field));
475475
self.with_parent(field.id, |this| {
476476
intravisit::walk_struct_field(this, field);
477477
});

0 commit comments

Comments
 (0)