Navigation Menu

Skip to content

Commit

Permalink
ItemKind
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe authored and oli-obk committed Jul 16, 2018
1 parent 7e5d224 commit 5b0cf56
Show file tree
Hide file tree
Showing 61 changed files with 696 additions and 696 deletions.
16 changes: 8 additions & 8 deletions src/librustc/hir/check_attr.rs
Expand Up @@ -38,13 +38,13 @@ enum Target {
impl Target {
fn from_item(item: &hir::Item) -> Target {
match item.node {
hir::ItemFn(..) => Target::Fn,
hir::ItemStruct(..) => Target::Struct,
hir::ItemUnion(..) => Target::Union,
hir::ItemEnum(..) => Target::Enum,
hir::ItemConst(..) => Target::Const,
hir::ItemForeignMod(..) => Target::ForeignMod,
hir::ItemStatic(..) => Target::Static,
hir::ItemKind::Fn(..) => Target::Fn,
hir::ItemKind::Struct(..) => Target::Struct,
hir::ItemKind::Union(..) => Target::Union,
hir::ItemKind::Enum(..) => Target::Enum,
hir::ItemKind::Const(..) => Target::Const,
hir::ItemKind::ForeignMod(..) => Target::ForeignMod,
hir::ItemKind::Static(..) => Target::Static,
_ => Target::Other,
}
}
Expand Down Expand Up @@ -340,7 +340,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
}

fn is_c_like_enum(item: &hir::Item) -> bool {
if let hir::ItemEnum(ref def, _) = item.node {
if let hir::ItemKind::Enum(ref def, _) = item.node {
for variant in &def.variants {
match variant.node.data {
hir::VariantData::Unit(_) => { /* continue */ }
Expand Down
32 changes: 16 additions & 16 deletions src/librustc/hir/intravisit.rs
Expand Up @@ -463,23 +463,23 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
visitor.visit_vis(&item.vis);
visitor.visit_name(item.span, item.name);
match item.node {
ItemExternCrate(orig_name) => {
ItemKind::ExternCrate(orig_name) => {
visitor.visit_id(item.id);
if let Some(orig_name) = orig_name {
visitor.visit_name(item.span, orig_name);
}
}
ItemUse(ref path, _) => {
ItemKind::Use(ref path, _) => {
visitor.visit_id(item.id);
visitor.visit_path(path, item.id);
}
ItemStatic(ref typ, _, body) |
ItemConst(ref typ, body) => {
ItemKind::Static(ref typ, _, body) |
ItemKind::Const(ref typ, body) => {
visitor.visit_id(item.id);
visitor.visit_ty(typ);
visitor.visit_nested_body(body);
}
ItemFn(ref declaration, header, ref generics, body_id) => {
ItemKind::Fn(ref declaration, header, ref generics, body_id) => {
visitor.visit_fn(FnKind::ItemFn(item.name,
generics,
header,
Expand All @@ -490,55 +490,55 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
item.span,
item.id)
}
ItemMod(ref module) => {
ItemKind::Mod(ref module) => {
// visit_mod() takes care of visiting the Item's NodeId
visitor.visit_mod(module, item.span, item.id)
}
ItemForeignMod(ref foreign_module) => {
ItemKind::ForeignMod(ref foreign_module) => {
visitor.visit_id(item.id);
walk_list!(visitor, visit_foreign_item, &foreign_module.items);
}
ItemGlobalAsm(_) => {
ItemKind::GlobalAsm(_) => {
visitor.visit_id(item.id);
}
ItemTy(ref typ, ref type_parameters) => {
ItemKind::Ty(ref typ, ref type_parameters) => {
visitor.visit_id(item.id);
visitor.visit_ty(typ);
visitor.visit_generics(type_parameters)
}
ItemExistential(ExistTy {ref generics, ref bounds, impl_trait_fn}) => {
ItemKind::Existential(ExistTy {ref generics, ref bounds, impl_trait_fn}) => {
visitor.visit_id(item.id);
walk_generics(visitor, generics);
walk_list!(visitor, visit_param_bound, bounds);
if let Some(impl_trait_fn) = impl_trait_fn {
visitor.visit_def_mention(Def::Fn(impl_trait_fn))
}
}
ItemEnum(ref enum_definition, ref type_parameters) => {
ItemKind::Enum(ref enum_definition, ref type_parameters) => {
visitor.visit_generics(type_parameters);
// visit_enum_def() takes care of visiting the Item's NodeId
visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span)
}
ItemImpl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_item_refs) => {
ItemKind::Impl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_item_refs) => {
visitor.visit_id(item.id);
visitor.visit_generics(type_parameters);
walk_list!(visitor, visit_trait_ref, opt_trait_reference);
visitor.visit_ty(typ);
walk_list!(visitor, visit_impl_item_ref, impl_item_refs);
}
ItemStruct(ref struct_definition, ref generics) |
ItemUnion(ref struct_definition, ref generics) => {
ItemKind::Struct(ref struct_definition, ref generics) |
ItemKind::Union(ref struct_definition, ref generics) => {
visitor.visit_generics(generics);
visitor.visit_id(item.id);
visitor.visit_variant_data(struct_definition, item.name, generics, item.id, item.span);
}
ItemTrait(.., ref generics, ref bounds, ref trait_item_refs) => {
ItemKind::Trait(.., ref generics, ref bounds, ref trait_item_refs) => {
visitor.visit_id(item.id);
visitor.visit_generics(generics);
walk_list!(visitor, visit_param_bound, bounds);
walk_list!(visitor, visit_trait_item_ref, trait_item_refs);
}
ItemTraitAlias(ref generics, ref bounds) => {
ItemKind::TraitAlias(ref generics, ref bounds) => {
visitor.visit_id(item.id);
visitor.visit_generics(generics);
walk_list!(visitor, visit_param_bound, bounds);
Expand Down
46 changes: 23 additions & 23 deletions src/librustc/hir/lowering.rs
Expand Up @@ -384,8 +384,8 @@ impl<'a> LoweringContext<'a> {

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

self.with_hir_id_owner(exist_ty_node_id, |lctx| {
let exist_ty_item_kind = hir::ItemExistential(hir::ExistTy {
let exist_ty_item_kind = hir::ItemKind::Existential(hir::ExistTy {
generics: hir::Generics {
params: lifetime_defs,
where_clause: hir::WhereClause {
Expand Down Expand Up @@ -2575,9 +2575,9 @@ impl<'a> LoweringContext<'a> {
attrs: &hir::HirVec<Attribute>,
vis: &mut hir::Visibility,
i: &ItemKind,
) -> hir::Item_ {
) -> hir::ItemKind {
match *i {
ItemKind::ExternCrate(orig_name) => hir::ItemExternCrate(orig_name),
ItemKind::ExternCrate(orig_name) => hir::ItemKind::ExternCrate(orig_name),
ItemKind::Use(ref use_tree) => {
// Start with an empty prefix
let prefix = Path {
Expand All @@ -2589,15 +2589,15 @@ impl<'a> LoweringContext<'a> {
}
ItemKind::Static(ref t, m, ref e) => {
let value = self.lower_body(None, |this| this.lower_expr(e));
hir::ItemStatic(
hir::ItemKind::Static(
self.lower_ty(t, ImplTraitContext::Disallowed),
self.lower_mutability(m),
value,
)
}
ItemKind::Const(ref t, ref e) => {
let value = self.lower_body(None, |this| this.lower_expr(e));
hir::ItemConst(self.lower_ty(t, ImplTraitContext::Disallowed), value)
hir::ItemKind::Const(self.lower_ty(t, ImplTraitContext::Disallowed), value)
}
ItemKind::Fn(ref decl, header, ref generics, ref body) => {
let fn_def_id = self.resolver.definitions().local_def_id(id);
Expand All @@ -2617,22 +2617,22 @@ impl<'a> LoweringContext<'a> {
decl, Some((fn_def_id, idty)), true, header.asyncness.opt_return_id()),
);

hir::ItemFn(
hir::ItemKind::Fn(
fn_decl,
this.lower_fn_header(header),
generics,
body_id,
)
})
}
ItemKind::Mod(ref m) => hir::ItemMod(self.lower_mod(m)),
ItemKind::ForeignMod(ref nm) => hir::ItemForeignMod(self.lower_foreign_mod(nm)),
ItemKind::GlobalAsm(ref ga) => hir::ItemGlobalAsm(self.lower_global_asm(ga)),
ItemKind::Ty(ref t, ref generics) => hir::ItemTy(
ItemKind::Mod(ref m) => hir::ItemKind::Mod(self.lower_mod(m)),
ItemKind::ForeignMod(ref nm) => hir::ItemKind::ForeignMod(self.lower_foreign_mod(nm)),
ItemKind::GlobalAsm(ref ga) => hir::ItemKind::GlobalAsm(self.lower_global_asm(ga)),
ItemKind::Ty(ref t, ref generics) => hir::ItemKind::Ty(
self.lower_ty(t, ImplTraitContext::Disallowed),
self.lower_generics(generics, ImplTraitContext::Disallowed),
),
ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemEnum(
ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemKind::Enum(
hir::EnumDef {
variants: enum_definition
.variants
Expand All @@ -2644,14 +2644,14 @@ impl<'a> LoweringContext<'a> {
),
ItemKind::Struct(ref struct_def, ref generics) => {
let struct_def = self.lower_variant_data(struct_def);
hir::ItemStruct(
hir::ItemKind::Struct(
struct_def,
self.lower_generics(generics, ImplTraitContext::Disallowed),
)
}
ItemKind::Union(ref vdata, ref generics) => {
let vdata = self.lower_variant_data(vdata);
hir::ItemUnion(
hir::ItemKind::Union(
vdata,
self.lower_generics(generics, ImplTraitContext::Disallowed),
)
Expand Down Expand Up @@ -2711,7 +2711,7 @@ impl<'a> LoweringContext<'a> {
},
);

hir::ItemImpl(
hir::ItemKind::Impl(
self.lower_unsafety(unsafety),
self.lower_impl_polarity(polarity),
self.lower_defaultness(defaultness, true /* [1] */),
Expand All @@ -2727,15 +2727,15 @@ impl<'a> LoweringContext<'a> {
.iter()
.map(|item| self.lower_trait_item_ref(item))
.collect();
hir::ItemTrait(
hir::ItemKind::Trait(
self.lower_is_auto(is_auto),
self.lower_unsafety(unsafety),
self.lower_generics(generics, ImplTraitContext::Disallowed),
bounds,
items,
)
}
ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemTraitAlias(
ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemKind::TraitAlias(
self.lower_generics(generics, ImplTraitContext::Disallowed),
self.lower_param_bounds(bounds, ImplTraitContext::Disallowed),
),
Expand All @@ -2754,7 +2754,7 @@ impl<'a> LoweringContext<'a> {
vis: &mut hir::Visibility,
name: &mut Name,
attrs: &hir::HirVec<Attribute>,
) -> hir::Item_ {
) -> hir::ItemKind {
let path = &tree.prefix;

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

let path = P(self.lower_path_extra(ret_def, &path, None, ParamMode::Explicit));
hir::ItemUse(path, hir::UseKind::Single)
hir::ItemKind::Use(path, hir::UseKind::Single)
}
UseTreeKind::Glob => {
let path = P(self.lower_path(
Expand All @@ -2851,7 +2851,7 @@ impl<'a> LoweringContext<'a> {
},
ParamMode::Explicit,
));
hir::ItemUse(path, hir::UseKind::Glob)
hir::ItemKind::Use(path, hir::UseKind::Glob)
}
UseTreeKind::Nested(ref trees) => {
let prefix = Path {
Expand Down Expand Up @@ -2912,7 +2912,7 @@ impl<'a> LoweringContext<'a> {
// a re-export by accident when `pub`, e.g. in documentation.
let path = P(self.lower_path(id, &prefix, ParamMode::Explicit));
*vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited);
hir::ItemUse(path, hir::UseKind::ListStem)
hir::ItemKind::Use(path, hir::UseKind::ListStem)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/map/blocks.rs
Expand Up @@ -47,7 +47,7 @@ pub trait MaybeFnLike { fn is_fn_like(&self) -> bool; }

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

Expand Down Expand Up @@ -229,7 +229,7 @@ impl<'a> FnLikeNode<'a> {
{
match self.node {
map::NodeItem(i) => match i.node {
ast::ItemFn(ref decl, header, ref generics, block) =>
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
item_fn(ItemFnParts {
id: i.id,
name: i.name,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/collector.rs
Expand Up @@ -329,7 +329,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
this.insert(i.id, NodeItem(i));
this.with_parent(i.id, |this| {
match i.node {
ItemStruct(ref struct_def, _) => {
ItemKind::Struct(ref struct_def, _) => {
// If this is a tuple-like struct, register the constructor.
if !struct_def.is_struct() {
this.insert(struct_def.id(), NodeStructCtor(struct_def));
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/hir_id_validator.rs
Expand Up @@ -179,7 +179,7 @@ impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {

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

0 comments on commit 5b0cf56

Please sign in to comment.