Skip to content

Commit 7bc94cc

Browse files
committed
Rename Item.node to Item.kind
1 parent 21bf983 commit 7bc94cc

File tree

99 files changed

+279
-278
lines changed

Some content is hidden

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

99 files changed

+279
-278
lines changed

src/librustc/hir/check_attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Display for Target {
6565

6666
impl Target {
6767
pub(crate) fn from_item(item: &hir::Item) -> Target {
68-
match item.node {
68+
match item.kind {
6969
hir::ItemKind::ExternCrate(..) => Target::ExternCrate,
7070
hir::ItemKind::Use(..) => Target::Use,
7171
hir::ItemKind::Static(..) => Target::Static,
@@ -333,7 +333,7 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
333333
}
334334

335335
fn is_c_like_enum(item: &hir::Item) -> bool {
336-
if let hir::ItemKind::Enum(ref def, _) = item.node {
336+
if let hir::ItemKind::Enum(ref def, _) = item.kind {
337337
for variant in &def.variants {
338338
match variant.data {
339339
hir::VariantData::Unit(..) => { /* continue */ }

src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param) {
465465
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
466466
visitor.visit_vis(&item.vis);
467467
visitor.visit_ident(item.ident);
468-
match item.node {
468+
match item.kind {
469469
ItemKind::ExternCrate(orig_name) => {
470470
visitor.visit_id(item.hir_id);
471471
if let Some(orig_name) = orig_name {

src/librustc/hir/lowering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ impl<'a> LoweringContext<'a> {
437437
fn visit_item(&mut self, item: &'tcx Item) {
438438
let hir_id = self.lctx.allocate_hir_id_counter(item.id);
439439

440-
match item.node {
440+
match item.kind {
441441
ItemKind::Struct(_, ref generics)
442442
| ItemKind::Union(_, ref generics)
443443
| ItemKind::Enum(_, ref generics)
@@ -1445,7 +1445,7 @@ impl<'a> LoweringContext<'a> {
14451445
hir_id: opaque_ty_id,
14461446
ident: Ident::invalid(),
14471447
attrs: Default::default(),
1448-
node: opaque_ty_item_kind,
1448+
kind: opaque_ty_item_kind,
14491449
vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited),
14501450
span: opaque_ty_span,
14511451
};

src/librustc/hir/lowering/item.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<'tcx, 'interner> Visitor<'tcx> for ItemLowerer<'tcx, 'interner> {
7373
if let Some(hir_id) = item_hir_id {
7474
self.lctx.with_parent_item_lifetime_defs(hir_id, |this| {
7575
let this = &mut ItemLowerer { lctx: this };
76-
if let ItemKind::Impl(.., ref opt_trait_ref, _, _) = item.node {
76+
if let ItemKind::Impl(.., ref opt_trait_ref, _, _) = item.kind {
7777
this.with_trait_impl_ref(opt_trait_ref, |this| {
7878
visit::walk_item(this, item)
7979
});
@@ -119,7 +119,7 @@ impl LoweringContext<'_> {
119119
) -> T {
120120
let old_len = self.in_scope_lifetimes.len();
121121

122-
let parent_generics = match self.items.get(&parent_hir_id).unwrap().node {
122+
let parent_generics = match self.items.get(&parent_hir_id).unwrap().kind {
123123
hir::ItemKind::Impl(_, _, _, ref generics, ..)
124124
| hir::ItemKind::Trait(_, _, ref generics, ..) => {
125125
&generics.params[..]
@@ -168,7 +168,7 @@ impl LoweringContext<'_> {
168168
}
169169

170170
pub(super) fn lower_item_id(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> {
171-
let node_ids = match i.node {
171+
let node_ids = match i.kind {
172172
ItemKind::Use(ref use_tree) => {
173173
let mut vec = smallvec![i.id];
174174
self.lower_item_id_use_tree(use_tree, i.id, &mut vec);
@@ -235,7 +235,7 @@ impl LoweringContext<'_> {
235235
}
236236
let attrs = attrs.into();
237237

238-
if let ItemKind::MacroDef(ref def) = i.node {
238+
if let ItemKind::MacroDef(ref def) = i.kind {
239239
if !def.legacy || attr::contains_name(&i.attrs, sym::macro_export) {
240240
let body = self.lower_token_stream(def.stream());
241241
let hir_id = self.lower_node_id(i.id);
@@ -254,13 +254,13 @@ impl LoweringContext<'_> {
254254
return None;
255255
}
256256

257-
let node = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.node);
257+
let kind = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.kind);
258258

259259
Some(hir::Item {
260260
hir_id: self.lower_node_id(i.id),
261261
ident,
262262
attrs,
263-
node,
263+
kind,
264264
vis,
265265
span: i.span,
266266
})
@@ -542,24 +542,23 @@ impl LoweringContext<'_> {
542542
let res = this.lower_res(res);
543543
let path =
544544
this.lower_path_extra(res, &path, ParamMode::Explicit, None);
545-
let item = hir::ItemKind::Use(P(path), hir::UseKind::Single);
545+
let kind = hir::ItemKind::Use(P(path), hir::UseKind::Single);
546546
let vis = this.rebuild_vis(&vis);
547547

548548
this.insert_item(
549549
hir::Item {
550550
hir_id: new_id,
551551
ident,
552552
attrs: attrs.into_iter().cloned().collect(),
553-
node: item,
553+
kind,
554554
vis,
555555
span,
556556
},
557557
);
558558
});
559559
}
560560

561-
let path =
562-
P(self.lower_path_extra(ret_res, &path, ParamMode::Explicit, None));
561+
let path = P(self.lower_path_extra(ret_res, &path, ParamMode::Explicit, None));
563562
hir::ItemKind::Use(path, hir::UseKind::Single)
564563
}
565564
UseTreeKind::Glob => {
@@ -623,7 +622,7 @@ impl LoweringContext<'_> {
623622
let mut vis = this.rebuild_vis(&vis);
624623
let mut ident = *ident;
625624

626-
let item = this.lower_use_tree(use_tree,
625+
let kind = this.lower_use_tree(use_tree,
627626
&prefix,
628627
id,
629628
&mut vis,
@@ -635,7 +634,7 @@ impl LoweringContext<'_> {
635634
hir_id: new_hir_id,
636635
ident,
637636
attrs: attrs.into_iter().cloned().collect(),
638-
node: item,
637+
kind,
639638
vis,
640639
span: use_tree.span,
641640
},

src/librustc/hir/map/blocks.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ trait MaybeFnLike { fn is_fn_like(&self) -> bool; }
3737

3838
impl MaybeFnLike for ast::Item {
3939
fn is_fn_like(&self) -> bool {
40-
match self.node { ast::ItemKind::Fn(..) => true, _ => false, }
40+
match self.kind {
41+
ast::ItemKind::Fn(..) => true,
42+
_ => false,
43+
}
4144
}
4245
}
4346

@@ -215,7 +218,7 @@ impl<'a> FnLikeNode<'a> {
215218
C: FnOnce(ClosureParts<'a>) -> A,
216219
{
217220
match self.node {
218-
map::Node::Item(i) => match i.node {
221+
map::Node::Item(i) => match i.kind {
219222
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
220223
item_fn(ItemFnParts {
221224
id: i.hir_id,

src/librustc/hir/map/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
378378
self.with_dep_node_owner(i.hir_id.owner, i, |this| {
379379
this.insert(i.span, i.hir_id, Node::Item(i));
380380
this.with_parent(i.hir_id, |this| {
381-
if let ItemKind::Struct(ref struct_def, _) = i.node {
381+
if let ItemKind::Struct(ref struct_def, _) = i.kind {
382382
// If this is a tuple or unit-like struct, register the constructor.
383383
if let Some(ctor_hir_id) = struct_def.ctor_hir_id() {
384384
this.insert(i.span, ctor_hir_id, Node::Ctor(struct_def));

src/librustc/hir/map/def_collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
101101

102102
// Pick the def data. This need not be unique, but the more
103103
// information we encapsulate into, the better
104-
let def_data = match i.node {
104+
let def_data = match i.kind {
105105
ItemKind::Impl(..) => DefPathData::Impl,
106106
ItemKind::Mod(..) if i.ident.name == kw::Invalid => {
107107
return visit::walk_item(self, i);
@@ -138,7 +138,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
138138
let def = self.create_def(i.id, def_data, i.span);
139139

140140
self.with_parent(def, |this| {
141-
match i.node {
141+
match i.kind {
142142
ItemKind::Struct(ref struct_def, _) | ItemKind::Union(ref struct_def, _) => {
143143
// If this is a unit or tuple-like struct, register the constructor.
144144
if let Some(ctor_hir_id) = struct_def.ctor_id() {

src/librustc/hir/map/mod.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'hir> Entry<'hir> {
5050
fn fn_decl(&self) -> Option<&'hir FnDecl> {
5151
match self.node {
5252
Node::Item(ref item) => {
53-
match item.node {
53+
match item.kind {
5454
ItemKind::Fn(ref fn_decl, _, _, _) => Some(fn_decl),
5555
_ => None,
5656
}
@@ -84,7 +84,7 @@ impl<'hir> Entry<'hir> {
8484
fn associated_body(self) -> Option<BodyId> {
8585
match self.node {
8686
Node::Item(item) => {
87-
match item.node {
87+
match item.kind {
8888
ItemKind::Const(_, body) |
8989
ItemKind::Static(.., body) |
9090
ItemKind::Fn(_, _, _, body) => Some(body),
@@ -293,7 +293,7 @@ impl<'hir> Map<'hir> {
293293

294294
Some(match node {
295295
Node::Item(item) => {
296-
match item.node {
296+
match item.kind {
297297
ItemKind::Static(..) => DefKind::Static,
298298
ItemKind::Const(..) => DefKind::Const,
299299
ItemKind::Fn(..) => DefKind::Fn,
@@ -453,19 +453,19 @@ impl<'hir> Map<'hir> {
453453

454454
pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind {
455455
match self.get(id) {
456-
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
456+
Node::Item(&Item { kind: ItemKind::Const(..), .. }) |
457457
Node::TraitItem(&TraitItem { kind: TraitItemKind::Const(..), .. }) |
458458
Node::ImplItem(&ImplItem { kind: ImplItemKind::Const(..), .. }) |
459459
Node::AnonConst(_) => {
460460
BodyOwnerKind::Const
461461
}
462462
Node::Ctor(..) |
463-
Node::Item(&Item { node: ItemKind::Fn(..), .. }) |
463+
Node::Item(&Item { kind: ItemKind::Fn(..), .. }) |
464464
Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. }) |
465465
Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => {
466466
BodyOwnerKind::Fn
467467
}
468-
Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => {
468+
Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => {
469469
BodyOwnerKind::Static(m)
470470
}
471471
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => {
@@ -477,17 +477,17 @@ impl<'hir> Map<'hir> {
477477

478478
pub fn ty_param_owner(&self, id: HirId) -> HirId {
479479
match self.get(id) {
480-
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
481-
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id,
480+
Node::Item(&Item { kind: ItemKind::Trait(..), .. }) |
481+
Node::Item(&Item { kind: ItemKind::TraitAlias(..), .. }) => id,
482482
Node::GenericParam(_) => self.get_parent_node(id),
483483
_ => bug!("ty_param_owner: {} not a type parameter", self.node_to_string(id))
484484
}
485485
}
486486

487487
pub fn ty_param_name(&self, id: HirId) -> Name {
488488
match self.get(id) {
489-
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
490-
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
489+
Node::Item(&Item { kind: ItemKind::Trait(..), .. }) |
490+
Node::Item(&Item { kind: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
491491
Node::GenericParam(param) => param.name.ident().name,
492492
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
493493
}
@@ -517,7 +517,7 @@ impl<'hir> Map<'hir> {
517517
match self.find_entry(hir_id).unwrap().node {
518518
Node::Item(&Item {
519519
span,
520-
node: ItemKind::Mod(ref m),
520+
kind: ItemKind::Mod(ref m),
521521
..
522522
}) => (m, span, hir_id),
523523
Node::Crate => (&self.forest.krate.module, self.forest.krate.span, hir_id),
@@ -568,7 +568,7 @@ impl<'hir> Map<'hir> {
568568
Node::ImplItem(ref impl_item) => Some(&impl_item.generics),
569569
Node::TraitItem(ref trait_item) => Some(&trait_item.generics),
570570
Node::Item(ref item) => {
571-
match item.node {
571+
match item.kind {
572572
ItemKind::Fn(_, _, ref generics, _) |
573573
ItemKind::TyAlias(_, ref generics) |
574574
ItemKind::Enum(_, ref generics) |
@@ -649,7 +649,7 @@ impl<'hir> Map<'hir> {
649649
let parent_id = self.get_parent_item(hir_id);
650650
match self.get(parent_id) {
651651
Node::Item(&Item {
652-
node: ItemKind::Const(..),
652+
kind: ItemKind::Const(..),
653653
..
654654
})
655655
| Node::TraitItem(&TraitItem {
@@ -662,11 +662,11 @@ impl<'hir> Map<'hir> {
662662
})
663663
| Node::AnonConst(_)
664664
| Node::Item(&Item {
665-
node: ItemKind::Static(..),
665+
kind: ItemKind::Static(..),
666666
..
667667
}) => true,
668668
Node::Item(&Item {
669-
node: ItemKind::Fn(_, header, ..),
669+
kind: ItemKind::Fn(_, header, ..),
670670
..
671671
}) => header.constness == Constness::Const,
672672
_ => false,
@@ -676,7 +676,7 @@ impl<'hir> Map<'hir> {
676676
/// Wether `hir_id` corresponds to a `mod` or a crate.
677677
pub fn is_hir_id_module(&self, hir_id: HirId) -> bool {
678678
match self.lookup(hir_id) {
679-
Some(Entry { node: Node::Item(Item { node: ItemKind::Mod(_), .. }), .. }) |
679+
Some(Entry { node: Node::Item(Item { kind: ItemKind::Mod(_), .. }), .. }) |
680680
Some(Entry { node: Node::Crate, .. }) => true,
681681
_ => false,
682682
}
@@ -796,7 +796,7 @@ impl<'hir> Map<'hir> {
796796
/// module parent is in this map.
797797
pub fn get_module_parent_node(&self, hir_id: HirId) -> HirId {
798798
match self.walk_parent_nodes(hir_id, |node| match *node {
799-
Node::Item(&Item { node: ItemKind::Mod(_), .. }) => true,
799+
Node::Item(&Item { kind: ItemKind::Mod(_), .. }) => true,
800800
_ => false,
801801
}, |_| false) {
802802
Ok(id) => id,
@@ -808,7 +808,7 @@ impl<'hir> Map<'hir> {
808808
pub fn get_enclosing_scope(&self, hir_id: HirId) -> Option<HirId> {
809809
self.walk_parent_nodes(hir_id, |node| match *node {
810810
Node::Item(i) => {
811-
match i.node {
811+
match i.kind {
812812
ItemKind::Fn(..)
813813
| ItemKind::Mod(..)
814814
| ItemKind::Enum(..)
@@ -852,7 +852,7 @@ impl<'hir> Map<'hir> {
852852
}
853853
match self.get(scope) {
854854
Node::Item(i) => {
855-
match i.node {
855+
match i.kind {
856856
ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: None, .. }) => {}
857857
_ => break,
858858
}
@@ -872,7 +872,7 @@ impl<'hir> Map<'hir> {
872872
let parent = self.get_parent_item(hir_id);
873873
if let Some(entry) = self.find_entry(parent) {
874874
if let Entry {
875-
node: Node::Item(Item { node: ItemKind::ForeignMod(ref nm), .. }), .. } = entry
875+
node: Node::Item(Item { kind: ItemKind::ForeignMod(ref nm), .. }), .. } = entry
876876
{
877877
self.read(hir_id); // reveals some of the content of a node
878878
return nm.abi;
@@ -905,7 +905,7 @@ impl<'hir> Map<'hir> {
905905
pub fn expect_variant_data(&self, id: HirId) -> &'hir VariantData {
906906
match self.find(id) {
907907
Some(Node::Item(i)) => {
908-
match i.node {
908+
match i.kind {
909909
ItemKind::Struct(ref struct_def, _) |
910910
ItemKind::Union(ref struct_def, _) => struct_def,
911911
_ => bug!("struct ID bound to non-struct {}", self.node_to_string(id))
@@ -1123,7 +1123,7 @@ impl<'a> NodesMatchingSuffix<'a> {
11231123
}
11241124

11251125
fn item_is_mod(item: &Item) -> bool {
1126-
match item.node {
1126+
match item.kind {
11271127
ItemKind::Mod(_) => true,
11281128
_ => false,
11291129
}
@@ -1286,7 +1286,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
12861286

12871287
match map.find(id) {
12881288
Some(Node::Item(item)) => {
1289-
let item_str = match item.node {
1289+
let item_str = match item.kind {
12901290
ItemKind::ExternCrate(..) => "extern crate",
12911291
ItemKind::Use(..) => "use",
12921292
ItemKind::Static(..) => "static",

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2416,7 +2416,7 @@ pub struct Item {
24162416
pub ident: Ident,
24172417
pub hir_id: HirId,
24182418
pub attrs: HirVec<Attribute>,
2419-
pub node: ItemKind,
2419+
pub kind: ItemKind,
24202420
pub vis: Visibility,
24212421
pub span: Span,
24222422
}

src/librustc/hir/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl<'a> State<'a> {
474474
self.maybe_print_comment(item.span.lo());
475475
self.print_outer_attributes(&item.attrs);
476476
self.ann.pre(self, AnnNode::Item(item));
477-
match item.node {
477+
match item.kind {
478478
hir::ItemKind::ExternCrate(orig_name) => {
479479
self.head(visibility_qualified(&item.vis, "extern crate"));
480480
if let Some(orig_name) = orig_name {

0 commit comments

Comments
 (0)