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,
}
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 */ }
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 {
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)
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,
};
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)
});
) -> 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[..]
}
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);
}
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);
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,
})
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(
hir_id: new_id,
ident,
attrs: attrs.into_iter().cloned().collect(),
- node: item,
+ kind,
vis,
span,
},
});
}
- 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 => {
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,
hir_id: new_hir_id,
ident,
attrs: attrs.into_iter().cloned().collect(),
- node: item,
+ kind,
vis,
span: use_tree.span,
},
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,
+ }
}
}
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,
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));
// 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);
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() {
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,
}
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),
Some(match node {
Node::Item(item) => {
- match item.node {
+ match item.kind {
ItemKind::Static(..) => DefKind::Static,
ItemKind::Const(..) => DefKind::Const,
ItemKind::Fn(..) => DefKind::Fn,
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(..), .. }) => {
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))
}
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)),
}
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),
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) |
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 {
})
| 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,
/// 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,
}
/// 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,
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(..)
}
match self.get(scope) {
Node::Item(i) => {
- match i.node {
+ match i.kind {
ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: None, .. }) => {}
_ => break,
}
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;
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))
}
fn item_is_mod(item: &Item) -> bool {
- match item.node {
+ match item.kind {
ItemKind::Mod(_) => true,
_ => false,
}
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",
pub ident: Ident,
pub hir_id: HirId,
pub attrs: HirVec<Attribute>,
- pub node: ItemKind,
+ pub kind: ItemKind,
pub vis: Visibility,
pub span: Span,
}
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 {
ident,
ref attrs,
hir_id: _,
- ref node,
+ ref kind,
ref vis,
span
} = *self;
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);
});
}
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",
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 {
.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),
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);
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();
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);
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));
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(..)
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(..) |
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"
};
item.hir_id,
span,
item.ident.name,
- item.node.descriptive_variant(),
+ item.kind.descriptive_variant(),
participle,
);
} else {
// 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
return true
}
- match item.node {
+ match item.kind {
hir::ItemKind::Fn(_, header, ..) if header.is_const() => {
return true;
}
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,
// 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)
// 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
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,
}
// 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));
}
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);
| 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
// `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 {
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)
{
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);
}
},
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;
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 {
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),
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()
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
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
}
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)
}
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 }
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);
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);
}
Node::Item(&hir::Item {
span,
- node: hir::ItemKind::Fn(ref decl, ..),
+ kind: hir::ItemKind::Fn(ref decl, ..),
..
}) |
Node::ImplItem(&hir::ImplItem {
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
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;
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,
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)]
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()
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;
}
}
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() {
// 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(..),
// 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;
}
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")
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
&format!(
"clean/dirty auto-assertions not yet defined \
for Node::Item.node={:?}",
- item.node
+ item.kind
)
),
}
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(..) |
}
// 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() {
}
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")
}
}
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",
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;
return;
}
- match item.node {
+ match item.kind {
hir::ItemKind::Struct(..) |
hir::ItemKind::Union(..) |
hir::ItemKind::Enum(..) => {}
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);
}
}
return;
}
- match it.node {
+ match it.kind {
hir::ItemKind::ExternCrate(..) => (),
_ => return,
};
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 {
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));
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,
};
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);
},
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;
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() {
// 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 {
return;
}
- match it.node {
+ match it.kind {
ast::ItemKind::TyAlias(..) |
ast::ItemKind::Enum(..) |
ast::ItemKind::Struct(..) |
}
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);
}
}
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);
}
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);
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);
}
}
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);
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,
}),
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) => {
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);
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()
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(..) |
_ => 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(..) |
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(..) |
// 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
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)),
/// 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(..) |
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
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,
};
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,
};
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,
};
// 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),
) => {
(*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)), .. }
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(..) |
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 {
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 {
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 {
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);
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));
}
}
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()),
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(
.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));
}
}
}
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.
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);
}
// 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`.
}
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(_) => {}
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`.
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
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`");
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)
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
// 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;
}
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, _) => {
// 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)));
}
// 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
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;
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![],
}
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)));
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));
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 {
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 {
_ => 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,
),
);
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 {
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);
// 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.
) -> 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)),
}
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,
}
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,
}
}
- 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 {
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,
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);
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), ..
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,
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 {
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:
//
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!(),
},
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);
}
}
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 {
// 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,
};
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
}
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
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)
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
};
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(..) |
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();
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);
}
}
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)
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(..)
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);
}
}
};
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
_ => 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"),
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"),
}
_ => 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)
}
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,
},
Node::ImplItem(item) => &item.generics,
Node::Item(item) => {
- match item.node {
+ match item.kind {
ItemKind::Fn(.., ref generics, _) | ItemKind::Impl(_, _, _, ref generics, ..) => {
generics
}
},
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 {
span_bug!(
item.span,
"compute_type_of_item: unexpected item type: {:?}",
- item.node
+ item.kind
);
}
}
..
})
| Item(hir::Item {
- node: ItemKind::Fn(decl, header, _, _),
+ kind: ItemKind::Fn(decl, header, _, _),
..
}) => match get_infer_ret_ty(&decl.output) {
Some(ty) => {
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);
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");
},
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);
// in trait checking. See `setup_constraining_predicates`
// for details.
if let Node::Item(&Item {
- node: ItemKind::Impl(..),
+ kind: ItemKind::Impl(..),
..
}) = node
{
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), ..
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,
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 \
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,
};
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);
.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);
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);
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(..) |
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);
}
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)
}
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()
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 {
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,
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,
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!()
// 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);
}
}
};
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;
}
}
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();
}
if !found_macro {
- if let ast::ItemKind::Mac(..) = item.node {
+ if let ast::ItemKind::Mac(..) = item.kind {
found_macro = true;
}
}
}
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()
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);
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);
pub ident: Ident,
pub attrs: Vec<Attribute>,
pub id: NodeId,
- pub node: ItemKind,
+ pub kind: ItemKind,
pub vis: Visibility,
pub span: Span,
// 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
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,
}
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,
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),
})]);
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;
},
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,
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,
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(),
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!(),
};
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 {
}
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],
_ => {}
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,
});
return Vec::new()
}
};
- match item.node {
+ match item.kind {
ItemKind::Struct(..) |
ItemKind::Enum(..) |
ItemKind::Union(..) => {},
}
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);
}
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);
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"),
}
// 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);
);
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"),
}
}
- 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,
&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!();
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 {
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);
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;
}
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) => {
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)
/// (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())
}
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)),
}
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,
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,
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";
// 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,
};
"`#[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)];
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,
}
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
// 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);
}
self.cx.test_cases.extend(tests);
}
- item.node = ast::ItemKind::Mod(module);
+ item.kind = ast::ItemKind::Mod(module);
}
smallvec![P(item)]
}
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),
})
.chain(iter::once(allow_dead_code))
.collect(),
- node,
+ kind,
vis,
span,
tokens,
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,