Rename Item.node
to Item.kind
This commit is contained in:
parent
21bf983acb
commit
7bc94cc3c2
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ impl CodegenCx<'ll, 'tcx> {
|
||||
let llty = self.layout_of(ty).llvm_type(self);
|
||||
let (g, attrs) = match self.tcx.hir().get(id) {
|
||||
Node::Item(&hir::Item {
|
||||
ref attrs, span, node: hir::ItemKind::Static(..), ..
|
||||
ref attrs, span, kind: hir::ItemKind::Static(..), ..
|
||||
}) => {
|
||||
let sym_str = sym.as_str();
|
||||
if self.get_declared_value(&sym_str).is_some() {
|
||||
|
@ -94,11 +94,11 @@ fn reachable_non_generics_provider(
|
||||
|
||||
// Only consider nodes that actually have exported symbols.
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Static(..),
|
||||
kind: hir::ItemKind::Static(..),
|
||||
..
|
||||
}) |
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(..), ..
|
||||
kind: hir::ItemKind::Fn(..), ..
|
||||
}) |
|
||||
Node::ImplItem(&hir::ImplItem {
|
||||
kind: hir::ImplItemKind::Method(..),
|
||||
@ -367,7 +367,7 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel
|
||||
// Emscripten cannot export statics, so reduce their export level here
|
||||
if tcx.sess.target.target.options.is_like_emscripten {
|
||||
if let Some(Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Static(..),
|
||||
kind: hir::ItemKind::Static(..),
|
||||
..
|
||||
})) = tcx.hir().get_if_local(sym_def_id) {
|
||||
return SymbolExportLevel::Rust;
|
||||
|
@ -30,7 +30,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
||||
}
|
||||
MonoItem::GlobalAsm(hir_id) => {
|
||||
let item = cx.tcx().hir().expect_item(hir_id);
|
||||
if let hir::ItemKind::GlobalAsm(ref ga) = item.node {
|
||||
if let hir::ItemKind::GlobalAsm(ref ga) = item.kind {
|
||||
cx.codegen_global_asm(ga);
|
||||
} else {
|
||||
span_bug!(item.span, "Mismatch between hir::Item type and MonoItem type")
|
||||
|
@ -327,7 +327,7 @@ impl DirtyCleanVisitor<'tcx> {
|
||||
let node = self.tcx.hir().get(item_id);
|
||||
let (name, labels) = match node {
|
||||
HirNode::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
// note: these are in the same order as hir::Item_;
|
||||
// FIXME(michaelwoerister): do commented out ones
|
||||
|
||||
@ -391,7 +391,7 @@ impl DirtyCleanVisitor<'tcx> {
|
||||
&format!(
|
||||
"clean/dirty auto-assertions not yet defined \
|
||||
for Node::Item.node={:?}",
|
||||
item.node
|
||||
item.kind
|
||||
)
|
||||
),
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ impl BoxPointers {
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::Fn(..) |
|
||||
hir::ItemKind::TyAlias(..) |
|
||||
hir::ItemKind::Enum(..) |
|
||||
@ -130,7 +130,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
|
||||
}
|
||||
|
||||
// If it's a struct, we also have to check the fields' types
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::Struct(ref struct_def, _) |
|
||||
hir::ItemKind::Union(ref struct_def, _) => {
|
||||
for struct_field in struct_def.fields() {
|
||||
@ -233,7 +233,7 @@ impl EarlyLintPass for UnsafeCode {
|
||||
}
|
||||
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, it: &ast::Item) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
ast::ItemKind::Trait(_, ast::Unsafety::Unsafe, ..) => {
|
||||
self.report_unsafe(cx, it.span, "declaration of an `unsafe` trait")
|
||||
}
|
||||
@ -391,7 +391,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
}
|
||||
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
let desc = match it.node {
|
||||
let desc = match it.kind {
|
||||
hir::ItemKind::Fn(..) => "a function",
|
||||
hir::ItemKind::Mod(..) => "a module",
|
||||
hir::ItemKind::Enum(..) => "an enum",
|
||||
@ -504,7 +504,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
|
||||
if !cx.access_levels.is_reachable(item.hir_id) {
|
||||
return;
|
||||
}
|
||||
let (def, ty) = match item.node {
|
||||
let (def, ty) = match item.kind {
|
||||
hir::ItemKind::Struct(_, ref ast_generics) => {
|
||||
if !ast_generics.params.is_empty() {
|
||||
return;
|
||||
@ -563,7 +563,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
|
||||
return;
|
||||
}
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Struct(..) |
|
||||
hir::ItemKind::Union(..) |
|
||||
hir::ItemKind::Enum(..) => {}
|
||||
@ -766,7 +766,7 @@ impl UnusedDocComment {
|
||||
|
||||
impl EarlyLintPass for UnusedDocComment {
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
|
||||
if let ast::ItemKind::Mac(..) = item.node {
|
||||
if let ast::ItemKind::Mac(..) = item.kind {
|
||||
self.warn_if_doc(cx, item.span, "macro expansions", true, &item.attrs);
|
||||
}
|
||||
}
|
||||
@ -809,7 +809,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
|
||||
return;
|
||||
}
|
||||
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::ExternCrate(..) => (),
|
||||
_ => return,
|
||||
};
|
||||
@ -849,7 +849,7 @@ declare_lint_pass!(InvalidNoMangleItems => [NO_MANGLE_CONST_ITEMS, NO_MANGLE_GEN
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::Fn(.., ref generics, _) => {
|
||||
if let Some(no_mangle_attr) = attr::find_by_name(&it.attrs, sym::no_mangle) {
|
||||
for param in &generics.params {
|
||||
@ -992,7 +992,7 @@ declare_lint_pass!(
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
|
||||
fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
if let hir::ItemKind::Union(ref vdata, _) = item.node {
|
||||
if let hir::ItemKind::Union(ref vdata, _) = item.kind {
|
||||
for field in vdata.fields() {
|
||||
let field_ty = ctx.tcx.type_of(
|
||||
ctx.tcx.hir().local_def_id(field.hir_id));
|
||||
@ -1137,7 +1137,7 @@ impl TypeAliasBounds {
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
let (ty, type_alias_generics) = match item.node {
|
||||
let (ty, type_alias_generics) = match item.kind {
|
||||
hir::ItemKind::TyAlias(ref ty, ref generics) => (&*ty, generics),
|
||||
_ => return,
|
||||
};
|
||||
@ -1204,7 +1204,7 @@ fn check_const(cx: &LateContext<'_, '_>, body_id: hir::BodyId) {
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::Const(_, body_id) => {
|
||||
check_const(cx, body_id);
|
||||
},
|
||||
@ -1395,7 +1395,7 @@ impl UnnameableTestItems {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestItems {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
if self.items_nameable {
|
||||
if let hir::ItemKind::Mod(..) = it.node {}
|
||||
if let hir::ItemKind::Mod(..) = it.kind {}
|
||||
else {
|
||||
self.items_nameable = false;
|
||||
self.boundary = it.hir_id;
|
||||
@ -1684,7 +1684,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
|
||||
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
if let hir::ItemKind::Struct(_, ref hir_generics)
|
||||
| hir::ItemKind::Enum(_, ref hir_generics)
|
||||
| hir::ItemKind::Union(_, ref hir_generics) = item.node
|
||||
| hir::ItemKind::Union(_, ref hir_generics) = item.kind
|
||||
{
|
||||
let inferred_outlives = cx.tcx.inferred_outlives_of(def_id);
|
||||
if inferred_outlives.is_empty() {
|
||||
@ -1812,7 +1812,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
|
||||
// generics, except for tuple struct, which have the `where`
|
||||
// after the fields of the struct.
|
||||
let full_where_span = if let hir::ItemKind::Struct(hir::VariantData::Tuple(..), _)
|
||||
= item.node
|
||||
= item.kind
|
||||
{
|
||||
where_span
|
||||
} else {
|
||||
|
@ -136,7 +136,7 @@ impl EarlyLintPass for NonCamelCaseTypes {
|
||||
return;
|
||||
}
|
||||
|
||||
match it.node {
|
||||
match it.kind {
|
||||
ast::ItemKind::TyAlias(..) |
|
||||
ast::ItemKind::Enum(..) |
|
||||
ast::ItemKind::Struct(..) |
|
||||
@ -326,7 +326,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
|
||||
}
|
||||
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
if let hir::ItemKind::Mod(_) = it.node {
|
||||
if let hir::ItemKind::Mod(_) = it.kind {
|
||||
self.check_snake_case(cx, "module", &it.ident);
|
||||
}
|
||||
}
|
||||
@ -387,7 +387,7 @@ impl NonUpperCaseGlobals {
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::Static(..) if !attr::contains_name(&it.attrs, sym::no_mangle) => {
|
||||
NonUpperCaseGlobals::check_upper_case(cx, "static variable", &it.ident);
|
||||
}
|
||||
|
@ -995,7 +995,7 @@ declare_lint_pass!(VariantSizeDifferences => [VARIANT_SIZE_DIFFERENCES]);
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
if let hir::ItemKind::Enum(ref enum_definition, _) = it.node {
|
||||
if let hir::ItemKind::Enum(ref enum_definition, _) = it.kind {
|
||||
let item_def_id = cx.tcx.hir().local_def_id(it.hir_id);
|
||||
let t = cx.tcx.type_of(item_def_id);
|
||||
let ty = cx.tcx.erase_regions(&t);
|
||||
|
@ -647,7 +647,7 @@ impl UnusedImportBraces {
|
||||
|
||||
impl EarlyLintPass for UnusedImportBraces {
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
|
||||
if let ast::ItemKind::Use(ref use_tree) = item.node {
|
||||
if let ast::ItemKind::Use(ref use_tree) = item.kind {
|
||||
self.check_use_tree(cx, use_tree, item);
|
||||
}
|
||||
}
|
||||
|
@ -999,7 +999,7 @@ impl<'a> CrateLoader<'a> {
|
||||
pub fn process_extern_crate(
|
||||
&mut self, item: &ast::Item, definitions: &Definitions,
|
||||
) -> CrateNum {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::ItemKind::ExternCrate(orig_name) => {
|
||||
debug!("resolving extern crate stmt. ident: {} orig_name: {:?}",
|
||||
item.ident, orig_name);
|
||||
|
@ -479,7 +479,7 @@ impl cstore::CStore {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: local_span,
|
||||
attrs: attrs.iter().cloned().collect(),
|
||||
node: ast::ItemKind::MacroDef(ast::MacroDef {
|
||||
kind: ast::ItemKind::MacroDef(ast::MacroDef {
|
||||
tokens: body.into(),
|
||||
legacy: def.legacy,
|
||||
}),
|
||||
|
@ -1117,7 +1117,7 @@ impl EncodeContext<'tcx> {
|
||||
|
||||
debug!("EncodeContext::encode_info_for_item({:?})", def_id);
|
||||
|
||||
let kind = match item.node {
|
||||
let kind = match item.kind {
|
||||
hir::ItemKind::Static(_, hir::MutMutable, _) => EntryKind::MutStatic,
|
||||
hir::ItemKind::Static(_, hir::MutImmutable, _) => EntryKind::ImmStatic,
|
||||
hir::ItemKind::Const(_, body_id) => {
|
||||
@ -1233,7 +1233,7 @@ impl EncodeContext<'tcx> {
|
||||
hir::ItemKind::Use(..) => bug!("cannot encode info for item {:?}", item),
|
||||
};
|
||||
|
||||
let mir = match item.node {
|
||||
let mir = match item.kind {
|
||||
hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => true,
|
||||
hir::ItemKind::Fn(_, header, ..) => {
|
||||
let generics = tcx.generics_of(def_id);
|
||||
@ -1252,7 +1252,7 @@ impl EncodeContext<'tcx> {
|
||||
visibility: self.lazy(ty::Visibility::from_hir(&item.vis, item.hir_id, tcx)),
|
||||
span: self.lazy(item.span),
|
||||
attributes: self.encode_attributes(&item.attrs),
|
||||
children: match item.node {
|
||||
children: match item.kind {
|
||||
hir::ItemKind::ForeignMod(ref fm) => {
|
||||
self.lazy(fm.items
|
||||
.iter()
|
||||
@ -1286,7 +1286,7 @@ impl EncodeContext<'tcx> {
|
||||
stability: self.encode_stability(def_id),
|
||||
deprecation: self.encode_deprecation(def_id),
|
||||
|
||||
ty: match item.node {
|
||||
ty: match item.kind {
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::Fn(..) |
|
||||
@ -1299,14 +1299,14 @@ impl EncodeContext<'tcx> {
|
||||
_ => None,
|
||||
},
|
||||
inherent_impls: self.encode_inherent_implementations(def_id),
|
||||
variances: match item.node {
|
||||
variances: match item.kind {
|
||||
hir::ItemKind::Enum(..) |
|
||||
hir::ItemKind::Struct(..) |
|
||||
hir::ItemKind::Union(..) |
|
||||
hir::ItemKind::Fn(..) => self.encode_variances_of(def_id),
|
||||
_ => Lazy::empty(),
|
||||
},
|
||||
generics: match item.node {
|
||||
generics: match item.kind {
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::Fn(..) |
|
||||
@ -1320,7 +1320,7 @@ impl EncodeContext<'tcx> {
|
||||
hir::ItemKind::TraitAlias(..) => Some(self.encode_generics(def_id)),
|
||||
_ => None,
|
||||
},
|
||||
predicates: match item.node {
|
||||
predicates: match item.kind {
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::Fn(..) |
|
||||
@ -1340,7 +1340,7 @@ impl EncodeContext<'tcx> {
|
||||
// so only encode it in that case as an efficiency
|
||||
// hack. (No reason not to expand it in the future if
|
||||
// necessary.)
|
||||
predicates_defined_on: match item.node {
|
||||
predicates_defined_on: match item.kind {
|
||||
hir::ItemKind::Trait(..) |
|
||||
hir::ItemKind::TraitAlias(..) => Some(self.encode_predicates_defined_on(def_id)),
|
||||
_ => None, // not *wrong* for other kinds of items, but not needed
|
||||
@ -1728,7 +1728,7 @@ impl Visitor<'tcx> for EncodeContext<'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
intravisit::walk_item(self, item);
|
||||
let def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(_) |
|
||||
hir::ItemKind::Use(..) => {} // ignore these
|
||||
_ => self.record(def_id, EncodeContext::encode_info_for_item, (def_id, item)),
|
||||
@ -1824,7 +1824,7 @@ impl EncodeContext<'tcx> {
|
||||
/// normally in the visitor walk.
|
||||
fn encode_addl_info_for_item(&mut self, item: &hir::Item) {
|
||||
let def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::Fn(..) |
|
||||
@ -1893,7 +1893,7 @@ struct ImplVisitor<'tcx> {
|
||||
|
||||
impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
if let hir::ItemKind::Impl(..) = item.node {
|
||||
if let hir::ItemKind::Impl(..) = item.kind {
|
||||
let impl_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) {
|
||||
self.impls
|
||||
|
@ -19,7 +19,7 @@ struct Collector<'tcx> {
|
||||
|
||||
impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
|
||||
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
let fm = match it.node {
|
||||
let fm = match it.kind {
|
||||
hir::ItemKind::ForeignMod(ref fm) => fm,
|
||||
_ => return,
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ struct Collector {
|
||||
|
||||
impl<'tcx> ItemLikeVisitor<'tcx> for Collector {
|
||||
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
let fm = match it.node {
|
||||
let fm = match it.kind {
|
||||
hir::ItemKind::ForeignMod(ref fm) => fm,
|
||||
_ => return,
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ struct Collector<'tcx> {
|
||||
|
||||
impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
|
||||
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
let fm = match it.node {
|
||||
let fm = match it.kind {
|
||||
hir::ItemKind::ForeignMod(ref fm) => fm,
|
||||
_ => return,
|
||||
};
|
||||
|
@ -28,7 +28,7 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
||||
// Figure out what primary body this item has.
|
||||
let (body_id, return_ty_span) = match tcx.hir().get(id) {
|
||||
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
|
||||
| Node::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. })
|
||||
| Node::Item(hir::Item { kind: hir::ItemKind::Fn(decl, _, _, body_id), .. })
|
||||
| Node::ImplItem(
|
||||
hir::ImplItem {
|
||||
kind: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id),
|
||||
@ -46,8 +46,8 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
||||
) => {
|
||||
(*body_id, decl.output.span())
|
||||
}
|
||||
Node::Item(hir::Item { node: hir::ItemKind::Static(ty, _, body_id), .. })
|
||||
| Node::Item(hir::Item { node: hir::ItemKind::Const(ty, body_id), .. })
|
||||
Node::Item(hir::Item { kind: hir::ItemKind::Static(ty, _, body_id), .. })
|
||||
| Node::Item(hir::Item { kind: hir::ItemKind::Const(ty, body_id), .. })
|
||||
| Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(ty, body_id), .. })
|
||||
| Node::TraitItem(
|
||||
hir::TraitItem { kind: hir::TraitItemKind::Const(ty, Some(body_id)), .. }
|
||||
|
@ -981,7 +981,7 @@ struct RootCollector<'a, 'tcx> {
|
||||
|
||||
impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
|
||||
fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(..) |
|
||||
hir::ItemKind::Use(..) |
|
||||
hir::ItemKind::ForeignMod(..) |
|
||||
@ -1141,7 +1141,7 @@ fn create_mono_items_for_default_impls<'tcx>(
|
||||
item: &'tcx hir::Item,
|
||||
output: &mut Vec<MonoItem<'tcx>>,
|
||||
) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Impl(_, _, _, ref generics, .., ref impl_item_refs) => {
|
||||
for param in &generics.params {
|
||||
match param.kind {
|
||||
|
@ -577,7 +577,7 @@ fn is_enclosed(
|
||||
if used_unsafe.contains(&parent_id) {
|
||||
Some(("block".to_string(), parent_id))
|
||||
} else if let Some(Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(_, header, _, _),
|
||||
kind: hir::ItemKind::Fn(_, header, _, _),
|
||||
..
|
||||
})) = tcx.hir().find(parent_id) {
|
||||
match header.unsafety {
|
||||
|
@ -538,7 +538,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
self.has_proc_macro_decls = true;
|
||||
}
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Impl(unsafety, polarity, _, _, Some(..), ref ty, ref impl_items) => {
|
||||
self.invalid_visibility(&item.vis, None);
|
||||
if let TyKind::Err = ty.kind {
|
||||
|
@ -31,7 +31,7 @@ impl ItemLikeVisitor<'tcx> for VarianceTest<'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let item_def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
|
||||
if let ItemKind::TyAlias(..) = item.node {
|
||||
if let ItemKind::TyAlias(..) = item.kind {
|
||||
for attr in self.tcx.get_attrs(item_def_id).iter() {
|
||||
if attr.check_name(sym::rustc_layout) {
|
||||
self.dump_layout_of(item_def_id, item, attr);
|
||||
|
@ -15,7 +15,7 @@ struct RegistrarFinder {
|
||||
|
||||
impl<'v> ItemLikeVisitor<'v> for RegistrarFinder {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
if let hir::ItemKind::Fn(..) = item.node {
|
||||
if let hir::ItemKind::Fn(..) = item.kind {
|
||||
if attr::contains_name(&item.attrs, sym::plugin_registrar) {
|
||||
self.registrars.push((item.hir_id, item.span));
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ fn def_id_visibility<'tcx>(
|
||||
}
|
||||
Node::ImplItem(impl_item) => {
|
||||
match tcx.hir().get(tcx.hir().get_parent_item(hir_id)) {
|
||||
Node::Item(item) => match &item.node {
|
||||
Node::Item(item) => match &item.kind {
|
||||
hir::ItemKind::Impl(.., None, _, _) => &impl_item.vis,
|
||||
hir::ItemKind::Impl(.., Some(trait_ref), _, _)
|
||||
=> return def_id_visibility(tcx, trait_ref.path.res.def_id()),
|
||||
@ -572,7 +572,7 @@ impl EmbargoVisitor<'tcx> {
|
||||
if let ty::Visibility::Public = vis {
|
||||
let item = self.tcx.hir().expect_item(hir_id);
|
||||
if let hir::ItemKind::Struct(ref struct_def, _)
|
||||
| hir::ItemKind::Union(ref struct_def, _) = item.node
|
||||
| hir::ItemKind::Union(ref struct_def, _) = item.kind
|
||||
{
|
||||
for field in struct_def.fields() {
|
||||
let field_vis = ty::Visibility::from_hir(
|
||||
@ -630,12 +630,12 @@ impl EmbargoVisitor<'tcx> {
|
||||
.and_then(|def_id| self.tcx.hir().as_local_hir_id(def_id))
|
||||
.map(|module_hir_id| self.tcx.hir().expect_item(module_hir_id))
|
||||
{
|
||||
if let hir::ItemKind::Mod(m) = &item.node {
|
||||
if let hir::ItemKind::Mod(m) = &item.kind {
|
||||
for item_id in m.item_ids.as_ref() {
|
||||
let item = self.tcx.hir().expect_item(item_id.id);
|
||||
let def_id = self.tcx.hir().local_def_id(item_id.id);
|
||||
if !self.tcx.hygienic_eq(segment.ident, item.ident, def_id) { continue; }
|
||||
if let hir::ItemKind::Use(..) = item.node {
|
||||
if let hir::ItemKind::Use(..) = item.kind {
|
||||
self.update(item.hir_id, Some(AccessLevel::Exported));
|
||||
}
|
||||
}
|
||||
@ -653,7 +653,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let inherited_item_level = match item.node {
|
||||
let inherited_item_level = match item.kind {
|
||||
hir::ItemKind::Impl(..) =>
|
||||
Option::<AccessLevel>::of_impl(item.hir_id, self.tcx, &self.access_levels),
|
||||
// Foreign modules inherit level from parents.
|
||||
@ -673,7 +673,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
let item_level = self.update(item.hir_id, inherited_item_level);
|
||||
|
||||
// Update levels of nested things.
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Enum(ref def, _) => {
|
||||
for variant in &def.variants {
|
||||
let variant_level = self.update(variant.id, item_level);
|
||||
@ -727,7 +727,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
}
|
||||
|
||||
// Mark all items in interfaces of reachable items as reachable.
|
||||
match item.node {
|
||||
match item.kind {
|
||||
// The interface is empty.
|
||||
hir::ItemKind::ExternCrate(..) => {}
|
||||
// All nested items are checked by `visit_item`.
|
||||
@ -1417,7 +1417,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
// Contents of a private mod can be re-exported, so we need
|
||||
// to check internals.
|
||||
hir::ItemKind::Mod(_) => {}
|
||||
@ -1853,7 +1853,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||
let tcx = self.tcx;
|
||||
let item_visibility = ty::Visibility::from_hir(&item.vis, item.hir_id, tcx);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
// Crates are always public.
|
||||
hir::ItemKind::ExternCrate(..) => {}
|
||||
// All nested items are checked by `visit_item`.
|
||||
|
@ -588,7 +588,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||
let sp = item.span;
|
||||
let vis = self.resolve_visibility(&item.vis);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Use(ref use_tree) => {
|
||||
self.build_reduced_graph_for_use_tree(
|
||||
// This particular use tree
|
||||
@ -936,7 +936,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||
span_err!(self.r.session, item.span, E0468,
|
||||
"an `extern crate` loading macros must be at the crate root");
|
||||
}
|
||||
if let ItemKind::ExternCrate(Some(orig_name)) = item.node {
|
||||
if let ItemKind::ExternCrate(Some(orig_name)) = item.kind {
|
||||
if orig_name == kw::SelfLower {
|
||||
self.r.session.span_err(attr.span,
|
||||
"`macro_use` is not supported on `extern crate self`");
|
||||
@ -1064,7 +1064,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||
fn define_macro(&mut self, item: &ast::Item) -> LegacyScope<'a> {
|
||||
let parent_scope = &self.parent_scope;
|
||||
let expansion = parent_scope.expansion;
|
||||
let (ext, ident, span, is_legacy) = match &item.node {
|
||||
let (ext, ident, span, is_legacy) = match &item.kind {
|
||||
ItemKind::MacroDef(def) => {
|
||||
let ext = Lrc::new(self.r.compile_macro(item, self.r.session.edition()));
|
||||
(ext, item.ident, item.span, def.legacy)
|
||||
@ -1138,7 +1138,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
||||
method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty);
|
||||
|
||||
fn visit_item(&mut self, item: &'b Item) {
|
||||
let macro_use = match item.node {
|
||||
let macro_use = match item.kind {
|
||||
ItemKind::MacroDef(..) => {
|
||||
self.parent_scope.legacy = self.define_macro(item);
|
||||
return
|
||||
|
@ -103,7 +103,7 @@ impl<'a, 'b> Visitor<'a> for UnusedImportCheckVisitor<'a, 'b> {
|
||||
// whether they're used or not. Also ignore imports with a dummy span
|
||||
// because this means that they were generated in some fashion by the
|
||||
// compiler and we don't need to consider them.
|
||||
if let ast::ItemKind::Use(..) = item.node {
|
||||
if let ast::ItemKind::Use(..) = item.kind {
|
||||
if item.vis.node.is_pub() || item.span.is_dummy() {
|
||||
return;
|
||||
}
|
||||
|
@ -700,9 +700,9 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
||||
|
||||
fn resolve_item(&mut self, item: &Item) {
|
||||
let name = item.ident.name;
|
||||
debug!("(resolving item) resolving {} ({:?})", name, item.node);
|
||||
debug!("(resolving item) resolving {} ({:?})", name, item.kind);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::TyAlias(_, ref generics) |
|
||||
ItemKind::OpaqueTy(_, ref generics) |
|
||||
ItemKind::Fn(_, _, ref generics, _) => {
|
||||
@ -1805,7 +1805,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
||||
// Descend into the block.
|
||||
for stmt in &block.stmts {
|
||||
if let StmtKind::Item(ref item) = stmt.kind {
|
||||
if let ItemKind::MacroDef(..) = item.node {
|
||||
if let ItemKind::MacroDef(..) = item.kind {
|
||||
num_macro_definition_ribs += 1;
|
||||
let res = self.r.definitions.local_def_id(item.id);
|
||||
self.ribs[ValueNS].push(Rib::new(MacroDefinition(res)));
|
||||
|
@ -290,7 +290,7 @@ impl<'tcx> Visitor<'tcx> for UsePlacementFinder {
|
||||
}
|
||||
// find a use statement
|
||||
for item in &module.items {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Use(..) => {
|
||||
// don't suggest placing a use before the prelude
|
||||
// import or other generated ones
|
||||
|
@ -472,13 +472,13 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
|
||||
let kind = match item.node {
|
||||
let kind = match item.kind {
|
||||
ast::ItemKind::Struct(_, _) => DefKind::Struct,
|
||||
ast::ItemKind::Union(_, _) => DefKind::Union,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let (value, fields) = match item.node {
|
||||
let (value, fields) = match item.kind {
|
||||
ast::ItemKind::Struct(ast::VariantData::Struct(ref fields, ..), ..) |
|
||||
ast::ItemKind::Union(ast::VariantData::Struct(ref fields, ..), ..) => {
|
||||
let include_priv_fields = !self.save_ctxt.config.pub_only;
|
||||
@ -1276,7 +1276,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'l ast::Item) {
|
||||
use syntax::ast::ItemKind::*;
|
||||
self.process_macro_use(item.span);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
Use(ref use_tree) => {
|
||||
let prefix = ast::Path {
|
||||
segments: vec![],
|
||||
|
@ -177,7 +177,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::ItemKind::Fn(ref decl, .., ref generics, _) => {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
@ -396,7 +396,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||
let (qualname, parent_scope, decl_id, docs, attributes) =
|
||||
match self.tcx.impl_of_method(self.tcx.hir().local_def_id_from_node_id(id)) {
|
||||
Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) {
|
||||
Some(Node::Item(item)) => match item.node {
|
||||
Some(Node::Item(item)) => match item.kind {
|
||||
hir::ItemKind::Impl(.., ref ty, _) => {
|
||||
let mut qualname = String::from("<");
|
||||
qualname.push_str(&self.tcx.hir().hir_to_pretty_string(ty.hir_id));
|
||||
@ -612,7 +612,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||
Node::TraitRef(tr) => tr.path.res,
|
||||
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Use(ref path, _),
|
||||
kind: hir::ItemKind::Use(ref path, _),
|
||||
..
|
||||
}) |
|
||||
Node::Visibility(&Spanned {
|
||||
|
@ -324,7 +324,7 @@ impl Sig for ast::Item {
|
||||
fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
|
||||
let id = Some(self.id);
|
||||
|
||||
match self.node {
|
||||
match self.kind {
|
||||
ast::ItemKind::Static(ref ty, m, ref expr) => {
|
||||
let mut text = "static ".to_owned();
|
||||
if m == ast::Mutability::Mutable {
|
||||
|
@ -205,7 +205,7 @@ crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> {
|
||||
_ => NodeKind::Other,
|
||||
}
|
||||
|
||||
Node::Item(item) => match item.node {
|
||||
Node::Item(item) => match item.kind {
|
||||
ItemKind::Impl(.., Some(..), _, _) => NodeKind::TraitImpl,
|
||||
ItemKind::Impl(.., None, _, _) => NodeKind::InherentImpl,
|
||||
ItemKind::Fn(..) => NodeKind::Fn,
|
||||
|
@ -248,7 +248,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
),
|
||||
);
|
||||
if let (Some(expr), Item(hir::Item {
|
||||
node: hir::ItemKind::Fn(..), ..
|
||||
kind: hir::ItemKind::Fn(..), ..
|
||||
})) = (&block.expr, parent) {
|
||||
// check that the `if` expr without `else` is the fn body's expr
|
||||
if expr.span == span {
|
||||
|
@ -895,7 +895,7 @@ fn compute_all_traits(tcx: TyCtxt<'_>) -> Vec<DefId> {
|
||||
|
||||
impl<'v, 'a, 'tcx> itemlikevisit::ItemLikeVisitor<'v> for Visitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &'v hir::Item) {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
hir::ItemKind::Trait(..) |
|
||||
hir::ItemKind::TraitAlias(..) => {
|
||||
let def_id = self.map.local_def_id(i.hir_id);
|
||||
@ -999,7 +999,7 @@ impl hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'tcx> {
|
||||
// Find a `use` statement.
|
||||
for item_id in &module.item_ids {
|
||||
let item = self.tcx.hir().expect_item(item_id.id);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Use(..) => {
|
||||
// Don't suggest placing a `use` before the prelude
|
||||
// import or other generated ones.
|
||||
|
@ -792,7 +792,7 @@ fn primary_body_of(
|
||||
) -> Option<(hir::BodyId, Option<&hir::Ty>, Option<&hir::FnHeader>, Option<&hir::FnDecl>)> {
|
||||
match tcx.hir().get(id) {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Const(ref ty, body) |
|
||||
hir::ItemKind::Static(ref ty, _, body) =>
|
||||
Some((body, Some(ty), None, None)),
|
||||
@ -1262,7 +1262,7 @@ fn check_fn<'a, 'tcx>(
|
||||
}
|
||||
|
||||
if let Node::Item(item) = fcx.tcx.hir().get(fn_id) {
|
||||
if let ItemKind::Fn(_, _, ref generics, _) = item.node {
|
||||
if let ItemKind::Fn(_, _, ref generics, _) = item.kind {
|
||||
if !generics.params.is_empty() {
|
||||
fcx.tcx.sess.span_err(
|
||||
span,
|
||||
@ -1310,7 +1310,7 @@ fn check_fn<'a, 'tcx>(
|
||||
}
|
||||
|
||||
if let Node::Item(item) = fcx.tcx.hir().get(fn_id) {
|
||||
if let ItemKind::Fn(_, _, ref generics, _) = item.node {
|
||||
if let ItemKind::Fn(_, _, ref generics, _) = item.kind {
|
||||
if !generics.params.is_empty() {
|
||||
fcx.tcx.sess.span_err(
|
||||
span,
|
||||
@ -1403,7 +1403,7 @@ fn check_opaque_for_inheriting_lifetimes(
|
||||
}
|
||||
}
|
||||
|
||||
let prohibit_opaque = match item.node {
|
||||
let prohibit_opaque = match item.kind {
|
||||
ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::AsyncFn, .. }) |
|
||||
ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn, .. }) => {
|
||||
let mut visitor = ProhibitOpaqueVisitor {
|
||||
@ -1421,7 +1421,7 @@ fn check_opaque_for_inheriting_lifetimes(
|
||||
|
||||
debug!("check_opaque_for_inheriting_lifetimes: prohibit_opaque={:?}", prohibit_opaque);
|
||||
if prohibit_opaque {
|
||||
let is_async = match item.node {
|
||||
let is_async = match item.kind {
|
||||
ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => match origin {
|
||||
hir::OpaqueTyOrigin::AsyncFn => true,
|
||||
_ => false,
|
||||
@ -1485,7 +1485,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item) {
|
||||
tcx.def_path_str(tcx.hir().local_def_id(it.hir_id))
|
||||
);
|
||||
let _indenter = indenter();
|
||||
match it.node {
|
||||
match it.kind {
|
||||
// Consts can play a role in type-checking, so they are included here.
|
||||
hir::ItemKind::Static(..) => {
|
||||
let def_id = tcx.hir().local_def_id(it.hir_id);
|
||||
@ -4069,7 +4069,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let node = self.tcx.hir().get(self.tcx.hir().get_parent_item(id));
|
||||
match node {
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(_, _, _, body_id), ..
|
||||
kind: hir::ItemKind::Fn(_, _, _, body_id), ..
|
||||
}) |
|
||||
Node::ImplItem(&hir::ImplItem {
|
||||
kind: hir::ImplItemKind::Method(_, body_id), ..
|
||||
@ -4094,7 +4094,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
fn get_node_fn_decl(&self, node: Node<'tcx>) -> Option<(&'tcx hir::FnDecl, ast::Ident, bool)> {
|
||||
match node {
|
||||
Node::Item(&hir::Item {
|
||||
ident, node: hir::ItemKind::Fn(ref decl, ..), ..
|
||||
ident, kind: hir::ItemKind::Fn(ref decl, ..), ..
|
||||
}) => {
|
||||
// This is less than ideal, it will not suggest a return type span on any
|
||||
// method called `main`, regardless of whether it is actually the entry point,
|
||||
@ -4192,7 +4192,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let mut msg = "call this function";
|
||||
match hir.get_if_local(def_id) {
|
||||
Some(Node::Item(hir::Item {
|
||||
node: ItemKind::Fn(.., body_id),
|
||||
kind: ItemKind::Fn(.., body_id),
|
||||
..
|
||||
})) |
|
||||
Some(Node::ImplItem(hir::ImplItem {
|
||||
|
@ -76,7 +76,7 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: DefId) {
|
||||
item.hir_id,
|
||||
tcx.def_path_str(def_id));
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
// Right now we check that every default trait implementation
|
||||
// has an implementation of itself. Basically, a case like:
|
||||
//
|
||||
@ -299,7 +299,7 @@ fn check_type_defn<'tcx, F>(
|
||||
field.span,
|
||||
fcx.body_id,
|
||||
traits::FieldSized {
|
||||
adt_kind: match item.node.adt_kind() {
|
||||
adt_kind: match item.kind.adt_kind() {
|
||||
Some(i) => i,
|
||||
None => bug!(),
|
||||
},
|
||||
|
@ -33,7 +33,7 @@ impl ItemLikeVisitor<'v> for CheckVisitor<'tcx> {
|
||||
if item.vis.node.is_pub() || item.span.is_dummy() {
|
||||
return;
|
||||
}
|
||||
if let hir::ItemKind::Use(ref path, _) = item.node {
|
||||
if let hir::ItemKind::Use(ref path, _) = item.kind {
|
||||
self.check_import(item.hir_id, path.span);
|
||||
}
|
||||
}
|
||||
@ -218,7 +218,7 @@ struct ExternCrateToLint {
|
||||
|
||||
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CollectExternCrateVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
if let hir::ItemKind::ExternCrate(orig_name) = item.node {
|
||||
if let hir::ItemKind::ExternCrate(orig_name) = item.kind {
|
||||
let extern_crate_def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
self.crates_to_lint.push(
|
||||
ExternCrateToLint {
|
||||
|
@ -53,7 +53,7 @@ fn visit_implementation_of_drop(tcx: TyCtxt<'_>, impl_did: DefId) {
|
||||
// Destructors only work on nominal types.
|
||||
if let Some(impl_hir_id) = tcx.hir().as_local_hir_id(impl_did) {
|
||||
if let Some(Node::Item(item)) = tcx.hir().find(impl_hir_id) {
|
||||
let span = match item.node {
|
||||
let span = match item.kind {
|
||||
ItemKind::Impl(.., ref ty, _) => ty.span,
|
||||
_ => item.span,
|
||||
};
|
||||
@ -99,7 +99,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: DefId) {
|
||||
Ok(()) => {}
|
||||
Err(CopyImplementationError::InfrigingFields(fields)) => {
|
||||
let item = tcx.hir().expect_item(impl_hir_id);
|
||||
let span = if let ItemKind::Impl(.., Some(ref tr), _, _) = item.node {
|
||||
let span = if let ItemKind::Impl(.., Some(ref tr), _, _) = item.kind {
|
||||
tr.path.span
|
||||
} else {
|
||||
span
|
||||
@ -116,7 +116,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: DefId) {
|
||||
}
|
||||
Err(CopyImplementationError::NotAnAdt) => {
|
||||
let item = tcx.hir().expect_item(impl_hir_id);
|
||||
let span = if let ItemKind::Impl(.., ref ty, _) = item.node {
|
||||
let span = if let ItemKind::Impl(.., ref ty, _) = item.kind {
|
||||
ty.span
|
||||
} else {
|
||||
span
|
||||
@ -481,7 +481,7 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
|
||||
return err_info;
|
||||
} else if diff_fields.len() > 1 {
|
||||
let item = gcx.hir().expect_item(impl_hir_id);
|
||||
let span = if let ItemKind::Impl(.., Some(ref t), _, _) = item.node {
|
||||
let span = if let ItemKind::Impl(.., Some(ref t), _, _) = item.kind {
|
||||
t.path.span
|
||||
} else {
|
||||
gcx.hir().span(impl_hir_id)
|
||||
|
@ -49,7 +49,7 @@ struct InherentCollect<'tcx> {
|
||||
|
||||
impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
let ty = match item.node {
|
||||
let ty = match item.kind {
|
||||
hir::ItemKind::Impl(.., None, ref ty, _) => ty,
|
||||
_ => return
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ impl InherentOverlapChecker<'tcx> {
|
||||
|
||||
impl ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> {
|
||||
fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Enum(..) |
|
||||
hir::ItemKind::Struct(..) |
|
||||
hir::ItemKind::Trait(..) |
|
||||
|
@ -24,7 +24,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
let def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
// "Trait" impl
|
||||
if let hir::ItemKind::Impl(.., Some(_), _, _) = item.node {
|
||||
if let hir::ItemKind::Impl(.., Some(_), _, _) = item.kind {
|
||||
debug!("coherence2::orphan check: trait impl {}",
|
||||
self.tcx.hir().node_to_string(item.hir_id));
|
||||
let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap();
|
||||
|
@ -71,7 +71,7 @@ impl UnsafetyChecker<'tcx> {
|
||||
|
||||
impl ItemLikeVisitor<'v> for UnsafetyChecker<'tcx> {
|
||||
fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
if let hir::ItemKind::Impl(unsafety, polarity, _, ref generics, ..) = item.node {
|
||||
if let hir::ItemKind::Impl(unsafety, polarity, _, ref generics, ..) = item.kind {
|
||||
self.check_unsafety_coherence(item, Some(generics), unsafety, polarity);
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ fn type_param_predicates(
|
||||
Node::ImplItem(item) => &item.generics,
|
||||
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(.., ref generics, _)
|
||||
| ItemKind::Impl(_, _, _, ref generics, ..)
|
||||
| ItemKind::TyAlias(_, ref generics)
|
||||
@ -403,7 +403,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
|
||||
let it = tcx.hir().expect_item(item_id);
|
||||
debug!("convert: item {} with id {}", it.ident, it.hir_id);
|
||||
let def_id = tcx.hir().local_def_id(item_id);
|
||||
match it.node {
|
||||
match it.kind {
|
||||
// These don't define types.
|
||||
hir::ItemKind::ExternCrate(_)
|
||||
| hir::ItemKind::Use(..)
|
||||
@ -474,7 +474,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
|
||||
tcx.generics_of(def_id);
|
||||
tcx.type_of(def_id);
|
||||
tcx.predicates_of(def_id);
|
||||
if let hir::ItemKind::Fn(..) = it.node {
|
||||
if let hir::ItemKind::Fn(..) = it.kind {
|
||||
tcx.fn_sig(def_id);
|
||||
}
|
||||
}
|
||||
@ -638,7 +638,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::AdtDef {
|
||||
};
|
||||
|
||||
let repr = ReprOptions::new(tcx, def_id);
|
||||
let (kind, variants) = match item.node {
|
||||
let (kind, variants) = match item.kind {
|
||||
ItemKind::Enum(ref def, _) => {
|
||||
let mut distance_from_explicit = 0;
|
||||
let variants = def.variants
|
||||
@ -707,7 +707,7 @@ fn super_predicates_of(
|
||||
_ => bug!("trait_node_id {} is not an item", trait_hir_id),
|
||||
};
|
||||
|
||||
let (generics, bounds) = match item.node {
|
||||
let (generics, bounds) = match item.kind {
|
||||
hir::ItemKind::Trait(.., ref generics, ref supertraits, _) => (generics, supertraits),
|
||||
hir::ItemKind::TraitAlias(ref generics, ref supertraits) => (generics, supertraits),
|
||||
_ => span_bug!(item.span, "super_predicates invoked on non-trait"),
|
||||
@ -753,7 +753,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::TraitDef {
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let item = tcx.hir().expect_item(hir_id);
|
||||
|
||||
let (is_auto, unsafety) = match item.node {
|
||||
let (is_auto, unsafety) = match item.kind {
|
||||
hir::ItemKind::Trait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety),
|
||||
hir::ItemKind::TraitAlias(..) => (false, hir::Unsafety::Normal),
|
||||
_ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"),
|
||||
@ -878,7 +878,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<S
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
Node::Item(item) => match item.node {
|
||||
Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Fn(ref fn_decl, .., ref generics, _) => {
|
||||
has_late_bound_regions(tcx, generics, fn_decl)
|
||||
}
|
||||
@ -918,7 +918,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
||||
kind: hir::ExprKind::Closure(..),
|
||||
..
|
||||
}) => Some(tcx.closure_base_def_id(def_id)),
|
||||
Node::Item(item) => match item.node {
|
||||
Node::Item(item) => match item.kind {
|
||||
ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn, .. }) => impl_trait_fn,
|
||||
_ => None,
|
||||
},
|
||||
@ -935,7 +935,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
||||
Node::ImplItem(item) => &item.generics,
|
||||
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(.., ref generics, _) | ItemKind::Impl(_, _, _, ref generics, ..) => {
|
||||
generics
|
||||
}
|
||||
@ -1265,7 +1265,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
|
||||
},
|
||||
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Static(ref ty, .., body_id)
|
||||
| ItemKind::Const(ref ty, body_id) => {
|
||||
if let hir::TyKind::Infer = ty.kind {
|
||||
@ -1325,7 +1325,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
|
||||
span_bug!(
|
||||
item.span,
|
||||
"compute_type_of_item: unexpected item type: {:?}",
|
||||
item.node
|
||||
item.kind
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1794,7 +1794,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||
..
|
||||
})
|
||||
| Item(hir::Item {
|
||||
node: ItemKind::Fn(decl, header, _, _),
|
||||
kind: ItemKind::Fn(decl, header, _, _),
|
||||
..
|
||||
}) => match get_infer_ret_ty(&decl.output) {
|
||||
Some(ty) => {
|
||||
@ -1878,7 +1878,7 @@ fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::TraitRef<'_>> {
|
||||
let icx = ItemCtxt::new(tcx, def_id);
|
||||
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
match tcx.hir().expect_item(hir_id).node {
|
||||
match tcx.hir().expect_item(hir_id).kind {
|
||||
hir::ItemKind::Impl(.., ref opt_trait_ref, _, _) => {
|
||||
opt_trait_ref.as_ref().map(|ast_trait_ref| {
|
||||
let selfty = tcx.type_of(def_id);
|
||||
@ -1893,7 +1893,7 @@ fn impl_polarity(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ImplPolarity {
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let is_rustc_reservation = tcx.has_attr(def_id, sym::rustc_reservation_impl);
|
||||
let item = tcx.hir().expect_item(hir_id);
|
||||
match &item.node {
|
||||
match &item.kind {
|
||||
hir::ItemKind::Impl(_, hir::ImplPolarity::Negative, ..) => {
|
||||
if is_rustc_reservation {
|
||||
tcx.sess.span_err(item.span, "reservation impls can't be negative");
|
||||
@ -2076,7 +2076,7 @@ fn explicit_predicates_of(
|
||||
},
|
||||
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Impl(_, _, defaultness, ref generics, ..) => {
|
||||
if defaultness.is_default() {
|
||||
is_default_impl_trait = tcx.impl_trait_ref(def_id);
|
||||
@ -2310,7 +2310,7 @@ fn explicit_predicates_of(
|
||||
// in trait checking. See `setup_constraining_predicates`
|
||||
// for details.
|
||||
if let Node::Item(&Item {
|
||||
node: ItemKind::Impl(..),
|
||||
kind: ItemKind::Impl(..),
|
||||
..
|
||||
}) = node
|
||||
{
|
||||
@ -2417,7 +2417,7 @@ fn is_foreign_item(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
fn static_mutability(tcx: TyCtxt<'_>, def_id: DefId) -> Option<hir::Mutability> {
|
||||
match tcx.hir().get_if_local(def_id) {
|
||||
Some(Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Static(_, mutbl, _), ..
|
||||
kind: hir::ItemKind::Static(_, mutbl, _), ..
|
||||
})) |
|
||||
Some(Node::ForeignItem( &hir::ForeignItem {
|
||||
node: hir::ForeignItemKind::Static(_, mutbl), ..
|
||||
|
@ -78,7 +78,7 @@ struct ImplWfCheck<'tcx> {
|
||||
|
||||
impl ItemLikeVisitor<'tcx> for ImplWfCheck<'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
if let hir::ItemKind::Impl(.., ref impl_item_refs) = item.node {
|
||||
if let hir::ItemKind::Impl(.., ref impl_item_refs) = item.kind {
|
||||
let impl_def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
enforce_impl_params_are_constrained(self.tcx,
|
||||
impl_def_id,
|
||||
|
@ -162,7 +162,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
||||
match main_t.kind {
|
||||
ty::FnDef(..) => {
|
||||
if let Some(Node::Item(it)) = tcx.hir().find(main_id) {
|
||||
if let hir::ItemKind::Fn(.., ref generics, _) = it.node {
|
||||
if let hir::ItemKind::Fn(.., ref generics, _) = it.kind {
|
||||
let mut error = false;
|
||||
if !generics.params.is_empty() {
|
||||
let msg = "`main` function is not allowed to have generic \
|
||||
@ -227,7 +227,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
|
||||
match start_t.kind {
|
||||
ty::FnDef(..) => {
|
||||
if let Some(Node::Item(it)) = tcx.hir().find(start_id) {
|
||||
if let hir::ItemKind::Fn(.., ref generics, _) = it.node {
|
||||
if let hir::ItemKind::Fn(.., ref generics, _) = it.kind {
|
||||
let mut error = false;
|
||||
if !generics.params.is_empty() {
|
||||
struct_span_err!(tcx.sess, generics.span, E0132,
|
||||
|
@ -66,7 +66,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
|
||||
};
|
||||
|
||||
let mut item_required_predicates = RequiredPredicates::default();
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Union(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) => {
|
||||
let adt_def = self.tcx.adt_def(item_did);
|
||||
|
||||
|
@ -30,7 +30,7 @@ fn inferred_outlives_of(
|
||||
.expect("expected local def-id");
|
||||
|
||||
match tcx.hir().get(id) {
|
||||
Node::Item(item) => match item.node {
|
||||
Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => {
|
||||
let crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE);
|
||||
|
||||
|
@ -68,7 +68,7 @@ pub fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>)
|
||||
|
||||
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Struct(ref struct_def, _) |
|
||||
hir::ItemKind::Union(ref struct_def, _) => {
|
||||
self.visit_node_helper(item.hir_id);
|
||||
|
@ -49,7 +49,7 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] {
|
||||
span_bug!(tcx.hir().span(id), "asked to compute variance for wrong kind of item")
|
||||
};
|
||||
match tcx.hir().get(id) {
|
||||
Node::Item(item) => match item.node {
|
||||
Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Enum(..) |
|
||||
hir::ItemKind::Struct(..) |
|
||||
hir::ItemKind::Union(..) |
|
||||
|
@ -131,7 +131,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
|
||||
debug!("add_inferreds for item {}",
|
||||
self.tcx.hir().node_to_string(item.hir_id));
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Struct(ref struct_def, _) |
|
||||
hir::ItemKind::Union(ref struct_def, _) => {
|
||||
self.add_inferreds_for_item(item.hir_id);
|
||||
|
@ -333,7 +333,7 @@ pub fn build_impl(cx: &DocContext<'_>, did: DefId, attrs: Option<Attrs<'_>>,
|
||||
}
|
||||
|
||||
let for_ = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
|
||||
match tcx.hir().expect_item(hir_id).node {
|
||||
match tcx.hir().expect_item(hir_id).kind {
|
||||
hir::ItemKind::Impl(.., ref t, _) => {
|
||||
t.clean(cx)
|
||||
}
|
||||
@ -355,7 +355,7 @@ pub fn build_impl(cx: &DocContext<'_>, did: DefId, attrs: Option<Attrs<'_>>,
|
||||
|
||||
let predicates = tcx.explicit_predicates_of(did);
|
||||
let (trait_items, generics) = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
|
||||
match tcx.hir().expect_item(hir_id).node {
|
||||
match tcx.hir().expect_item(hir_id).kind {
|
||||
hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => {
|
||||
(
|
||||
item_ids.iter()
|
||||
@ -481,7 +481,7 @@ fn build_macro(cx: &DocContext<'_>, did: DefId, name: ast::Name) -> clean::ItemE
|
||||
let imported_from = cx.tcx.original_crate_name(did.krate);
|
||||
match cx.cstore.load_macro_untracked(did, cx.sess()) {
|
||||
LoadedMacro::MacroDef(def) => {
|
||||
let matchers: hir::HirVec<Span> = if let ast::ItemKind::MacroDef(ref def) = def.node {
|
||||
let matchers: hir::HirVec<Span> = if let ast::ItemKind::MacroDef(ref def) = def.kind {
|
||||
let tts: Vec<_> = def.stream().into_trees().collect();
|
||||
tts.chunks(4).map(|arm| arm[0].span()).collect()
|
||||
} else {
|
||||
|
@ -275,7 +275,7 @@ impl Clean<ExternalCrate> for CrateNum {
|
||||
let primitives = if root.is_local() {
|
||||
cx.tcx.hir().krate().module.item_ids.iter().filter_map(|&id| {
|
||||
let item = cx.tcx.hir().expect_item(id.id);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Mod(_) => {
|
||||
as_primitive(Res::Def(
|
||||
DefKind::Mod,
|
||||
@ -319,7 +319,7 @@ impl Clean<ExternalCrate> for CrateNum {
|
||||
let keywords = if root.is_local() {
|
||||
cx.tcx.hir().krate().module.item_ids.iter().filter_map(|&id| {
|
||||
let item = cx.tcx.hir().expect_item(id.id);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Mod(_) => {
|
||||
as_keyword(Res::Def(
|
||||
DefKind::Mod,
|
||||
@ -2868,7 +2868,7 @@ impl Clean<Type> for hir::Ty {
|
||||
TyKind::Tup(ref tys) => Tuple(tys.clean(cx)),
|
||||
TyKind::Def(item_id, _) => {
|
||||
let item = cx.tcx.hir().expect_item(item_id.id);
|
||||
if let hir::ItemKind::OpaqueTy(ref ty) = item.node {
|
||||
if let hir::ItemKind::OpaqueTy(ref ty) = item.kind {
|
||||
ImplTrait(ty.bounds.clean(cx))
|
||||
} else {
|
||||
unreachable!()
|
||||
@ -2889,7 +2889,7 @@ impl Clean<Type> for hir::Ty {
|
||||
// Substitute private type aliases
|
||||
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) {
|
||||
if !cx.renderinfo.borrow().access_levels.is_exported(def_id) {
|
||||
alias = Some(&cx.tcx.hir().expect_item(hir_id).node);
|
||||
alias = Some(&cx.tcx.hir().expect_item(hir_id).kind);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -425,7 +425,7 @@ pub fn make_test(s: &str,
|
||||
match parser.parse_item() {
|
||||
Ok(Some(item)) => {
|
||||
if !found_main {
|
||||
if let ast::ItemKind::Fn(..) = item.node {
|
||||
if let ast::ItemKind::Fn(..) = item.kind {
|
||||
if item.ident.name == sym::main {
|
||||
found_main = true;
|
||||
}
|
||||
@ -433,7 +433,7 @@ pub fn make_test(s: &str,
|
||||
}
|
||||
|
||||
if !found_extern_crate {
|
||||
if let ast::ItemKind::ExternCrate(original) = item.node {
|
||||
if let ast::ItemKind::ExternCrate(original) = item.kind {
|
||||
// This code will never be reached if `cratename` is none because
|
||||
// `found_extern_crate` is initialized to `true` if it is none.
|
||||
let cratename = cratename.unwrap();
|
||||
@ -446,7 +446,7 @@ pub fn make_test(s: &str,
|
||||
}
|
||||
|
||||
if !found_macro {
|
||||
if let ast::ItemKind::Mac(..) = item.node {
|
||||
if let ast::ItemKind::Mac(..) = item.kind {
|
||||
found_macro = true;
|
||||
}
|
||||
}
|
||||
@ -882,7 +882,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> {
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'hir hir::Item) {
|
||||
let name = if let hir::ItemKind::Impl(.., ref ty, _) = item.node {
|
||||
let name = if let hir::ItemKind::Impl(.., ref ty, _) = item.kind {
|
||||
self.map.hir_to_pretty_string(ty.hir_id)
|
||||
} else {
|
||||
item.ident.to_string()
|
||||
|
@ -320,7 +320,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
if !self.view_item_stack.insert(res_hir_id) { return false }
|
||||
|
||||
let ret = match tcx.hir().get(res_hir_id) {
|
||||
Node::Item(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => {
|
||||
Node::Item(&hir::Item { kind: hir::ItemKind::Mod(ref m), .. }) if glob => {
|
||||
let prev = mem::replace(&mut self.inlining, true);
|
||||
for i in &m.item_ids {
|
||||
let i = self.cx.tcx.hir().expect_item(i.id);
|
||||
@ -361,7 +361,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
self.store_path(def_id);
|
||||
}
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ForeignMod(ref fm) => {
|
||||
for item in &fm.items {
|
||||
self.visit_foreign_item(item, None, om);
|
||||
|
@ -2269,7 +2269,7 @@ pub struct Item {
|
||||
pub ident: Ident,
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub id: NodeId,
|
||||
pub node: ItemKind,
|
||||
pub kind: ItemKind,
|
||||
pub vis: Visibility,
|
||||
pub span: Span,
|
||||
|
||||
|
@ -13,7 +13,7 @@ pub enum EntryPointType {
|
||||
// Beware, this is duplicated in librustc/middle/entry.rs, make sure to keep
|
||||
// them in sync.
|
||||
pub fn entry_point_type(item: &Item, depth: usize) -> EntryPointType {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(..) => {
|
||||
if attr::contains_name(&item.attrs, sym::start) {
|
||||
EntryPointType::Start
|
||||
|
@ -222,7 +222,7 @@ impl Annotatable {
|
||||
|
||||
pub fn derive_allowed(&self) -> bool {
|
||||
match *self {
|
||||
Annotatable::Item(ref item) => match item.node {
|
||||
Annotatable::Item(ref item) => match item.kind {
|
||||
ast::ItemKind::Struct(..) |
|
||||
ast::ItemKind::Enum(..) |
|
||||
ast::ItemKind::Union(..) => true,
|
||||
|
@ -567,14 +567,14 @@ impl<'a> ExtCtxt<'a> {
|
||||
}
|
||||
|
||||
pub fn item(&self, span: Span, name: Ident,
|
||||
attrs: Vec<ast::Attribute>, node: ast::ItemKind) -> P<ast::Item> {
|
||||
attrs: Vec<ast::Attribute>, kind: ast::ItemKind) -> P<ast::Item> {
|
||||
// FIXME: Would be nice if our generated code didn't violate
|
||||
// Rust coding conventions
|
||||
P(ast::Item {
|
||||
ident: name,
|
||||
attrs,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node,
|
||||
kind,
|
||||
vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited),
|
||||
span,
|
||||
tokens: None,
|
||||
|
@ -293,7 +293,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||
let krate_item = AstFragment::Items(smallvec![P(ast::Item {
|
||||
attrs: krate.attrs,
|
||||
span: krate.span,
|
||||
node: ast::ItemKind::Mod(krate.module),
|
||||
kind: ast::ItemKind::Mod(krate.module),
|
||||
ident: Ident::invalid(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
vis: respan(krate.span.shrink_to_lo(), ast::VisibilityKind::Public),
|
||||
@ -301,7 +301,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||
})]);
|
||||
|
||||
match self.fully_expand_fragment(krate_item).make_items().pop().map(P::into_inner) {
|
||||
Some(ast::Item { attrs, node: ast::ItemKind::Mod(module), .. }) => {
|
||||
Some(ast::Item { attrs, kind: ast::ItemKind::Mod(module), .. }) => {
|
||||
krate.attrs = attrs;
|
||||
krate.module = module;
|
||||
},
|
||||
@ -689,7 +689,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||
fn gate_proc_macro_attr_item(&self, span: Span, item: &Annotatable) {
|
||||
let (kind, gate) = match *item {
|
||||
Annotatable::Item(ref item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Mod(_) if self.cx.ecfg.proc_macro_hygiene() => return,
|
||||
ItemKind::Mod(_) => ("modules", sym::proc_macro_hygiene),
|
||||
_ => return,
|
||||
@ -737,7 +737,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||
|
||||
impl<'ast, 'a> Visitor<'ast> for DisallowMacros<'a> {
|
||||
fn visit_item(&mut self, i: &'ast ast::Item) {
|
||||
if let ast::ItemKind::MacroDef(_) = i.node {
|
||||
if let ast::ItemKind::MacroDef(_) = i.kind {
|
||||
emit_feature_err(
|
||||
self.parse_sess,
|
||||
sym::proc_macro_hygiene,
|
||||
@ -1247,10 +1247,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
||||
AstFragmentKind::Items, after_derive).make_items();
|
||||
}
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::ItemKind::Mac(..) => {
|
||||
self.check_attributes(&item.attrs);
|
||||
item.and_then(|item| match item.node {
|
||||
item.and_then(|item| match item.kind {
|
||||
ItemKind::Mac(mac) => self.collect(
|
||||
AstFragmentKind::Items, InvocationKind::Bang { mac, span: item.span }
|
||||
).make_items(),
|
||||
|
@ -302,7 +302,7 @@ pub fn compile_declarative_macro(
|
||||
let tt_spec = ast::Ident::new(sym::tt, def.span);
|
||||
|
||||
// Parse the macro_rules! invocation
|
||||
let body = match def.node {
|
||||
let body = match def.kind {
|
||||
ast::ItemKind::MacroDef(ref body) => body,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment {
|
||||
AstFragmentKind::OptExpr => AstFragment::OptExpr(Some(expr_placeholder())),
|
||||
AstFragmentKind::Items => AstFragment::Items(smallvec![P(ast::Item {
|
||||
id, span, ident, vis, attrs,
|
||||
node: ast::ItemKind::Mac(mac_placeholder()),
|
||||
kind: ast::ItemKind::Mac(mac_placeholder()),
|
||||
tokens: None,
|
||||
})]),
|
||||
AstFragmentKind::TraitItems => AstFragment::TraitItems(smallvec![ast::TraitItem {
|
||||
@ -251,7 +251,7 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
|
||||
}
|
||||
|
||||
fn flat_map_item(&mut self, item: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::ItemKind::Mac(_) => return self.remove(item.id).make_items(),
|
||||
ast::ItemKind::MacroDef(_) => return smallvec![item],
|
||||
_ => {}
|
||||
@ -337,7 +337,7 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
|
||||
|
||||
fn visit_mod(&mut self, module: &mut ast::Mod) {
|
||||
noop_visit_mod(module, self);
|
||||
module.items.retain(|item| match item.node {
|
||||
module.items.retain(|item| match item.kind {
|
||||
ast::ItemKind::Mac(_) if !self.cx.ecfg.keep_macs => false, // remove macro definitions
|
||||
_ => true,
|
||||
});
|
||||
|
@ -107,7 +107,7 @@ impl MultiItemModifier for ProcMacroDerive {
|
||||
return Vec::new()
|
||||
}
|
||||
};
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Struct(..) |
|
||||
ItemKind::Enum(..) |
|
||||
ItemKind::Union(..) => {},
|
||||
|
@ -302,7 +302,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'a ast::Item) {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
ast::ItemKind::ForeignMod(ref foreign_module) => {
|
||||
self.check_abi(foreign_module.abi, i.span);
|
||||
}
|
||||
|
@ -994,7 +994,7 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
|
||||
id: DUMMY_NODE_ID,
|
||||
vis: respan(span.shrink_to_lo(), VisibilityKind::Public),
|
||||
span,
|
||||
node: ItemKind::Mod(module),
|
||||
kind: ItemKind::Mod(module),
|
||||
tokens: None,
|
||||
});
|
||||
let items = vis.flat_map_item(item);
|
||||
@ -1004,8 +1004,8 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
|
||||
let module = Mod { inner: span, items: vec![], inline: true };
|
||||
Crate { module, attrs: vec![], span }
|
||||
} else if len == 1 {
|
||||
let Item { attrs, span, node, .. } = items.into_iter().next().unwrap().into_inner();
|
||||
match node {
|
||||
let Item { attrs, span, kind, .. } = items.into_iter().next().unwrap().into_inner();
|
||||
match kind {
|
||||
ItemKind::Mod(module) => Crate { module, attrs, span },
|
||||
_ => panic!("visitor converted a module to not a module"),
|
||||
}
|
||||
@ -1018,11 +1018,11 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
|
||||
// Mutates one item into possibly many items.
|
||||
pub fn noop_flat_map_item<T: MutVisitor>(mut item: P<Item>, visitor: &mut T)
|
||||
-> SmallVec<[P<Item>; 1]> {
|
||||
let Item { ident, attrs, id, node, vis, span, tokens: _ } = item.deref_mut();
|
||||
let Item { ident, attrs, id, kind, vis, span, tokens: _ } = item.deref_mut();
|
||||
visitor.visit_ident(ident);
|
||||
visit_attrs(attrs, visitor);
|
||||
visitor.visit_id(id);
|
||||
visitor.visit_item_kind(node);
|
||||
visitor.visit_item_kind(kind);
|
||||
visitor.visit_vis(vis);
|
||||
visitor.visit_span(span);
|
||||
|
||||
|
@ -761,7 +761,7 @@ impl<'a> Parser<'a> {
|
||||
);
|
||||
if !items.is_empty() {
|
||||
let previous_item = &items[items.len() - 1];
|
||||
let previous_item_kind_name = match previous_item.node {
|
||||
let previous_item_kind_name = match previous_item.kind {
|
||||
// Say "braced struct" because tuple-structs and
|
||||
// braceless-empty-struct declarations do take a semicolon.
|
||||
ItemKind::Struct(..) => Some("braced struct"),
|
||||
|
@ -1949,13 +1949,13 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_item(&self, span: Span, ident: Ident, node: ItemKind, vis: Visibility,
|
||||
fn mk_item(&self, span: Span, ident: Ident, kind: ItemKind, vis: Visibility,
|
||||
attrs: Vec<Attribute>) -> P<Item> {
|
||||
P(Item {
|
||||
ident,
|
||||
attrs,
|
||||
id: DUMMY_NODE_ID,
|
||||
node,
|
||||
kind,
|
||||
vis,
|
||||
span,
|
||||
tokens: None,
|
||||
|
@ -299,7 +299,7 @@ fn out_of_line_mod() {
|
||||
&sess,
|
||||
).unwrap().unwrap();
|
||||
|
||||
if let ast::ItemKind::Mod(ref m) = item.node {
|
||||
if let ast::ItemKind::Mod(ref m) = item.kind {
|
||||
assert!(m.items.len() == 2);
|
||||
} else {
|
||||
panic!();
|
||||
|
@ -1142,7 +1142,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 {
|
||||
ast::ItemKind::ExternCrate(orig_name) => {
|
||||
self.head(visibility_qualified(&item.vis, "extern crate"));
|
||||
if let Some(orig_name) = orig_name {
|
||||
|
@ -230,7 +230,7 @@ pub fn walk_trait_ref<'a, V: Visitor<'a>>(visitor: &mut V, trait_ref: &'a TraitR
|
||||
pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
|
||||
visitor.visit_vis(&item.vis);
|
||||
visitor.visit_ident(item.ident);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::ExternCrate(orig_name) => {
|
||||
if let Some(orig_name) = orig_name {
|
||||
visitor.visit_name(item.span, orig_name);
|
||||
|
@ -32,7 +32,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt<'_>,
|
||||
let is_shallow;
|
||||
match *item {
|
||||
Annotatable::Item(ref annitem) => {
|
||||
match annitem.node {
|
||||
match annitem.kind {
|
||||
ItemKind::Struct(_, Generics { ref params, .. }) |
|
||||
ItemKind::Enum(_, Generics { ref params, .. }) => {
|
||||
let container_id = cx.current_expansion.id.expn_data().parent;
|
||||
|
@ -409,7 +409,7 @@ impl<'a> TraitDef<'a> {
|
||||
}
|
||||
false
|
||||
});
|
||||
let has_no_type_params = match item.node {
|
||||
let has_no_type_params = match item.kind {
|
||||
ast::ItemKind::Struct(_, ref generics) |
|
||||
ast::ItemKind::Enum(_, ref generics) |
|
||||
ast::ItemKind::Union(_, ref generics) => {
|
||||
@ -431,7 +431,7 @@ impl<'a> TraitDef<'a> {
|
||||
has_no_type_params;
|
||||
let use_temporaries = is_packed && is_always_copy;
|
||||
|
||||
let newitem = match item.node {
|
||||
let newitem = match item.kind {
|
||||
ast::ItemKind::Struct(ref struct_def, ref generics) => {
|
||||
self.expand_struct_def(cx, &struct_def, item.ident, generics, from_scratch,
|
||||
use_temporaries)
|
||||
@ -1780,7 +1780,7 @@ pub fn cs_fold1<F, B>(use_foldl: bool,
|
||||
/// (for an enum, no variant has any fields)
|
||||
pub fn is_type_without_fields(item: &Annotatable) -> bool {
|
||||
if let Annotatable::Item(ref item) = *item {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::ItemKind::Enum(ref enum_def, _) => {
|
||||
enum_def.variants.iter().all(|v| v.data.fields().is_empty())
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ pub fn expand(
|
||||
vec![item]
|
||||
};
|
||||
let item = match item {
|
||||
Annotatable::Item(item) => match item.node {
|
||||
Annotatable::Item(item) => match item.kind {
|
||||
ItemKind::Static(..) => item,
|
||||
_ => return not_static(Annotatable::Item(item)),
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt<'_>,
|
||||
ident: ast::Ident::invalid(),
|
||||
attrs: Vec::new(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::ItemKind::GlobalAsm(P(global_asm)),
|
||||
kind: ast::ItemKind::GlobalAsm(P(global_asm)),
|
||||
vis: respan(sp.shrink_to_lo(), ast::VisibilityKind::Inherited),
|
||||
span: cx.with_def_site_ctxt(sp),
|
||||
tokens: None,
|
||||
|
@ -28,7 +28,7 @@ fn plugin_macro_def(name: Name, span: Span) -> P<Item> {
|
||||
ident: Ident::new(name, span),
|
||||
attrs: vec![rustc_builtin_macro],
|
||||
id: DUMMY_NODE_ID,
|
||||
node: ItemKind::MacroDef(MacroDef { tokens: TokenStream::new(trees), legacy: true }),
|
||||
kind: ItemKind::MacroDef(MacroDef { tokens: TokenStream::new(trees), legacy: true }),
|
||||
vis: respan(span, VisibilityKind::Inherited),
|
||||
span: span,
|
||||
tokens: None,
|
||||
|
@ -226,7 +226,7 @@ impl<'a> CollectProcMacros<'a> {
|
||||
|
||||
impl<'a> Visitor<'a> for CollectProcMacros<'a> {
|
||||
fn visit_item(&mut self, item: &'a ast::Item) {
|
||||
if let ast::ItemKind::MacroDef(..) = item.node {
|
||||
if let ast::ItemKind::MacroDef(..) = item.kind {
|
||||
if self.is_proc_macro_crate && attr::contains_name(&item.attrs, sym::macro_export) {
|
||||
let msg =
|
||||
"cannot export macro_rules! macros from a `proc-macro` crate type currently";
|
||||
@ -238,7 +238,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
|
||||
// we're just not interested in this item.
|
||||
//
|
||||
// If we find one, try to locate a `#[proc_macro_derive]` attribute on it.
|
||||
let is_fn = match item.node {
|
||||
let is_fn = match item.kind {
|
||||
ast::ItemKind::Fn(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
@ -78,7 +78,7 @@ pub fn expand_test_or_bench(
|
||||
"`#[test]` attribute is only allowed on non associated functions").raise();
|
||||
};
|
||||
|
||||
if let ast::ItemKind::Mac(_) = item.node {
|
||||
if let ast::ItemKind::Mac(_) = item.kind {
|
||||
cx.parse_sess.span_diagnostic.span_warn(item.span,
|
||||
"`#[test]` attribute should not be used on macros. Use `#[cfg(test)]` instead.");
|
||||
return vec![Annotatable::Item(item)];
|
||||
@ -264,7 +264,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
|
||||
fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool {
|
||||
let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic);
|
||||
let ref sd = cx.parse_sess.span_diagnostic;
|
||||
if let ast::ItemKind::Fn(ref decl, ref header, ref generics, _) = i.node {
|
||||
if let ast::ItemKind::Fn(ref decl, ref header, ref generics, _) = i.kind {
|
||||
if header.unsafety == ast::Unsafety::Unsafe {
|
||||
sd.span_err(
|
||||
i.span,
|
||||
@ -315,7 +315,7 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool {
|
||||
}
|
||||
|
||||
fn has_bench_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool {
|
||||
let has_sig = if let ast::ItemKind::Fn(ref decl, _, _, _) = i.node {
|
||||
let has_sig = if let ast::ItemKind::Fn(ref decl, _, _, _) = i.kind {
|
||||
// N.B., inadequate check, but we're running
|
||||
// well before resolve, can't get too deep.
|
||||
decl.inputs.len() == 1
|
||||
|
@ -85,7 +85,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
|
||||
|
||||
// We don't want to recurse into anything other than mods, since
|
||||
// mods or tests inside of functions will break things
|
||||
if let ast::ItemKind::Mod(mut module) = item.node {
|
||||
if let ast::ItemKind::Mod(mut module) = item.kind {
|
||||
let tests = mem::take(&mut self.tests);
|
||||
noop_visit_mod(&mut module, self);
|
||||
let mut tests = mem::replace(&mut self.tests, tests);
|
||||
@ -111,7 +111,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
|
||||
}
|
||||
self.cx.test_cases.extend(tests);
|
||||
}
|
||||
item.node = ast::ItemKind::Mod(module);
|
||||
item.kind = ast::ItemKind::Mod(module);
|
||||
}
|
||||
smallvec![P(item)]
|
||||
}
|
||||
@ -142,7 +142,7 @@ impl MutVisitor for EntryPointCleaner {
|
||||
EntryPointType::MainNamed |
|
||||
EntryPointType::MainAttr |
|
||||
EntryPointType::Start =>
|
||||
item.map(|ast::Item {id, ident, attrs, node, vis, span, tokens}| {
|
||||
item.map(|ast::Item {id, ident, attrs, kind, vis, span, tokens}| {
|
||||
let allow_ident = Ident::new(sym::allow, self.def_site);
|
||||
let dc_nested = attr::mk_nested_word_item(
|
||||
Ident::from_str_and_span("dead_code", self.def_site),
|
||||
@ -159,7 +159,7 @@ impl MutVisitor for EntryPointCleaner {
|
||||
})
|
||||
.chain(iter::once(allow_dead_code))
|
||||
.collect(),
|
||||
node,
|
||||
kind,
|
||||
vis,
|
||||
span,
|
||||
tokens,
|
||||
@ -295,7 +295,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
|
||||
ident: main_id,
|
||||
attrs: vec![main_attr],
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: main,
|
||||
kind: main,
|
||||
vis: respan(sp, ast::VisibilityKind::Public),
|
||||
span: sp,
|
||||
tokens: None,
|
||||
|
Loading…
x
Reference in New Issue
Block a user