Rename Item.node to Item.kind
This commit is contained in:
parent
21bf983acb
commit
7bc94cc3c2
99 changed files with 279 additions and 278 deletions
|
|
@ -65,7 +65,7 @@ impl Display for Target {
|
|||
|
||||
impl Target {
|
||||
pub(crate) fn from_item(item: &hir::Item) -> Target {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(..) => Target::ExternCrate,
|
||||
hir::ItemKind::Use(..) => Target::Use,
|
||||
hir::ItemKind::Static(..) => Target::Static,
|
||||
|
|
@ -333,7 +333,7 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn is_c_like_enum(item: &hir::Item) -> bool {
|
||||
if let hir::ItemKind::Enum(ref def, _) = item.node {
|
||||
if let hir::ItemKind::Enum(ref def, _) = item.kind {
|
||||
for variant in &def.variants {
|
||||
match variant.data {
|
||||
hir::VariantData::Unit(..) => { /* continue */ }
|
||||
|
|
|
|||
|
|
@ -465,7 +465,7 @@ pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param) {
|
|||
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||
visitor.visit_vis(&item.vis);
|
||||
visitor.visit_ident(item.ident);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::ExternCrate(orig_name) => {
|
||||
visitor.visit_id(item.hir_id);
|
||||
if let Some(orig_name) = orig_name {
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ impl<'a> LoweringContext<'a> {
|
|||
fn visit_item(&mut self, item: &'tcx Item) {
|
||||
let hir_id = self.lctx.allocate_hir_id_counter(item.id);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Struct(_, ref generics)
|
||||
| ItemKind::Union(_, ref generics)
|
||||
| ItemKind::Enum(_, ref generics)
|
||||
|
|
@ -1445,7 +1445,7 @@ impl<'a> LoweringContext<'a> {
|
|||
hir_id: opaque_ty_id,
|
||||
ident: Ident::invalid(),
|
||||
attrs: Default::default(),
|
||||
node: opaque_ty_item_kind,
|
||||
kind: opaque_ty_item_kind,
|
||||
vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited),
|
||||
span: opaque_ty_span,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ impl<'tcx, 'interner> Visitor<'tcx> for ItemLowerer<'tcx, 'interner> {
|
|||
if let Some(hir_id) = item_hir_id {
|
||||
self.lctx.with_parent_item_lifetime_defs(hir_id, |this| {
|
||||
let this = &mut ItemLowerer { lctx: this };
|
||||
if let ItemKind::Impl(.., ref opt_trait_ref, _, _) = item.node {
|
||||
if let ItemKind::Impl(.., ref opt_trait_ref, _, _) = item.kind {
|
||||
this.with_trait_impl_ref(opt_trait_ref, |this| {
|
||||
visit::walk_item(this, item)
|
||||
});
|
||||
|
|
@ -119,7 +119,7 @@ impl LoweringContext<'_> {
|
|||
) -> T {
|
||||
let old_len = self.in_scope_lifetimes.len();
|
||||
|
||||
let parent_generics = match self.items.get(&parent_hir_id).unwrap().node {
|
||||
let parent_generics = match self.items.get(&parent_hir_id).unwrap().kind {
|
||||
hir::ItemKind::Impl(_, _, _, ref generics, ..)
|
||||
| hir::ItemKind::Trait(_, _, ref generics, ..) => {
|
||||
&generics.params[..]
|
||||
|
|
@ -168,7 +168,7 @@ impl LoweringContext<'_> {
|
|||
}
|
||||
|
||||
pub(super) fn lower_item_id(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> {
|
||||
let node_ids = match i.node {
|
||||
let node_ids = match i.kind {
|
||||
ItemKind::Use(ref use_tree) => {
|
||||
let mut vec = smallvec![i.id];
|
||||
self.lower_item_id_use_tree(use_tree, i.id, &mut vec);
|
||||
|
|
@ -235,7 +235,7 @@ impl LoweringContext<'_> {
|
|||
}
|
||||
let attrs = attrs.into();
|
||||
|
||||
if let ItemKind::MacroDef(ref def) = i.node {
|
||||
if let ItemKind::MacroDef(ref def) = i.kind {
|
||||
if !def.legacy || attr::contains_name(&i.attrs, sym::macro_export) {
|
||||
let body = self.lower_token_stream(def.stream());
|
||||
let hir_id = self.lower_node_id(i.id);
|
||||
|
|
@ -254,13 +254,13 @@ impl LoweringContext<'_> {
|
|||
return None;
|
||||
}
|
||||
|
||||
let node = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.node);
|
||||
let kind = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.kind);
|
||||
|
||||
Some(hir::Item {
|
||||
hir_id: self.lower_node_id(i.id),
|
||||
ident,
|
||||
attrs,
|
||||
node,
|
||||
kind,
|
||||
vis,
|
||||
span: i.span,
|
||||
})
|
||||
|
|
@ -542,7 +542,7 @@ impl LoweringContext<'_> {
|
|||
let res = this.lower_res(res);
|
||||
let path =
|
||||
this.lower_path_extra(res, &path, ParamMode::Explicit, None);
|
||||
let item = hir::ItemKind::Use(P(path), hir::UseKind::Single);
|
||||
let kind = hir::ItemKind::Use(P(path), hir::UseKind::Single);
|
||||
let vis = this.rebuild_vis(&vis);
|
||||
|
||||
this.insert_item(
|
||||
|
|
@ -550,7 +550,7 @@ impl LoweringContext<'_> {
|
|||
hir_id: new_id,
|
||||
ident,
|
||||
attrs: attrs.into_iter().cloned().collect(),
|
||||
node: item,
|
||||
kind,
|
||||
vis,
|
||||
span,
|
||||
},
|
||||
|
|
@ -558,8 +558,7 @@ impl LoweringContext<'_> {
|
|||
});
|
||||
}
|
||||
|
||||
let path =
|
||||
P(self.lower_path_extra(ret_res, &path, ParamMode::Explicit, None));
|
||||
let path = P(self.lower_path_extra(ret_res, &path, ParamMode::Explicit, None));
|
||||
hir::ItemKind::Use(path, hir::UseKind::Single)
|
||||
}
|
||||
UseTreeKind::Glob => {
|
||||
|
|
@ -623,7 +622,7 @@ impl LoweringContext<'_> {
|
|||
let mut vis = this.rebuild_vis(&vis);
|
||||
let mut ident = *ident;
|
||||
|
||||
let item = this.lower_use_tree(use_tree,
|
||||
let kind = this.lower_use_tree(use_tree,
|
||||
&prefix,
|
||||
id,
|
||||
&mut vis,
|
||||
|
|
@ -635,7 +634,7 @@ impl LoweringContext<'_> {
|
|||
hir_id: new_hir_id,
|
||||
ident,
|
||||
attrs: attrs.into_iter().cloned().collect(),
|
||||
node: item,
|
||||
kind,
|
||||
vis,
|
||||
span: use_tree.span,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -37,7 +37,10 @@ trait MaybeFnLike { fn is_fn_like(&self) -> bool; }
|
|||
|
||||
impl MaybeFnLike for ast::Item {
|
||||
fn is_fn_like(&self) -> bool {
|
||||
match self.node { ast::ItemKind::Fn(..) => true, _ => false, }
|
||||
match self.kind {
|
||||
ast::ItemKind::Fn(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +218,7 @@ impl<'a> FnLikeNode<'a> {
|
|||
C: FnOnce(ClosureParts<'a>) -> A,
|
||||
{
|
||||
match self.node {
|
||||
map::Node::Item(i) => match i.node {
|
||||
map::Node::Item(i) => match i.kind {
|
||||
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
|
||||
item_fn(ItemFnParts {
|
||||
id: i.hir_id,
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
|||
self.with_dep_node_owner(i.hir_id.owner, i, |this| {
|
||||
this.insert(i.span, i.hir_id, Node::Item(i));
|
||||
this.with_parent(i.hir_id, |this| {
|
||||
if let ItemKind::Struct(ref struct_def, _) = i.node {
|
||||
if let ItemKind::Struct(ref struct_def, _) = i.kind {
|
||||
// If this is a tuple or unit-like struct, register the constructor.
|
||||
if let Some(ctor_hir_id) = struct_def.ctor_hir_id() {
|
||||
this.insert(i.span, ctor_hir_id, Node::Ctor(struct_def));
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
|
||||
// Pick the def data. This need not be unique, but the more
|
||||
// information we encapsulate into, the better
|
||||
let def_data = match i.node {
|
||||
let def_data = match i.kind {
|
||||
ItemKind::Impl(..) => DefPathData::Impl,
|
||||
ItemKind::Mod(..) if i.ident.name == kw::Invalid => {
|
||||
return visit::walk_item(self, i);
|
||||
|
|
@ -138,7 +138,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
let def = self.create_def(i.id, def_data, i.span);
|
||||
|
||||
self.with_parent(def, |this| {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
ItemKind::Struct(ref struct_def, _) | ItemKind::Union(ref struct_def, _) => {
|
||||
// If this is a unit or tuple-like struct, register the constructor.
|
||||
if let Some(ctor_hir_id) = struct_def.ctor_id() {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ impl<'hir> Entry<'hir> {
|
|||
fn fn_decl(&self) -> Option<&'hir FnDecl> {
|
||||
match self.node {
|
||||
Node::Item(ref item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(ref fn_decl, _, _, _) => Some(fn_decl),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ impl<'hir> Entry<'hir> {
|
|||
fn associated_body(self) -> Option<BodyId> {
|
||||
match self.node {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Const(_, body) |
|
||||
ItemKind::Static(.., body) |
|
||||
ItemKind::Fn(_, _, _, body) => Some(body),
|
||||
|
|
@ -293,7 +293,7 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
Some(match node {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Static(..) => DefKind::Static,
|
||||
ItemKind::Const(..) => DefKind::Const,
|
||||
ItemKind::Fn(..) => DefKind::Fn,
|
||||
|
|
@ -453,19 +453,19 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
|
||||
Node::Item(&Item { kind: ItemKind::Const(..), .. }) |
|
||||
Node::TraitItem(&TraitItem { kind: TraitItemKind::Const(..), .. }) |
|
||||
Node::ImplItem(&ImplItem { kind: ImplItemKind::Const(..), .. }) |
|
||||
Node::AnonConst(_) => {
|
||||
BodyOwnerKind::Const
|
||||
}
|
||||
Node::Ctor(..) |
|
||||
Node::Item(&Item { node: ItemKind::Fn(..), .. }) |
|
||||
Node::Item(&Item { kind: ItemKind::Fn(..), .. }) |
|
||||
Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. }) |
|
||||
Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => {
|
||||
BodyOwnerKind::Fn
|
||||
}
|
||||
Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => {
|
||||
Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => {
|
||||
BodyOwnerKind::Static(m)
|
||||
}
|
||||
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => {
|
||||
|
|
@ -477,8 +477,8 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
pub fn ty_param_owner(&self, id: HirId) -> HirId {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
|
||||
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id,
|
||||
Node::Item(&Item { kind: ItemKind::Trait(..), .. }) |
|
||||
Node::Item(&Item { kind: ItemKind::TraitAlias(..), .. }) => id,
|
||||
Node::GenericParam(_) => self.get_parent_node(id),
|
||||
_ => bug!("ty_param_owner: {} not a type parameter", self.node_to_string(id))
|
||||
}
|
||||
|
|
@ -486,8 +486,8 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
pub fn ty_param_name(&self, id: HirId) -> Name {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
|
||||
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
|
||||
Node::Item(&Item { kind: ItemKind::Trait(..), .. }) |
|
||||
Node::Item(&Item { kind: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
|
||||
Node::GenericParam(param) => param.name.ident().name,
|
||||
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
|
||||
}
|
||||
|
|
@ -517,7 +517,7 @@ impl<'hir> Map<'hir> {
|
|||
match self.find_entry(hir_id).unwrap().node {
|
||||
Node::Item(&Item {
|
||||
span,
|
||||
node: ItemKind::Mod(ref m),
|
||||
kind: ItemKind::Mod(ref m),
|
||||
..
|
||||
}) => (m, span, hir_id),
|
||||
Node::Crate => (&self.forest.krate.module, self.forest.krate.span, hir_id),
|
||||
|
|
@ -568,7 +568,7 @@ impl<'hir> Map<'hir> {
|
|||
Node::ImplItem(ref impl_item) => Some(&impl_item.generics),
|
||||
Node::TraitItem(ref trait_item) => Some(&trait_item.generics),
|
||||
Node::Item(ref item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(_, _, ref generics, _) |
|
||||
ItemKind::TyAlias(_, ref generics) |
|
||||
ItemKind::Enum(_, ref generics) |
|
||||
|
|
@ -649,7 +649,7 @@ impl<'hir> Map<'hir> {
|
|||
let parent_id = self.get_parent_item(hir_id);
|
||||
match self.get(parent_id) {
|
||||
Node::Item(&Item {
|
||||
node: ItemKind::Const(..),
|
||||
kind: ItemKind::Const(..),
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(&TraitItem {
|
||||
|
|
@ -662,11 +662,11 @@ impl<'hir> Map<'hir> {
|
|||
})
|
||||
| Node::AnonConst(_)
|
||||
| Node::Item(&Item {
|
||||
node: ItemKind::Static(..),
|
||||
kind: ItemKind::Static(..),
|
||||
..
|
||||
}) => true,
|
||||
Node::Item(&Item {
|
||||
node: ItemKind::Fn(_, header, ..),
|
||||
kind: ItemKind::Fn(_, header, ..),
|
||||
..
|
||||
}) => header.constness == Constness::Const,
|
||||
_ => false,
|
||||
|
|
@ -676,7 +676,7 @@ impl<'hir> Map<'hir> {
|
|||
/// Wether `hir_id` corresponds to a `mod` or a crate.
|
||||
pub fn is_hir_id_module(&self, hir_id: HirId) -> bool {
|
||||
match self.lookup(hir_id) {
|
||||
Some(Entry { node: Node::Item(Item { node: ItemKind::Mod(_), .. }), .. }) |
|
||||
Some(Entry { node: Node::Item(Item { kind: ItemKind::Mod(_), .. }), .. }) |
|
||||
Some(Entry { node: Node::Crate, .. }) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -796,7 +796,7 @@ impl<'hir> Map<'hir> {
|
|||
/// module parent is in this map.
|
||||
pub fn get_module_parent_node(&self, hir_id: HirId) -> HirId {
|
||||
match self.walk_parent_nodes(hir_id, |node| match *node {
|
||||
Node::Item(&Item { node: ItemKind::Mod(_), .. }) => true,
|
||||
Node::Item(&Item { kind: ItemKind::Mod(_), .. }) => true,
|
||||
_ => false,
|
||||
}, |_| false) {
|
||||
Ok(id) => id,
|
||||
|
|
@ -808,7 +808,7 @@ impl<'hir> Map<'hir> {
|
|||
pub fn get_enclosing_scope(&self, hir_id: HirId) -> Option<HirId> {
|
||||
self.walk_parent_nodes(hir_id, |node| match *node {
|
||||
Node::Item(i) => {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
ItemKind::Fn(..)
|
||||
| ItemKind::Mod(..)
|
||||
| ItemKind::Enum(..)
|
||||
|
|
@ -852,7 +852,7 @@ impl<'hir> Map<'hir> {
|
|||
}
|
||||
match self.get(scope) {
|
||||
Node::Item(i) => {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: None, .. }) => {}
|
||||
_ => break,
|
||||
}
|
||||
|
|
@ -872,7 +872,7 @@ impl<'hir> Map<'hir> {
|
|||
let parent = self.get_parent_item(hir_id);
|
||||
if let Some(entry) = self.find_entry(parent) {
|
||||
if let Entry {
|
||||
node: Node::Item(Item { node: ItemKind::ForeignMod(ref nm), .. }), .. } = entry
|
||||
node: Node::Item(Item { kind: ItemKind::ForeignMod(ref nm), .. }), .. } = entry
|
||||
{
|
||||
self.read(hir_id); // reveals some of the content of a node
|
||||
return nm.abi;
|
||||
|
|
@ -905,7 +905,7 @@ impl<'hir> Map<'hir> {
|
|||
pub fn expect_variant_data(&self, id: HirId) -> &'hir VariantData {
|
||||
match self.find(id) {
|
||||
Some(Node::Item(i)) => {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
ItemKind::Struct(ref struct_def, _) |
|
||||
ItemKind::Union(ref struct_def, _) => struct_def,
|
||||
_ => bug!("struct ID bound to non-struct {}", self.node_to_string(id))
|
||||
|
|
@ -1123,7 +1123,7 @@ impl<'a> NodesMatchingSuffix<'a> {
|
|||
}
|
||||
|
||||
fn item_is_mod(item: &Item) -> bool {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Mod(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1286,7 +1286,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
|
|||
|
||||
match map.find(id) {
|
||||
Some(Node::Item(item)) => {
|
||||
let item_str = match item.node {
|
||||
let item_str = match item.kind {
|
||||
ItemKind::ExternCrate(..) => "extern crate",
|
||||
ItemKind::Use(..) => "use",
|
||||
ItemKind::Static(..) => "static",
|
||||
|
|
|
|||
|
|
@ -2416,7 +2416,7 @@ pub struct Item {
|
|||
pub ident: Ident,
|
||||
pub hir_id: HirId,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub node: ItemKind,
|
||||
pub kind: ItemKind,
|
||||
pub vis: Visibility,
|
||||
pub span: Span,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -474,7 +474,7 @@ impl<'a> State<'a> {
|
|||
self.maybe_print_comment(item.span.lo());
|
||||
self.print_outer_attributes(&item.attrs);
|
||||
self.ann.pre(self, AnnNode::Item(item));
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(orig_name) => {
|
||||
self.head(visibility_qualified(&item.vis, "extern crate"));
|
||||
if let Some(orig_name) = orig_name {
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
|
|||
ident,
|
||||
ref attrs,
|
||||
hir_id: _,
|
||||
ref node,
|
||||
ref kind,
|
||||
ref vis,
|
||||
span
|
||||
} = *self;
|
||||
|
|
@ -320,7 +320,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
|
|||
hcx.hash_hir_item_like(|hcx| {
|
||||
ident.name.hash_stable(hcx, hasher);
|
||||
attrs.hash_stable(hcx, hasher);
|
||||
node.hash_stable(hcx, hasher);
|
||||
kind.hash_stable(hcx, hasher);
|
||||
vis.hash_stable(hcx, hasher);
|
||||
span.hash_stable(hcx, hasher);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
fn item_scope_tag(item: &hir::Item) -> &'static str {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Impl(..) => "impl",
|
||||
hir::ItemKind::Struct(..) => "struct",
|
||||
hir::ItemKind::Union(..) => "union",
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(def_id) {
|
||||
let fndecl = match self.tcx().hir().get(hir_id) {
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(ref fndecl, ..),
|
||||
kind: hir::ItemKind::Fn(ref fndecl, ..),
|
||||
..
|
||||
}) => &fndecl,
|
||||
Node::TraitItem(&hir::TraitItem {
|
||||
|
|
|
|||
|
|
@ -1036,7 +1036,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
|||
.local_def_id(opaque_parent_hir_id)
|
||||
};
|
||||
let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) {
|
||||
Some(Node::Item(item)) => match item.node {
|
||||
Some(Node::Item(item)) => match item.kind {
|
||||
// Anonymous `impl Trait`
|
||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
|
||||
impl_trait_fn: Some(parent),
|
||||
|
|
|
|||
|
|
@ -981,7 +981,7 @@ for LateContextAndPass<'a, 'tcx, T> {
|
|||
|
||||
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
let generics = self.context.generics.take();
|
||||
self.context.generics = it.node.generics();
|
||||
self.context.generics = it.kind.generics();
|
||||
self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
|
||||
cx.with_param_env(it.hir_id, |cx| {
|
||||
lint_callback!(cx, check_item, it);
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ declare_lint_pass!(LintPassImpl => [LINT_PASS_IMPL_WITHOUT_MACRO]);
|
|||
|
||||
impl EarlyLintPass for LintPassImpl {
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
|
||||
if let ItemKind::Impl(_, _, _, _, Some(lint_pass), _, _) = &item.node {
|
||||
if let ItemKind::Impl(_, _, _, _, Some(lint_pass), _, _) = &item.kind {
|
||||
if let Some(last) = lint_pass.path.segments.last() {
|
||||
if last.ident.name == sym::LintPass {
|
||||
let expn_data = lint_pass.path.span.ctxt().outer_expn_data();
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
self.inherited_pub_visibility = false;
|
||||
match node {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
|
||||
let def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
let def = self.tcx.adt_def(def_id);
|
||||
|
|
@ -369,7 +369,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
|
|||
if allow_dead_code {
|
||||
self.worklist.push(item.hir_id);
|
||||
}
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Enum(ref enum_def, _) => {
|
||||
if allow_dead_code {
|
||||
self.worklist.extend(enum_def.variants.iter().map(|variant| variant.id));
|
||||
|
|
@ -482,7 +482,7 @@ struct DeadVisitor<'tcx> {
|
|||
|
||||
impl DeadVisitor<'tcx> {
|
||||
fn should_warn_about_item(&mut self, item: &hir::Item) -> bool {
|
||||
let should_warn = match item.node {
|
||||
let should_warn = match item.kind {
|
||||
hir::ItemKind::Static(..)
|
||||
| hir::ItemKind::Const(..)
|
||||
| hir::ItemKind::Fn(..)
|
||||
|
|
@ -571,7 +571,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
if self.should_warn_about_item(item) {
|
||||
// For items that have a definition with a signature followed by a
|
||||
// block, point only at the signature.
|
||||
let span = match item.node {
|
||||
let span = match item.kind {
|
||||
hir::ItemKind::Fn(..) |
|
||||
hir::ItemKind::Mod(..) |
|
||||
hir::ItemKind::Enum(..) |
|
||||
|
|
@ -581,7 +581,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
hir::ItemKind::Impl(..) => self.tcx.sess.source_map().def_span(item.span),
|
||||
_ => item.span,
|
||||
};
|
||||
let participle = match item.node {
|
||||
let participle = match item.kind {
|
||||
hir::ItemKind::Struct(..) => "constructed", // Issue #52325
|
||||
_ => "used"
|
||||
};
|
||||
|
|
@ -589,7 +589,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
item.hir_id,
|
||||
span,
|
||||
item.ident.name,
|
||||
item.node.descriptive_variant(),
|
||||
item.kind.descriptive_variant(),
|
||||
participle,
|
||||
);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(DefId, EntryFnType)> {
|
|||
// Beware, this is duplicated in `libsyntax/entry.rs`, so make sure to keep
|
||||
// them in sync.
|
||||
fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(..) => {
|
||||
if attr::contains_name(&item.attrs, sym::start) {
|
||||
EntryPointType::Start
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt
|
|||
return true
|
||||
}
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(_, header, ..) if header.is_const() => {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -157,7 +157,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
|
||||
match self.tcx.hir().find(hir_id) {
|
||||
Some(Node::Item(item)) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(..) =>
|
||||
item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)),
|
||||
_ => false,
|
||||
|
|
@ -187,7 +187,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
// type of the impl require inlining, this method
|
||||
// does too.
|
||||
let impl_hir_id = self.tcx.hir().as_local_hir_id(impl_did).unwrap();
|
||||
match self.tcx.hir().expect_item(impl_hir_id).node {
|
||||
match self.tcx.hir().expect_item(impl_hir_id).kind {
|
||||
hir::ItemKind::Impl(..) => {
|
||||
let generics = self.tcx.generics_of(impl_did);
|
||||
generics.requires_monomorphization(self.tcx)
|
||||
|
|
@ -225,7 +225,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
// If we are building an executable, only explicitly extern
|
||||
// types need to be exported.
|
||||
if let Node::Item(item) = *node {
|
||||
let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.node {
|
||||
let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.kind {
|
||||
header.abi != Abi::Rust
|
||||
} else {
|
||||
false
|
||||
|
|
@ -249,7 +249,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
|
||||
match *node {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(.., body) => {
|
||||
let def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
if item_might_be_inlined(self.tcx,
|
||||
|
|
@ -361,7 +361,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
|
|||
}
|
||||
|
||||
// We need only trait impls here, not inherent impls, and only non-exported ones
|
||||
if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node {
|
||||
if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.kind {
|
||||
if !self.access_levels.is_reachable(item.hir_id) {
|
||||
self.worklist.extend(impl_item_refs.iter().map(|ii_ref| ii_ref.id.hir_id));
|
||||
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(ref decl, _, ref generics, _) => {
|
||||
self.visit_early_late(None, decl, generics, |this| {
|
||||
intravisit::walk_item(this, item);
|
||||
|
|
@ -504,12 +504,12 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
| hir::ItemKind::Impl(_, _, _, ref generics, ..) => {
|
||||
// Impls permit `'_` to be used and it is equivalent to "some fresh lifetime name".
|
||||
// This is not true for other kinds of items.x
|
||||
let track_lifetime_uses = match item.node {
|
||||
let track_lifetime_uses = match item.kind {
|
||||
hir::ItemKind::Impl(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
// These kinds of items have only early-bound lifetime parameters.
|
||||
let mut index = if sub_items_have_self_param(&item.node) {
|
||||
let mut index = if sub_items_have_self_param(&item.kind) {
|
||||
1 // Self comes before lifetimes
|
||||
} else {
|
||||
0
|
||||
|
|
@ -637,8 +637,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
// `type MyAnonTy<'b> = impl MyTrait<'b>;`
|
||||
// ^ ^ this gets resolved in the scope of
|
||||
// the opaque_ty generics
|
||||
let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).node
|
||||
{
|
||||
let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).kind {
|
||||
// Named opaque `impl Trait` types are reached via `TyKind::Path`.
|
||||
// This arm is for `impl Trait` in the types of statics, constants and locals.
|
||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
|
||||
|
|
@ -1263,7 +1262,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
|
|||
fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap<Vec<ObjectLifetimeDefault>> {
|
||||
let mut map = HirIdMap::default();
|
||||
for item in tcx.hir().krate().items.values() {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Struct(_, ref generics)
|
||||
| hir::ItemKind::Union(_, ref generics)
|
||||
| hir::ItemKind::Enum(_, ref generics)
|
||||
|
|
@ -1525,7 +1524,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
{
|
||||
match parent {
|
||||
Node::Item(item) => {
|
||||
if let hir::ItemKind::Fn(decl, _, _, _) = &item.node {
|
||||
if let hir::ItemKind::Fn(decl, _, _, _) = &item.kind {
|
||||
find_arg_use_span(&decl.inputs);
|
||||
}
|
||||
},
|
||||
|
|
@ -1733,10 +1732,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
let mut index = 0;
|
||||
if let Some(parent_id) = parent_id {
|
||||
let parent = self.tcx.hir().expect_item(parent_id);
|
||||
if sub_items_have_self_param(&parent.node) {
|
||||
if sub_items_have_self_param(&parent.kind) {
|
||||
index += 1; // Self comes before lifetimes
|
||||
}
|
||||
match parent.node {
|
||||
match parent.kind {
|
||||
hir::ItemKind::Trait(_, _, ref generics, ..)
|
||||
| hir::ItemKind::Impl(_, _, _, ref generics, ..) => {
|
||||
index += generics.params.len() as u32;
|
||||
|
|
@ -1867,7 +1866,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
let fn_id = self.tcx.hir().body_owner(body_id);
|
||||
match self.tcx.hir().get(fn_id) {
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(..),
|
||||
kind: hir::ItemKind::Fn(..),
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(&hir::TraitItem {
|
||||
|
|
@ -2165,7 +2164,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
let body = match self.tcx.hir().get(parent) {
|
||||
// `fn` definitions and methods.
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(.., body),
|
||||
kind: hir::ItemKind::Fn(.., body),
|
||||
..
|
||||
}) => Some(body),
|
||||
|
||||
|
|
@ -2176,7 +2175,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx
|
||||
.hir()
|
||||
.expect_item(self.tcx.hir().get_parent_item(parent))
|
||||
.node
|
||||
.kind
|
||||
{
|
||||
assoc_item_kind = trait_items
|
||||
.iter()
|
||||
|
|
@ -2196,7 +2195,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx
|
||||
.hir()
|
||||
.expect_item(self.tcx.hir().get_parent_item(parent))
|
||||
.node
|
||||
.kind
|
||||
{
|
||||
impl_self = Some(self_ty);
|
||||
assoc_item_kind = impl_items
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
|||
fn visit_item(&mut self, i: &'tcx Item) {
|
||||
let orig_in_trait_impl = self.in_trait_impl;
|
||||
let mut kind = AnnotationKind::Required;
|
||||
match i.node {
|
||||
match i.kind {
|
||||
// Inherent impls and foreign modules serve only as containers for other items,
|
||||
// they don't have their own stability. They still can be annotated as unstable
|
||||
// and propagate this unstability to children, but this annotation is completely
|
||||
|
|
@ -344,14 +344,14 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'tcx Item) {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
// Inherent impls and foreign modules serve only as containers for other items,
|
||||
// they don't have their own stability. They still can be annotated as unstable
|
||||
// and propagate this unstability to children, but this annotation is completely
|
||||
// optional. They inherit stability from their parents when unannotated.
|
||||
hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => {}
|
||||
|
||||
_ => self.check_missing_stability(i.hir_id, i.span, i.node.descriptive_variant())
|
||||
_ => self.check_missing_stability(i.hir_id, i.span, i.kind.descriptive_variant())
|
||||
}
|
||||
|
||||
intravisit::walk_item(self, i)
|
||||
|
|
@ -797,7 +797,7 @@ impl Visitor<'tcx> for Checker<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(_) => {
|
||||
// compiler-generated `extern crate` items have a dummy span.
|
||||
if item.span.is_dummy() { return }
|
||||
|
|
|
|||
|
|
@ -1001,7 +1001,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
Ok(EvaluationResult::EvaluatedToAmbig) => {
|
||||
if let Some(hir::Node::Item(hir::Item {
|
||||
ident,
|
||||
node: hir::ItemKind::Fn(.., body_id),
|
||||
kind: hir::ItemKind::Fn(.., body_id),
|
||||
..
|
||||
})) = self.tcx.hir().get_if_local(def_id) {
|
||||
let body = self.tcx.hir().body(*body_id);
|
||||
|
|
@ -1106,7 +1106,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
||||
let node = hir.find(parent_node);
|
||||
if let Some(hir::Node::Item(hir::Item {
|
||||
node: hir::ItemKind::Fn(decl, _, _, body_id),
|
||||
kind: hir::ItemKind::Fn(decl, _, _, body_id),
|
||||
..
|
||||
})) = node {
|
||||
let body = hir.body(*body_id);
|
||||
|
|
@ -1163,7 +1163,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
Node::Item(&hir::Item {
|
||||
span,
|
||||
node: hir::ItemKind::Fn(ref decl, ..),
|
||||
kind: hir::ItemKind::Fn(ref decl, ..),
|
||||
..
|
||||
}) |
|
||||
Node::ImplItem(&hir::ImplItem {
|
||||
|
|
|
|||
|
|
@ -654,7 +654,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
match self.hir().as_local_hir_id(node_item_def_id) {
|
||||
Some(hir_id) => {
|
||||
let item = self.hir().expect_item(hir_id);
|
||||
if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node {
|
||||
if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.kind {
|
||||
defaultness.is_default()
|
||||
} else {
|
||||
false
|
||||
|
|
|
|||
|
|
@ -1554,7 +1554,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let hir_id = self.hir().as_local_hir_id(scope_def_id).unwrap();
|
||||
match self.hir().get(hir_id) {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(..) => { /* `type_of_def_id()` will work */ }
|
||||
_ => {
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -3164,7 +3164,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> AssocItem {
|
|||
let parent_id = tcx.hir().get_parent_item(id);
|
||||
let parent_def_id = tcx.hir().local_def_id(parent_id);
|
||||
let parent_item = tcx.hir().expect_item(parent_id);
|
||||
match parent_item.node {
|
||||
match parent_item.kind {
|
||||
hir::ItemKind::Impl(.., ref impl_item_refs) => {
|
||||
if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.hir_id == id) {
|
||||
let assoc_item = tcx.associated_item_from_impl_item_ref(parent_def_id,
|
||||
|
|
@ -3189,7 +3189,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> AssocItem {
|
|||
|
||||
span_bug!(parent_item.span,
|
||||
"unexpected parent of trait or impl item or item not found: {:?}",
|
||||
parent_item.node)
|
||||
parent_item.kind)
|
||||
}
|
||||
|
||||
#[derive(Clone, HashStable)]
|
||||
|
|
@ -3221,7 +3221,7 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> AdtSizedConstraint<'_
|
|||
fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
|
||||
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let item = tcx.hir().expect_item(id);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
tcx.arena.alloc_from_iter(
|
||||
trait_item_refs.iter()
|
||||
|
|
@ -3262,7 +3262,7 @@ fn trait_of_item(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
|
|||
pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
|
||||
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
|
||||
if let Node::Item(item) = tcx.hir().get(hir_id) {
|
||||
if let hir::ItemKind::OpaqueTy(ref opaque_ty) = item.node {
|
||||
if let hir::ItemKind::OpaqueTy(ref opaque_ty) = item.kind {
|
||||
return opaque_ty.impl_trait_fn;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue