Skip to content

Commit 5b0cf56

Browse files
csmoeoli-obk
authored andcommitted
ItemKind
1 parent 7e5d224 commit 5b0cf56

Some content is hidden

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

61 files changed

+696
-696
lines changed

src/librustc/hir/check_attr.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ enum Target {
3838
impl Target {
3939
fn from_item(item: &hir::Item) -> Target {
4040
match item.node {
41-
hir::ItemFn(..) => Target::Fn,
42-
hir::ItemStruct(..) => Target::Struct,
43-
hir::ItemUnion(..) => Target::Union,
44-
hir::ItemEnum(..) => Target::Enum,
45-
hir::ItemConst(..) => Target::Const,
46-
hir::ItemForeignMod(..) => Target::ForeignMod,
47-
hir::ItemStatic(..) => Target::Static,
41+
hir::ItemKind::Fn(..) => Target::Fn,
42+
hir::ItemKind::Struct(..) => Target::Struct,
43+
hir::ItemKind::Union(..) => Target::Union,
44+
hir::ItemKind::Enum(..) => Target::Enum,
45+
hir::ItemKind::Const(..) => Target::Const,
46+
hir::ItemKind::ForeignMod(..) => Target::ForeignMod,
47+
hir::ItemKind::Static(..) => Target::Static,
4848
_ => Target::Other,
4949
}
5050
}
@@ -340,7 +340,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
340340
}
341341

342342
fn is_c_like_enum(item: &hir::Item) -> bool {
343-
if let hir::ItemEnum(ref def, _) = item.node {
343+
if let hir::ItemKind::Enum(ref def, _) = item.node {
344344
for variant in &def.variants {
345345
match variant.node.data {
346346
hir::VariantData::Unit(_) => { /* continue */ }

src/librustc/hir/intravisit.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -463,23 +463,23 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
463463
visitor.visit_vis(&item.vis);
464464
visitor.visit_name(item.span, item.name);
465465
match item.node {
466-
ItemExternCrate(orig_name) => {
466+
ItemKind::ExternCrate(orig_name) => {
467467
visitor.visit_id(item.id);
468468
if let Some(orig_name) = orig_name {
469469
visitor.visit_name(item.span, orig_name);
470470
}
471471
}
472-
ItemUse(ref path, _) => {
472+
ItemKind::Use(ref path, _) => {
473473
visitor.visit_id(item.id);
474474
visitor.visit_path(path, item.id);
475475
}
476-
ItemStatic(ref typ, _, body) |
477-
ItemConst(ref typ, body) => {
476+
ItemKind::Static(ref typ, _, body) |
477+
ItemKind::Const(ref typ, body) => {
478478
visitor.visit_id(item.id);
479479
visitor.visit_ty(typ);
480480
visitor.visit_nested_body(body);
481481
}
482-
ItemFn(ref declaration, header, ref generics, body_id) => {
482+
ItemKind::Fn(ref declaration, header, ref generics, body_id) => {
483483
visitor.visit_fn(FnKind::ItemFn(item.name,
484484
generics,
485485
header,
@@ -490,55 +490,55 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
490490
item.span,
491491
item.id)
492492
}
493-
ItemMod(ref module) => {
493+
ItemKind::Mod(ref module) => {
494494
// visit_mod() takes care of visiting the Item's NodeId
495495
visitor.visit_mod(module, item.span, item.id)
496496
}
497-
ItemForeignMod(ref foreign_module) => {
497+
ItemKind::ForeignMod(ref foreign_module) => {
498498
visitor.visit_id(item.id);
499499
walk_list!(visitor, visit_foreign_item, &foreign_module.items);
500500
}
501-
ItemGlobalAsm(_) => {
501+
ItemKind::GlobalAsm(_) => {
502502
visitor.visit_id(item.id);
503503
}
504-
ItemTy(ref typ, ref type_parameters) => {
504+
ItemKind::Ty(ref typ, ref type_parameters) => {
505505
visitor.visit_id(item.id);
506506
visitor.visit_ty(typ);
507507
visitor.visit_generics(type_parameters)
508508
}
509-
ItemExistential(ExistTy {ref generics, ref bounds, impl_trait_fn}) => {
509+
ItemKind::Existential(ExistTy {ref generics, ref bounds, impl_trait_fn}) => {
510510
visitor.visit_id(item.id);
511511
walk_generics(visitor, generics);
512512
walk_list!(visitor, visit_param_bound, bounds);
513513
if let Some(impl_trait_fn) = impl_trait_fn {
514514
visitor.visit_def_mention(Def::Fn(impl_trait_fn))
515515
}
516516
}
517-
ItemEnum(ref enum_definition, ref type_parameters) => {
517+
ItemKind::Enum(ref enum_definition, ref type_parameters) => {
518518
visitor.visit_generics(type_parameters);
519519
// visit_enum_def() takes care of visiting the Item's NodeId
520520
visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span)
521521
}
522-
ItemImpl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_item_refs) => {
522+
ItemKind::Impl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_item_refs) => {
523523
visitor.visit_id(item.id);
524524
visitor.visit_generics(type_parameters);
525525
walk_list!(visitor, visit_trait_ref, opt_trait_reference);
526526
visitor.visit_ty(typ);
527527
walk_list!(visitor, visit_impl_item_ref, impl_item_refs);
528528
}
529-
ItemStruct(ref struct_definition, ref generics) |
530-
ItemUnion(ref struct_definition, ref generics) => {
529+
ItemKind::Struct(ref struct_definition, ref generics) |
530+
ItemKind::Union(ref struct_definition, ref generics) => {
531531
visitor.visit_generics(generics);
532532
visitor.visit_id(item.id);
533533
visitor.visit_variant_data(struct_definition, item.name, generics, item.id, item.span);
534534
}
535-
ItemTrait(.., ref generics, ref bounds, ref trait_item_refs) => {
535+
ItemKind::Trait(.., ref generics, ref bounds, ref trait_item_refs) => {
536536
visitor.visit_id(item.id);
537537
visitor.visit_generics(generics);
538538
walk_list!(visitor, visit_param_bound, bounds);
539539
walk_list!(visitor, visit_trait_item_ref, trait_item_refs);
540540
}
541-
ItemTraitAlias(ref generics, ref bounds) => {
541+
ItemKind::TraitAlias(ref generics, ref bounds) => {
542542
visitor.visit_id(item.id);
543543
visitor.visit_generics(generics);
544544
walk_list!(visitor, visit_param_bound, bounds);

src/librustc/hir/lowering.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ impl<'a> LoweringContext<'a> {
384384

385385
if item_lowered {
386386
let item_generics = match self.lctx.items.get(&item.id).unwrap().node {
387-
hir::Item_::ItemImpl(_, _, _, ref generics, ..)
388-
| hir::Item_::ItemTrait(_, _, ref generics, ..) => {
387+
hir::ItemKind::Impl(_, _, _, ref generics, ..)
388+
| hir::ItemKind::Trait(_, _, ref generics, ..) => {
389389
generics.params.clone()
390390
}
391391
_ => HirVec::new(),
@@ -1274,7 +1274,7 @@ impl<'a> LoweringContext<'a> {
12741274
);
12751275

12761276
self.with_hir_id_owner(exist_ty_node_id, |lctx| {
1277-
let exist_ty_item_kind = hir::ItemExistential(hir::ExistTy {
1277+
let exist_ty_item_kind = hir::ItemKind::Existential(hir::ExistTy {
12781278
generics: hir::Generics {
12791279
params: lifetime_defs,
12801280
where_clause: hir::WhereClause {
@@ -2575,9 +2575,9 @@ impl<'a> LoweringContext<'a> {
25752575
attrs: &hir::HirVec<Attribute>,
25762576
vis: &mut hir::Visibility,
25772577
i: &ItemKind,
2578-
) -> hir::Item_ {
2578+
) -> hir::ItemKind {
25792579
match *i {
2580-
ItemKind::ExternCrate(orig_name) => hir::ItemExternCrate(orig_name),
2580+
ItemKind::ExternCrate(orig_name) => hir::ItemKind::ExternCrate(orig_name),
25812581
ItemKind::Use(ref use_tree) => {
25822582
// Start with an empty prefix
25832583
let prefix = Path {
@@ -2589,15 +2589,15 @@ impl<'a> LoweringContext<'a> {
25892589
}
25902590
ItemKind::Static(ref t, m, ref e) => {
25912591
let value = self.lower_body(None, |this| this.lower_expr(e));
2592-
hir::ItemStatic(
2592+
hir::ItemKind::Static(
25932593
self.lower_ty(t, ImplTraitContext::Disallowed),
25942594
self.lower_mutability(m),
25952595
value,
25962596
)
25972597
}
25982598
ItemKind::Const(ref t, ref e) => {
25992599
let value = self.lower_body(None, |this| this.lower_expr(e));
2600-
hir::ItemConst(self.lower_ty(t, ImplTraitContext::Disallowed), value)
2600+
hir::ItemKind::Const(self.lower_ty(t, ImplTraitContext::Disallowed), value)
26012601
}
26022602
ItemKind::Fn(ref decl, header, ref generics, ref body) => {
26032603
let fn_def_id = self.resolver.definitions().local_def_id(id);
@@ -2617,22 +2617,22 @@ impl<'a> LoweringContext<'a> {
26172617
decl, Some((fn_def_id, idty)), true, header.asyncness.opt_return_id()),
26182618
);
26192619

2620-
hir::ItemFn(
2620+
hir::ItemKind::Fn(
26212621
fn_decl,
26222622
this.lower_fn_header(header),
26232623
generics,
26242624
body_id,
26252625
)
26262626
})
26272627
}
2628-
ItemKind::Mod(ref m) => hir::ItemMod(self.lower_mod(m)),
2629-
ItemKind::ForeignMod(ref nm) => hir::ItemForeignMod(self.lower_foreign_mod(nm)),
2630-
ItemKind::GlobalAsm(ref ga) => hir::ItemGlobalAsm(self.lower_global_asm(ga)),
2631-
ItemKind::Ty(ref t, ref generics) => hir::ItemTy(
2628+
ItemKind::Mod(ref m) => hir::ItemKind::Mod(self.lower_mod(m)),
2629+
ItemKind::ForeignMod(ref nm) => hir::ItemKind::ForeignMod(self.lower_foreign_mod(nm)),
2630+
ItemKind::GlobalAsm(ref ga) => hir::ItemKind::GlobalAsm(self.lower_global_asm(ga)),
2631+
ItemKind::Ty(ref t, ref generics) => hir::ItemKind::Ty(
26322632
self.lower_ty(t, ImplTraitContext::Disallowed),
26332633
self.lower_generics(generics, ImplTraitContext::Disallowed),
26342634
),
2635-
ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemEnum(
2635+
ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemKind::Enum(
26362636
hir::EnumDef {
26372637
variants: enum_definition
26382638
.variants
@@ -2644,14 +2644,14 @@ impl<'a> LoweringContext<'a> {
26442644
),
26452645
ItemKind::Struct(ref struct_def, ref generics) => {
26462646
let struct_def = self.lower_variant_data(struct_def);
2647-
hir::ItemStruct(
2647+
hir::ItemKind::Struct(
26482648
struct_def,
26492649
self.lower_generics(generics, ImplTraitContext::Disallowed),
26502650
)
26512651
}
26522652
ItemKind::Union(ref vdata, ref generics) => {
26532653
let vdata = self.lower_variant_data(vdata);
2654-
hir::ItemUnion(
2654+
hir::ItemKind::Union(
26552655
vdata,
26562656
self.lower_generics(generics, ImplTraitContext::Disallowed),
26572657
)
@@ -2711,7 +2711,7 @@ impl<'a> LoweringContext<'a> {
27112711
},
27122712
);
27132713

2714-
hir::ItemImpl(
2714+
hir::ItemKind::Impl(
27152715
self.lower_unsafety(unsafety),
27162716
self.lower_impl_polarity(polarity),
27172717
self.lower_defaultness(defaultness, true /* [1] */),
@@ -2727,15 +2727,15 @@ impl<'a> LoweringContext<'a> {
27272727
.iter()
27282728
.map(|item| self.lower_trait_item_ref(item))
27292729
.collect();
2730-
hir::ItemTrait(
2730+
hir::ItemKind::Trait(
27312731
self.lower_is_auto(is_auto),
27322732
self.lower_unsafety(unsafety),
27332733
self.lower_generics(generics, ImplTraitContext::Disallowed),
27342734
bounds,
27352735
items,
27362736
)
27372737
}
2738-
ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemTraitAlias(
2738+
ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemKind::TraitAlias(
27392739
self.lower_generics(generics, ImplTraitContext::Disallowed),
27402740
self.lower_param_bounds(bounds, ImplTraitContext::Disallowed),
27412741
),
@@ -2754,7 +2754,7 @@ impl<'a> LoweringContext<'a> {
27542754
vis: &mut hir::Visibility,
27552755
name: &mut Name,
27562756
attrs: &hir::HirVec<Attribute>,
2757-
) -> hir::Item_ {
2757+
) -> hir::ItemKind {
27582758
let path = &tree.prefix;
27592759

27602760
match tree.kind {
@@ -2804,7 +2804,7 @@ impl<'a> LoweringContext<'a> {
28042804
self.with_hir_id_owner(new_node_id, |this| {
28052805
let new_id = this.lower_node_id(new_node_id);
28062806
let path = this.lower_path_extra(def, &path, None, ParamMode::Explicit);
2807-
let item = hir::ItemUse(P(path), hir::UseKind::Single);
2807+
let item = hir::ItemKind::Use(P(path), hir::UseKind::Single);
28082808
let vis_kind = match vis.node {
28092809
hir::VisibilityKind::Public => hir::VisibilityKind::Public,
28102810
hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
@@ -2835,7 +2835,7 @@ impl<'a> LoweringContext<'a> {
28352835
}
28362836

28372837
let path = P(self.lower_path_extra(ret_def, &path, None, ParamMode::Explicit));
2838-
hir::ItemUse(path, hir::UseKind::Single)
2838+
hir::ItemKind::Use(path, hir::UseKind::Single)
28392839
}
28402840
UseTreeKind::Glob => {
28412841
let path = P(self.lower_path(
@@ -2851,7 +2851,7 @@ impl<'a> LoweringContext<'a> {
28512851
},
28522852
ParamMode::Explicit,
28532853
));
2854-
hir::ItemUse(path, hir::UseKind::Glob)
2854+
hir::ItemKind::Use(path, hir::UseKind::Glob)
28552855
}
28562856
UseTreeKind::Nested(ref trees) => {
28572857
let prefix = Path {
@@ -2912,7 +2912,7 @@ impl<'a> LoweringContext<'a> {
29122912
// a re-export by accident when `pub`, e.g. in documentation.
29132913
let path = P(self.lower_path(id, &prefix, ParamMode::Explicit));
29142914
*vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited);
2915-
hir::ItemUse(path, hir::UseKind::ListStem)
2915+
hir::ItemKind::Use(path, hir::UseKind::ListStem)
29162916
}
29172917
}
29182918
}

src/librustc/hir/map/blocks.rs

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

4848
impl MaybeFnLike for ast::Item {
4949
fn is_fn_like(&self) -> bool {
50-
match self.node { ast::ItemFn(..) => true, _ => false, }
50+
match self.node { ast::ItemKind::Fn(..) => true, _ => false, }
5151
}
5252
}
5353

@@ -229,7 +229,7 @@ impl<'a> FnLikeNode<'a> {
229229
{
230230
match self.node {
231231
map::NodeItem(i) => match i.node {
232-
ast::ItemFn(ref decl, header, ref generics, block) =>
232+
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
233233
item_fn(ItemFnParts {
234234
id: i.id,
235235
name: i.name,

src/librustc/hir/map/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
329329
this.insert(i.id, NodeItem(i));
330330
this.with_parent(i.id, |this| {
331331
match i.node {
332-
ItemStruct(ref struct_def, _) => {
332+
ItemKind::Struct(ref struct_def, _) => {
333333
// If this is a tuple-like struct, register the constructor.
334334
if !struct_def.is_struct() {
335335
this.insert(struct_def.id(), NodeStructCtor(struct_def));

src/librustc/hir/map/hir_id_validator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
179179

180180
fn visit_impl_item_ref(&mut self, _: &'hir hir::ImplItemRef) {
181181
// Explicitly do nothing here. ImplItemRefs contain hir::Visibility
182-
// values that actually belong to an ImplItem instead of the ItemImpl
182+
// values that actually belong to an ImplItem instead of the ItemKind::Impl
183183
// we are currently in. So for those it's correct that they have a
184184
// different owner.
185185
}

0 commit comments

Comments
 (0)