diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 1df09429e519f..c946118b1ea19 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -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, @@ -262,7 +262,7 @@ impl CheckAttrVisitor<'tcx> { fn check_stmt_attributes(&self, stmt: &hir::Stmt) { // When checking statements ignore expressions, they will be checked later - if let hir::StmtKind::Local(ref l) = stmt.node { + if let hir::StmtKind::Local(ref l) = stmt.kind { for attr in l.attrs.iter() { if attr.check_name(sym::inline) { self.check_inline(attr, &stmt.span, Target::Statement); @@ -280,7 +280,7 @@ impl CheckAttrVisitor<'tcx> { } fn check_expr_attributes(&self, expr: &hir::Expr) { - let target = match expr.node { + let target = match expr.kind { hir::ExprKind::Closure(..) => Target::Closure, _ => Target::Expression, }; @@ -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 */ } diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 91fc004b893ba..d1ebdd2f086ab 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -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 { @@ -594,7 +594,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V, pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { visitor.visit_id(typ.hir_id); - match typ.node { + match typ.kind { TyKind::Slice(ref ty) => { visitor.visit_ty(ty) } @@ -696,7 +696,7 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V, pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) { visitor.visit_id(pattern.hir_id); - match pattern.node { + match pattern.kind { PatKind::TupleStruct(ref qpath, ref children, _) => { visitor.visit_qpath(qpath, pattern.hir_id, pattern.span); walk_list!(visitor, visit_pat, children); @@ -743,7 +743,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v visitor.visit_vis(&foreign_item.vis); visitor.visit_ident(foreign_item.ident); - match foreign_item.node { + match foreign_item.kind { ForeignItemKind::Fn(ref function_declaration, ref param_names, ref generics) => { visitor.visit_generics(generics); visitor.visit_fn_decl(function_declaration); @@ -856,7 +856,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai visitor.visit_ident(trait_item.ident); walk_list!(visitor, visit_attribute, &trait_item.attrs); visitor.visit_generics(&trait_item.generics); - match trait_item.node { + match trait_item.kind { TraitItemKind::Const(ref ty, default) => { visitor.visit_id(trait_item.hir_id); visitor.visit_ty(ty); @@ -905,7 +905,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt ref defaultness, ref attrs, ref generics, - ref node, + ref kind, span: _, } = *impl_item; @@ -914,7 +914,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt visitor.visit_defaultness(defaultness); walk_list!(visitor, visit_attribute, attrs); visitor.visit_generics(generics); - match *node { + match *kind { ImplItemKind::Const(ref ty, body) => { visitor.visit_id(impl_item.hir_id); visitor.visit_ty(ty); @@ -974,7 +974,7 @@ pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) { pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) { visitor.visit_id(statement.hir_id); - match statement.node { + match statement.kind { StmtKind::Local(ref local) => visitor.visit_local(local), StmtKind::Item(item) => visitor.visit_nested_item(item), StmtKind::Expr(ref expression) | @@ -992,7 +992,7 @@ pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonCo pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { visitor.visit_id(expression.hir_id); walk_list!(visitor, visit_attribute, expression.attrs.iter()); - match expression.node { + match expression.kind { ExprKind::Box(ref subexpression) => { visitor.visit_expr(subexpression) } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index f861499cfe418..d0a9d967a649d 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -346,7 +346,7 @@ struct ImplTraitTypeIdVisitor<'a> { ids: &'a mut SmallVec<[NodeId; 1]> } impl<'a, 'b> Visitor<'a> for ImplTraitTypeIdVisitor<'b> { fn visit_ty(&mut self, ty: &'a Ty) { - match ty.node { + match ty.kind { | TyKind::Typeof(_) | TyKind::BareFn(_) => return, @@ -425,7 +425,7 @@ impl<'a> LoweringContext<'a> { impl<'tcx, 'interner> Visitor<'tcx> for MiscCollector<'tcx, 'interner> { fn visit_pat(&mut self, p: &'tcx Pat) { - if let PatKind::Paren(..) | PatKind::Rest = p.node { + if let PatKind::Paren(..) | PatKind::Rest = p.kind { // Doesn't generate a HIR node } else if let Some(owner) = self.hir_id_owner { self.lctx.lower_node_id_with_owner(p.id, owner); @@ -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) @@ -469,7 +469,7 @@ impl<'a> LoweringContext<'a> { fn visit_trait_item(&mut self, item: &'tcx TraitItem) { self.lctx.allocate_hir_id_counter(item.id); - match item.node { + match item.kind { TraitItemKind::Method(_, None) => { // Ignore patterns in trait methods without bodies self.with_hir_id_owner(None, |this| { @@ -497,7 +497,7 @@ impl<'a> LoweringContext<'a> { } fn visit_ty(&mut self, t: &'tcx Ty) { - match t.node { + match t.kind { // Mirrors the case in visit::walk_ty TyKind::BareFn(ref f) => { walk_list!( @@ -1104,7 +1104,7 @@ impl<'a> LoweringContext<'a> { let ty = this.lower_ty( &Ty { id: this.sess.next_node_id(), - node: TyKind::ImplTrait(impl_trait_node_id, bounds.clone()), + kind: TyKind::ImplTrait(impl_trait_node_id, bounds.clone()), span: constraint.span, }, itctx, @@ -1165,14 +1165,14 @@ impl<'a> LoweringContext<'a> { let id = self.lower_node_id(t.id); let qpath = self.lower_qpath(t.id, qself, path, param_mode, itctx); let ty = self.ty_path(id, t.span, qpath); - if let hir::TyKind::TraitObject(..) = ty.node { + if let hir::TyKind::TraitObject(..) = ty.kind { self.maybe_lint_bare_trait(t.span, t.id, qself.is_none() && path.is_global()); } ty } fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_>) -> hir::Ty { - let kind = match t.node { + let kind = match t.kind { TyKind::Infer => hir::TyKind::Infer, TyKind::Err => hir::TyKind::Err, TyKind::Slice(ref ty) => hir::TyKind::Slice(self.lower_ty(ty, itctx)), @@ -1345,7 +1345,7 @@ impl<'a> LoweringContext<'a> { }; hir::Ty { - node: kind, + kind, span: t.span, hir_id: self.lower_node_id(t.id), } @@ -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, }; @@ -1505,7 +1505,7 @@ impl<'a> LoweringContext<'a> { fn visit_ty(&mut self, t: &'v hir::Ty) { // Don't collect elided lifetimes used inside of `fn()` syntax. - if let hir::TyKind::BareFn(_) = t.node { + if let hir::TyKind::BareFn(_) = t.kind { let old_collect_elided_lifetimes = self.collect_elided_lifetimes; self.collect_elided_lifetimes = false; @@ -2026,7 +2026,7 @@ impl<'a> LoweringContext<'a> { .map(|ty| this.lower_ty_direct(ty, ImplTraitContext::disallowed())) .collect(); let mk_tup = |this: &mut Self, tys, span| { - hir::Ty { node: hir::TyKind::Tup(tys), hir_id: this.next_id(), span } + hir::Ty { kind: hir::TyKind::Tup(tys), hir_id: this.next_id(), span } }; ( hir::GenericArgs { @@ -2095,7 +2095,7 @@ impl<'a> LoweringContext<'a> { fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> hir::HirVec { decl.inputs .iter() - .map(|param| match param.pat.node { + .map(|param| match param.pat.kind { PatKind::Ident(_, ident, _) => ident, _ => Ident::new(kw::Invalid, param.pat.span), }) @@ -2172,23 +2172,23 @@ impl<'a> LoweringContext<'a> { implicit_self: decl.inputs.get(0).map_or( hir::ImplicitSelfKind::None, |arg| { - let is_mutable_pat = match arg.pat.node { + let is_mutable_pat = match arg.pat.kind { PatKind::Ident(BindingMode::ByValue(mt), _, _) | PatKind::Ident(BindingMode::ByRef(mt), _, _) => mt == Mutability::Mutable, _ => false, }; - match arg.ty.node { + match arg.ty.kind { TyKind::ImplicitSelf if is_mutable_pat => hir::ImplicitSelfKind::Mut, TyKind::ImplicitSelf => hir::ImplicitSelfKind::Imm, // Given we are only considering `ImplicitSelf` types, we needn't consider // the case where we have a mutable pattern to a reference as that would // no longer be an `ImplicitSelf`. - TyKind::Rptr(_, ref mt) if mt.ty.node.is_implicit_self() && + TyKind::Rptr(_, ref mt) if mt.ty.kind.is_implicit_self() && mt.mutbl == ast::Mutability::Mutable => hir::ImplicitSelfKind::MutRef, - TyKind::Rptr(_, ref mt) if mt.ty.node.is_implicit_self() => + TyKind::Rptr(_, ref mt) if mt.ty.kind.is_implicit_self() => hir::ImplicitSelfKind::ImmRef, _ => hir::ImplicitSelfKind::None, } @@ -2403,7 +2403,7 @@ impl<'a> LoweringContext<'a> { let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args.into()); hir::FunctionRetTy::Return(P(hir::Ty { - node: opaque_ty_ref, + kind: opaque_ty_ref, span, hir_id: self.next_id(), })) @@ -2424,7 +2424,7 @@ impl<'a> LoweringContext<'a> { FunctionRetTy::Default(ret_ty_span) => { P(hir::Ty { hir_id: self.next_id(), - node: hir::TyKind::Tup(hir_vec![]), + kind: hir::TyKind::Tup(hir_vec![]), span: *ret_ty_span, }) } @@ -2660,7 +2660,7 @@ impl<'a> LoweringContext<'a> { for (index, stmt) in b.stmts.iter().enumerate() { if index == b.stmts.len() - 1 { - if let StmtKind::Expr(ref e) = stmt.node { + if let StmtKind::Expr(ref e) = stmt.kind { expr = Some(P(self.lower_expr(e))); } else { stmts.extend(self.lower_stmt(stmt)); @@ -2688,7 +2688,7 @@ impl<'a> LoweringContext<'a> { } fn lower_pat(&mut self, p: &Pat) -> P { - let node = match p.node { + let node = match p.kind { PatKind::Wild => hir::PatKind::Wild, PatKind::Ident(ref binding_mode, ident, ref sub) => { let lower_sub = |this: &mut Self| sub.as_ref().map(|x| this.lower_pat(x)); @@ -2805,7 +2805,7 @@ impl<'a> LoweringContext<'a> { let mut iter = pats.iter(); while let Some(pat) = iter.next() { // Interpret the first `((ref mut?)? x @)? ..` pattern as a subslice pattern. - match pat.node { + match pat.kind { PatKind::Rest => { prev_rest_span = Some(pat.span); slice = Some(self.pat_wild_with_node_id_of(pat)); @@ -2827,7 +2827,7 @@ impl<'a> LoweringContext<'a> { while let Some(pat) = iter.next() { // There was a previous subslice pattern; make sure we don't allow more. - let rest_span = match pat.node { + let rest_span = match pat.kind { PatKind::Rest => Some(pat.span), PatKind::Ident(.., Some(ref sub)) if sub.is_rest() => { // The `HirValidator` is merciless; add a `_` pattern to avoid ICEs. @@ -2884,10 +2884,10 @@ impl<'a> LoweringContext<'a> { } /// Construct a `Pat` with the `HirId` of `p.id` lowered. - fn pat_with_node_id_of(&mut self, p: &Pat, node: hir::PatKind) -> P { + fn pat_with_node_id_of(&mut self, p: &Pat, kind: hir::PatKind) -> P { P(hir::Pat { hir_id: self.lower_node_id(p.id), - node, + kind, span: p.span, }) } @@ -2931,7 +2931,7 @@ impl<'a> LoweringContext<'a> { } fn lower_stmt(&mut self, s: &Stmt) -> SmallVec<[hir::Stmt; 1]> { - let node = match s.node { + let kind = match s.kind { StmtKind::Local(ref l) => { let (l, item_ids) = self.lower_local(l); let mut ids: SmallVec<[hir::Stmt; 1]> = item_ids @@ -2944,7 +2944,7 @@ impl<'a> LoweringContext<'a> { ids.push({ hir::Stmt { hir_id: self.lower_node_id(s.id), - node: hir::StmtKind::Local(P(l)), + kind: hir::StmtKind::Local(P(l)), span: s.span, } }); @@ -2962,7 +2962,7 @@ impl<'a> LoweringContext<'a> { hir::Stmt { hir_id, - node: hir::StmtKind::Item(item_id), + kind: hir::StmtKind::Item(item_id), span: s.span, } }) @@ -2974,7 +2974,7 @@ impl<'a> LoweringContext<'a> { }; smallvec![hir::Stmt { hir_id: self.lower_node_id(s.id), - node, + kind, span: s.span, }] } @@ -3011,8 +3011,8 @@ impl<'a> LoweringContext<'a> { // Helper methods for building HIR. - fn stmt(&mut self, span: Span, node: hir::StmtKind) -> hir::Stmt { - hir::Stmt { span, node, hir_id: self.next_id() } + fn stmt(&mut self, span: Span, kind: hir::StmtKind) -> hir::Stmt { + hir::Stmt { span, kind, hir_id: self.next_id() } } fn stmt_expr(&mut self, span: Span, expr: hir::Expr) -> hir::Stmt { @@ -3112,7 +3112,7 @@ impl<'a> LoweringContext<'a> { ( P(hir::Pat { hir_id, - node: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None), + kind: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None), span, }), hir_id @@ -3123,10 +3123,10 @@ impl<'a> LoweringContext<'a> { self.pat(span, hir::PatKind::Wild) } - fn pat(&mut self, span: Span, pat: hir::PatKind) -> P { + fn pat(&mut self, span: Span, kind: hir::PatKind) -> P { P(hir::Pat { hir_id: self.next_id(), - node: pat, + kind, span, }) } @@ -3164,7 +3164,7 @@ impl<'a> LoweringContext<'a> { } fn ty_path(&mut self, mut hir_id: hir::HirId, span: Span, qpath: hir::QPath) -> hir::Ty { - let node = match qpath { + let kind = match qpath { hir::QPath::Resolved(None, path) => { // Turn trait object paths into `TyKind::TraitObject` instead. match path.res { @@ -3188,9 +3188,10 @@ impl<'a> LoweringContext<'a> { } _ => hir::TyKind::Path(qpath), }; + hir::Ty { hir_id, - node, + kind, span, } } @@ -3378,7 +3379,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool { } }; - match expr.node { + match expr.kind { // All built-in range literals but `..=` and `..` desugar to `Struct`s. ExprKind::Struct(ref qpath, _, _) => { if let QPath::Resolved(None, ref path) = **qpath { @@ -3393,8 +3394,8 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool { // `..=` desugars into `::std::ops::RangeInclusive::new(...)`. ExprKind::Call(ref func, _) => { - if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.node { - if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.node { + if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.kind { + if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.kind { let new_call = segment.ident.as_str() == "new"; return is_range_path(&path) && is_lit(sess, &expr.span) && new_call; } diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs index 90b6c9474acb0..caecc162c7866 100644 --- a/src/librustc/hir/lowering/expr.rs +++ b/src/librustc/hir/lowering/expr.rs @@ -17,7 +17,7 @@ impl LoweringContext<'_> { } pub(super) fn lower_expr(&mut self, e: &Expr) -> hir::Expr { - let kind = match e.node { + let kind = match e.kind { ExprKind::Box(ref inner) => hir::ExprKind::Box(P(self.lower_expr(inner))), ExprKind::Array(ref exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)), ExprKind::Repeat(ref expr, ref count) => { @@ -54,7 +54,7 @@ impl LoweringContext<'_> { let ohs = P(self.lower_expr(ohs)); hir::ExprKind::Unary(op, ohs) } - ExprKind::Lit(ref l) => hir::ExprKind::Lit(respan(l.span, l.node.clone())), + ExprKind::Lit(ref l) => hir::ExprKind::Lit(respan(l.span, l.kind.clone())), ExprKind::Cast(ref expr, ref ty) => { let expr = P(self.lower_expr(expr)); hir::ExprKind::Cast(expr, self.lower_ty(ty, ImplTraitContext::disallowed())) @@ -184,7 +184,7 @@ impl LoweringContext<'_> { hir::Expr { hir_id: self.lower_node_id(e.id), - node: kind, + kind, span: e.span, attrs: e.attrs.clone(), } @@ -282,7 +282,7 @@ impl LoweringContext<'_> { // Handle then + scrutinee: let then_expr = self.lower_block_expr(then); - let (then_pat, scrutinee, desugar) = match cond.node { + let (then_pat, scrutinee, desugar) = match cond.kind { // ` => `: ExprKind::Let(ref pat, ref scrutinee) => { let scrutinee = self.lower_expr(scrutinee); @@ -332,7 +332,7 @@ impl LoweringContext<'_> { // Handle then + scrutinee: let then_expr = self.lower_block_expr(body); - let (then_pat, scrutinee, desugar, source) = match cond.node { + let (then_pat, scrutinee, desugar, source) = match cond.kind { ExprKind::Let(ref pat, ref scrutinee) => { // to: // @@ -459,7 +459,7 @@ impl LoweringContext<'_> { }); // `static || -> { body }`: - let generator_node = hir::ExprKind::Closure( + let generator_kind = hir::ExprKind::Closure( capture_clause, decl, body_id, @@ -468,7 +468,7 @@ impl LoweringContext<'_> { ); let generator = hir::Expr { hir_id: self.lower_node_id(closure_node_id), - node: generator_node, + kind: generator_kind, span, attrs: ThinVec::new(), }; @@ -625,7 +625,7 @@ impl LoweringContext<'_> { // loop { .. } let loop_expr = P(hir::Expr { hir_id: loop_hir_id, - node: hir::ExprKind::Loop( + kind: hir::ExprKind::Loop( loop_block, None, hir::LoopSource::Loop, @@ -1135,14 +1135,14 @@ impl LoweringContext<'_> { )); // `[opt_ident]: loop { ... }` - let loop_expr = hir::ExprKind::Loop( + let kind = hir::ExprKind::Loop( loop_block, self.lower_label(opt_label), hir::LoopSource::ForLoop, ); let loop_expr = P(hir::Expr { hir_id: self.lower_node_id(e.id), - node: loop_expr, + kind, span: e.span, attrs: ThinVec::new(), }); @@ -1443,15 +1443,10 @@ impl LoweringContext<'_> { pub(super) fn expr( &mut self, span: Span, - node: hir::ExprKind, + kind: hir::ExprKind, attrs: ThinVec ) -> hir::Expr { - hir::Expr { - hir_id: self.next_id(), - node, - span, - attrs, - } + hir::Expr { hir_id: self.next_id(), kind, span, attrs } } fn field(&mut self, ident: Ident, expr: P, span: Span) -> hir::Field { diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 5a8d5daaf09b8..7159db736a711 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -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, }, @@ -712,7 +711,7 @@ impl LoweringContext<'_> { hir_id: self.lower_node_id(i.id), ident: i.ident, attrs: self.lower_attrs(&i.attrs), - node: match i.node { + kind: match i.kind { ForeignItemKind::Fn(ref fdec, ref generics) => { let (generics, (fn_dec, fn_args)) = self.add_in_band_defs( generics, @@ -789,7 +788,7 @@ impl LoweringContext<'_> { } fn lower_struct_field(&mut self, (index, f): (usize, &StructField)) -> hir::StructField { - let ty = if let TyKind::Path(ref qself, ref path) = f.ty.node { + let ty = if let TyKind::Path(ref qself, ref path) = f.ty.kind { let t = self.lower_path_ty( &f.ty, qself, @@ -818,7 +817,7 @@ impl LoweringContext<'_> { fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem { let trait_item_def_id = self.resolver.definitions().local_def_id(i.id); - let (generics, node) = match i.node { + let (generics, kind) = match i.kind { TraitItemKind::Const(ref ty, ref default) => ( self.lower_generics(&i.generics, ImplTraitContext::disallowed()), hir::TraitItemKind::Const( @@ -852,14 +851,14 @@ impl LoweringContext<'_> { } TraitItemKind::Type(ref bounds, ref default) => { let generics = self.lower_generics(&i.generics, ImplTraitContext::disallowed()); - let node = hir::TraitItemKind::Type( + let kind = hir::TraitItemKind::Type( self.lower_param_bounds(bounds, ImplTraitContext::disallowed()), default .as_ref() .map(|x| self.lower_ty(x, ImplTraitContext::disallowed())), ); - (generics, node) + (generics, kind) }, TraitItemKind::Macro(..) => bug!("macro item shouldn't exist at this point"), }; @@ -869,13 +868,13 @@ impl LoweringContext<'_> { ident: i.ident, attrs: self.lower_attrs(&i.attrs), generics, - node, + kind, span: i.span, } } fn lower_trait_item_ref(&mut self, i: &TraitItem) -> hir::TraitItemRef { - let (kind, has_default) = match i.node { + let (kind, has_default) = match i.kind { TraitItemKind::Const(_, ref default) => { (hir::AssocItemKind::Const, default.is_some()) } @@ -902,7 +901,7 @@ impl LoweringContext<'_> { fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem { let impl_item_def_id = self.resolver.definitions().local_def_id(i.id); - let (generics, node) = match i.node { + let (generics, kind) = match i.kind { ImplItemKind::Const(ref ty, ref expr) => ( self.lower_generics(&i.generics, ImplTraitContext::disallowed()), hir::ImplItemKind::Const( @@ -946,7 +945,7 @@ impl LoweringContext<'_> { generics, vis: self.lower_visibility(&i.vis, None), defaultness: self.lower_defaultness(i.defaultness, true /* [1] */), - node, + kind, span: i.span, } @@ -960,7 +959,7 @@ impl LoweringContext<'_> { span: i.span, vis: self.lower_visibility(&i.vis, Some(i.id)), defaultness: self.lower_defaultness(i.defaultness, true /* [1] */), - kind: match i.node { + kind: match i.kind { ImplItemKind::Const(..) => hir::AssocItemKind::Const, ImplItemKind::TyAlias(..) => hir::AssocItemKind::Type, ImplItemKind::OpaqueTy(..) => hir::AssocItemKind::OpaqueTy, @@ -1133,7 +1132,7 @@ impl LoweringContext<'_> { // Check if this is a binding pattern, if so, we can optimize and avoid adding a // `let = __argN;` statement. In this case, we do not rename the parameter. - let (ident, is_simple_parameter) = match parameter.pat.node { + let (ident, is_simple_parameter) = match parameter.pat.kind { hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, _) => (ident, true), _ => { @@ -1343,7 +1342,7 @@ impl LoweringContext<'_> { ); }; // Check if the where clause type is a plain type parameter. - match bound_pred.bounded_ty.node { + match bound_pred.bounded_ty.kind { TyKind::Path(None, ref path) if path.segments.len() == 1 && bound_pred.bound_generic_params.is_empty() => diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index 351f5818f7e67..f670d5abe85e4 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -37,19 +37,25 @@ 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, + } } } impl MaybeFnLike for ast::ImplItem { fn is_fn_like(&self) -> bool { - match self.node { ast::ImplItemKind::Method(..) => true, _ => false, } + match self.kind { + ast::ImplItemKind::Method(..) => true, + _ => false, + } } } impl MaybeFnLike for ast::TraitItem { fn is_fn_like(&self) -> bool { - match self.node { + match self.kind { ast::TraitItemKind::Method(_, ast::TraitMethod::Provided(_)) => true, _ => false, } @@ -58,7 +64,7 @@ impl MaybeFnLike for ast::TraitItem { impl MaybeFnLike for ast::Expr { fn is_fn_like(&self) -> bool { - match self.node { + match self.kind { ast::ExprKind::Closure(..) => true, _ => false, } @@ -212,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, @@ -227,21 +233,21 @@ impl<'a> FnLikeNode<'a> { }), _ => bug!("item FnLikeNode that is not fn-like"), }, - map::Node::TraitItem(ti) => match ti.node { + map::Node::TraitItem(ti) => match ti.kind { ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => { method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs) } _ => bug!("trait method FnLikeNode that is not fn-like"), }, map::Node::ImplItem(ii) => { - match ii.node { + match ii.kind { ast::ImplItemKind::Method(ref sig, body) => { method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs) } _ => bug!("impl method FnLikeNode that is not fn-like") } }, - map::Node::Expr(e) => match e.node { + map::Node::Expr(e) => match e.kind { ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) => closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)), _ => bug!("expr FnLikeNode that is not fn-like"), diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 4179cf2ff807f..c69d682b6f796 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -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)); @@ -427,7 +427,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { } fn visit_pat(&mut self, pat: &'hir Pat) { - let node = if let PatKind::Binding(..) = pat.node { + let node = if let PatKind::Binding(..) = pat.kind { Node::Binding(pat) } else { Node::Pat(pat) diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index d1cc7a8ce988f..1997e2aab35e8 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -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() { @@ -157,7 +157,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { } fn visit_foreign_item(&mut self, foreign_item: &'a ForeignItem) { - if let ForeignItemKind::Macro(_) = foreign_item.node { + if let ForeignItemKind::Macro(_) = foreign_item.kind { return self.visit_macro_invoc(foreign_item.id); } @@ -214,7 +214,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { } fn visit_trait_item(&mut self, ti: &'a TraitItem) { - let def_data = match ti.node { + let def_data = match ti.kind { TraitItemKind::Method(..) | TraitItemKind::Const(..) => DefPathData::ValueNs(ti.ident.as_interned_str()), TraitItemKind::Type(..) => { @@ -228,7 +228,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { } fn visit_impl_item(&mut self, ii: &'a ImplItem) { - let def_data = match ii.node { + let def_data = match ii.kind { ImplItemKind::Method(MethodSig { ref header, ref decl, @@ -257,7 +257,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { } fn visit_pat(&mut self, pat: &'a Pat) { - match pat.node { + match pat.kind { PatKind::Mac(..) => return self.visit_macro_invoc(pat.id), _ => visit::walk_pat(self, pat), } @@ -271,7 +271,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { } fn visit_expr(&mut self, expr: &'a Expr) { - let parent_def = match expr.node { + let parent_def = match expr.kind { ExprKind::Mac(..) => return self.visit_macro_invoc(expr.id), ExprKind::Closure(_, asyncness, ..) => { // Async closures desugar to closures inside of closures, so @@ -292,7 +292,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { } fn visit_ty(&mut self, ty: &'a Ty) { - match ty.node { + match ty.kind { TyKind::Mac(..) => return self.visit_macro_invoc(ty.id), TyKind::ImplTrait(node_id, _) => { self.create_def(node_id, DefPathData::ImplTrait, ty.span); @@ -303,7 +303,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { } fn visit_stmt(&mut self, stmt: &'a Stmt) { - match stmt.node { + match stmt.kind { StmtKind::Mac(..) => self.visit_macro_invoc(stmt.id), _ => visit::walk_stmt(self, stmt), } @@ -312,7 +312,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { fn visit_token(&mut self, t: Token) { if let token::Interpolated(nt) = t.kind { if let token::NtExpr(ref expr) = *nt { - if let ExprKind::Mac(..) = expr.node { + if let ExprKind::Mac(..) = expr.kind { self.visit_macro_invoc(expr.id); } } diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 956cb36c6b139..d4efe0297b671 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -50,28 +50,28 @@ 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, } } Node::TraitItem(ref item) => { - match item.node { + match item.kind { TraitItemKind::Method(ref method_sig, _) => Some(&method_sig.decl), _ => None } } Node::ImplItem(ref item) => { - match item.node { + match item.kind { ImplItemKind::Method(ref method_sig, _) => Some(&method_sig.decl), _ => None, } } Node::Expr(ref expr) => { - match expr.node { + match expr.kind { ExprKind::Closure(_, ref fn_decl, ..) => Some(fn_decl), _ => None, } @@ -84,7 +84,7 @@ impl<'hir> Entry<'hir> { fn associated_body(self) -> Option { match self.node { Node::Item(item) => { - match item.node { + match item.kind { ItemKind::Const(_, body) | ItemKind::Static(.., body) | ItemKind::Fn(_, _, _, body) => Some(body), @@ -93,7 +93,7 @@ impl<'hir> Entry<'hir> { } Node::TraitItem(item) => { - match item.node { + match item.kind { TraitItemKind::Const(_, Some(body)) | TraitItemKind::Method(_, TraitMethod::Provided(body)) => Some(body), _ => None @@ -101,7 +101,7 @@ impl<'hir> Entry<'hir> { } Node::ImplItem(item) => { - match item.node { + match item.kind { ImplItemKind::Const(_, body) | ImplItemKind::Method(_, body) => Some(body), _ => None, @@ -111,7 +111,7 @@ impl<'hir> Entry<'hir> { Node::AnonConst(constant) => Some(constant.body), Node::Expr(expr) => { - match expr.node { + match expr.kind { ExprKind::Closure(.., body, _, _) => Some(body), _ => None, } @@ -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, @@ -313,21 +313,21 @@ impl<'hir> Map<'hir> { } } Node::ForeignItem(item) => { - match item.node { + match item.kind { ForeignItemKind::Fn(..) => DefKind::Fn, ForeignItemKind::Static(..) => DefKind::Static, ForeignItemKind::Type => DefKind::ForeignTy, } } Node::TraitItem(item) => { - match item.node { + match item.kind { TraitItemKind::Const(..) => DefKind::AssocConst, TraitItemKind::Method(..) => DefKind::Method, TraitItemKind::Type(..) => DefKind::AssocTy, } } Node::ImplItem(item) => { - match item.node { + match item.kind { ImplItemKind::Const(..) => DefKind::AssocConst, ImplItemKind::Method(..) => DefKind::Method, ImplItemKind::TyAlias(..) => DefKind::AssocTy, @@ -453,22 +453,22 @@ impl<'hir> Map<'hir> { pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind { match self.get(id) { - Node::Item(&Item { node: ItemKind::Const(..), .. }) | - Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) | - Node::ImplItem(&ImplItem { node: ImplItemKind::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::TraitItem(&TraitItem { node: TraitItemKind::Method(..), .. }) | - Node::ImplItem(&ImplItem { node: ImplItemKind::Method(..), .. }) => { + 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 { node: ExprKind::Closure(..), .. }) => { + Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => { BodyOwnerKind::Closure } node => bug!("{:#?} is not a body node", node), @@ -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) | @@ -634,7 +634,7 @@ impl<'hir> Map<'hir> { Some(Node::TraitItem(_)) | Some(Node::ImplItem(_)) => true, Some(Node::Expr(e)) => { - match e.node { + match e.kind { ExprKind::Closure(..) => true, _ => false, } @@ -649,24 +649,24 @@ 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 { - node: TraitItemKind::Const(..), + kind: TraitItemKind::Const(..), .. }) | Node::ImplItem(&ImplItem { - node: ImplItemKind::Const(..), + kind: ImplItemKind::Const(..), .. }) | 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, } @@ -749,7 +749,7 @@ impl<'hir> Map<'hir> { Node::Item(_) | Node::ForeignItem(_) | Node::TraitItem(_) | - Node::Expr(Expr { node: ExprKind::Closure(..), ..}) | + Node::Expr(Expr { kind: ExprKind::Closure(..), ..}) | Node::ImplItem(_) => true, _ => false, } @@ -757,7 +757,7 @@ impl<'hir> Map<'hir> { let match_non_returning_block = |node: &Node<'_>| { match *node { Node::Expr(ref expr) => { - match expr.node { + match expr.kind { ExprKind::Loop(..) | ExprKind::Ret(..) => 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 { self.walk_parent_nodes(hir_id, |node| match *node { Node::Item(i) => { - match i.node { + match i.kind { ItemKind::Fn(..) | ItemKind::Mod(..) | ItemKind::Enum(..) @@ -820,19 +820,19 @@ impl<'hir> Map<'hir> { } }, Node::ForeignItem(fi) => { - match fi.node { + match fi.kind { ForeignItemKind::Fn(..) => true, _ => false, } }, Node::TraitItem(ti) => { - match ti.node { + match ti.kind { TraitItemKind::Method(..) => true, _ => false, } }, Node::ImplItem(ii) => { - match ii.node { + match ii.kind { ImplItemKind::Method(..) => true, _ => false, } @@ -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)) @@ -948,7 +948,7 @@ impl<'hir> Map<'hir> { Node::Field(f) => f.ident.name, Node::Lifetime(lt) => lt.name.ident().name, Node::GenericParam(param) => param.name.ident().name, - Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name, + Node::Binding(&Pat { kind: PatKind::Binding(_, _, l, _), .. }) => l.name, Node::Ctor(..) => self.name(self.get_parent_item(id)), _ => bug!("no name for {}", self.node_to_string(id)) } @@ -968,7 +968,7 @@ impl<'hir> Map<'hir> { Some(Node::Variant(ref v)) => Some(&v.attrs[..]), Some(Node::Field(ref f)) => Some(&f.attrs[..]), Some(Node::Expr(ref e)) => Some(&*e.attrs), - Some(Node::Stmt(ref s)) => Some(s.node.attrs()), + Some(Node::Stmt(ref s)) => Some(s.kind.attrs()), Some(Node::Arm(ref a)) => Some(&*a.attrs), Some(Node::GenericParam(param)) => Some(¶m.attrs[..]), // Unit/tuple structs/variants take the attributes straight from @@ -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", @@ -1310,7 +1310,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String { format!("foreign item {}{}", path_str(), id_str) } Some(Node::ImplItem(ii)) => { - match ii.node { + match ii.kind { ImplItemKind::Const(..) => { format!("assoc const {} in {}{}", ii.ident, path_str(), id_str) } @@ -1326,7 +1326,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String { } } Some(Node::TraitItem(ti)) => { - let kind = match ti.node { + let kind = match ti.kind { TraitItemKind::Const(..) => "assoc constant", TraitItemKind::Method(..) => "trait method", TraitItemKind::Type(..) => "assoc type", diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 6fdc126e216aa..01cb5cc9bc105 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -479,7 +479,7 @@ impl GenericArgs { match arg { GenericArg::Lifetime(_) => {} GenericArg::Type(ref ty) => { - if let TyKind::Tup(ref tys) = ty.node { + if let TyKind::Tup(ref tys) = ty.kind { return tys; } break; @@ -869,7 +869,7 @@ pub struct Block { pub struct Pat { #[stable_hasher(ignore)] pub hir_id: HirId, - pub node: PatKind, + pub kind: PatKind, pub span: Span, } @@ -888,7 +888,7 @@ impl Pat { } use PatKind::*; - match &self.node { + match &self.kind { Wild | Lit(_) | Range(..) | Binding(.., None) | Path(_) => true, Box(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_short_(it), Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)), @@ -919,7 +919,7 @@ impl Pat { } use PatKind::*; - match &self.node { + match &self.kind { Wild | Lit(_) | Range(..) | Binding(.., None) | Path(_) => {}, Box(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_(it), Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)), @@ -1221,7 +1221,7 @@ impl UnOp { #[derive(RustcEncodable, RustcDecodable)] pub struct Stmt { pub hir_id: HirId, - pub node: StmtKind, + pub kind: StmtKind, pub span: Span, } @@ -1295,7 +1295,7 @@ impl Arm { // HACK(or_patterns; Centril | dlrobertson): Remove this and // correctly handle each case in which this method is used. pub fn top_pats_hack(&self) -> &[P] { - match &self.pat.node { + match &self.pat.kind { PatKind::Or(pats) => pats, _ => std::slice::from_ref(&self.pat), } @@ -1434,7 +1434,7 @@ pub struct AnonConst { #[derive(RustcEncodable, RustcDecodable)] pub struct Expr { pub hir_id: HirId, - pub node: ExprKind, + pub kind: ExprKind, pub attrs: ThinVec, pub span: Span, } @@ -1445,7 +1445,7 @@ static_assert_size!(Expr, 72); impl Expr { pub fn precedence(&self) -> ExprPrecedence { - match self.node { + match self.kind { ExprKind::Box(_) => ExprPrecedence::Box, ExprKind::Array(_) => ExprPrecedence::Array, ExprKind::Call(..) => ExprPrecedence::Call, @@ -1478,7 +1478,7 @@ impl Expr { } pub fn is_place_expr(&self) -> bool { - match self.node { + match self.kind { ExprKind::Path(QPath::Resolved(_, ref path)) => { match path.res { Res::Local(..) @@ -1830,7 +1830,7 @@ pub struct TraitItem { pub hir_id: HirId, pub attrs: HirVec, pub generics: Generics, - pub node: TraitItemKind, + pub kind: TraitItemKind, pub span: Span, } @@ -1873,7 +1873,7 @@ pub struct ImplItem { pub defaultness: Defaultness, pub attrs: HirVec, pub generics: Generics, - pub node: ImplItemKind, + pub kind: ImplItemKind, pub span: Span, } @@ -1939,7 +1939,7 @@ impl TypeBinding { #[derive(RustcEncodable, RustcDecodable)] pub struct Ty { pub hir_id: HirId, - pub node: TyKind, + pub kind: TyKind, pub span: Span, } @@ -2416,7 +2416,7 @@ pub struct Item { pub ident: Ident, pub hir_id: HirId, pub attrs: HirVec, - pub node: ItemKind, + pub kind: ItemKind, pub vis: Visibility, pub span: Span, } @@ -2581,7 +2581,7 @@ pub struct ForeignItem { #[stable_hasher(project(name))] pub ident: Ident, pub attrs: HirVec, - pub node: ForeignItemKind, + pub kind: ForeignItemKind, pub hir_id: HirId, pub span: Span, pub vis: Visibility, diff --git a/src/librustc/hir/pat_util.rs b/src/librustc/hir/pat_util.rs index 118e168f87767..feb0d97822c42 100644 --- a/src/librustc/hir/pat_util.rs +++ b/src/librustc/hir/pat_util.rs @@ -45,7 +45,7 @@ impl EnumerateAndAdjustIterator for T { impl hir::Pat { pub fn is_refutable(&self) -> bool { - match self.node { + match self.kind { PatKind::Lit(_) | PatKind::Range(..) | PatKind::Path(hir::QPath::Resolved(Some(..), _)) | @@ -68,7 +68,7 @@ impl hir::Pat { /// `match foo() { Some(a) => (), None => () }` pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident)) { self.walk(|p| { - if let PatKind::Binding(binding_mode, _, ident, _) = p.node { + if let PatKind::Binding(binding_mode, _, ident, _) = p.kind { f(binding_mode, p.hir_id, p.span, ident); } true @@ -83,7 +83,7 @@ impl hir::Pat { &self, f: &mut impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident), ) { - self.walk(|p| match &p.node { + self.walk(|p| match &p.kind { PatKind::Or(ps) => { ps[0].each_binding_or_first(f); false @@ -99,7 +99,7 @@ impl hir::Pat { /// Checks if the pattern contains any patterns that bind something to /// an ident, e.g., `foo`, or `Foo(foo)` or `foo @ Bar(..)`. pub fn contains_bindings(&self) -> bool { - self.satisfies(|p| match p.node { + self.satisfies(|p| match p.kind { PatKind::Binding(..) => true, _ => false, }) @@ -108,7 +108,7 @@ impl hir::Pat { /// Checks if the pattern contains any patterns that bind something to /// an ident or wildcard, e.g., `foo`, or `Foo(_)`, `foo @ Bar(..)`, pub fn contains_bindings_or_wild(&self) -> bool { - self.satisfies(|p| match p.node { + self.satisfies(|p| match p.kind { PatKind::Binding(..) | PatKind::Wild => true, _ => false, }) @@ -129,7 +129,7 @@ impl hir::Pat { } pub fn simple_ident(&self) -> Option { - match self.node { + match self.kind { PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) | PatKind::Binding(hir::BindingAnnotation::Mutable, _, ident, None) => Some(ident), _ => None, @@ -139,7 +139,7 @@ impl hir::Pat { /// Returns variants that are necessary to exist for the pattern to match. pub fn necessary_variants(&self) -> Vec { let mut variants = vec![]; - self.walk(|p| match &p.node { + self.walk(|p| match &p.kind { PatKind::Or(_) => false, PatKind::Path(hir::QPath::Resolved(_, path)) | PatKind::TupleStruct(hir::QPath::Resolved(_, path), ..) | diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 3cbc9ebec0ad8..91f2c5a0aaf85 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -286,7 +286,7 @@ impl<'a> State<'a> { pub fn print_type(&mut self, ty: &hir::Ty) { self.maybe_print_comment(ty.span.lo()); self.ibox(0); - match ty.node { + match ty.kind { hir::TyKind::Slice(ref ty) => { self.s.word("["); self.print_type(&ty); @@ -372,7 +372,7 @@ impl<'a> State<'a> { self.hardbreak_if_not_bol(); self.maybe_print_comment(item.span.lo()); self.print_outer_attributes(&item.attrs); - match item.node { + match item.kind { hir::ForeignItemKind::Fn(ref decl, ref arg_names, ref generics) => { self.head(""); self.print_fn(decl, @@ -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 { @@ -858,7 +858,7 @@ impl<'a> State<'a> { self.hardbreak_if_not_bol(); self.maybe_print_comment(ti.span.lo()); self.print_outer_attributes(&ti.attrs); - match ti.node { + match ti.kind { hir::TraitItemKind::Const(ref ty, default) => { let vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityKind::Inherited }; @@ -896,7 +896,7 @@ impl<'a> State<'a> { self.print_outer_attributes(&ii.attrs); self.print_defaultness(ii.defaultness); - match ii.node { + match ii.kind { hir::ImplItemKind::Const(ref ty, expr) => { self.print_associated_const(ii.ident, &ty, Some(expr), &ii.vis); } @@ -944,7 +944,7 @@ impl<'a> State<'a> { pub fn print_stmt(&mut self, st: &hir::Stmt) { self.maybe_print_comment(st.span.lo()); - match st.node { + match st.kind { hir::StmtKind::Local(ref loc) => { self.print_local(loc.init.as_deref(), |this| this.print_local_decl(&loc)); } @@ -961,7 +961,7 @@ impl<'a> State<'a> { self.s.word(";"); } } - if stmt_ends_with_semi(&st.node) { + if stmt_ends_with_semi(&st.kind) { self.s.word(";"); } self.maybe_print_trailing_comment(st.span, None) @@ -1035,7 +1035,7 @@ impl<'a> State<'a> { /// Print an expr using syntax that's acceptable in a condition position, such as the `cond` in /// `if cond { ... }`. pub fn print_expr_as_cond(&mut self, expr: &hir::Expr) { - let needs_par = match expr.node { + let needs_par = match expr.kind { // These cases need parens due to the parse error observed in #26461: `if return {}` // parses as the erroneous construct `if (return {})`, not `if (return) {}`. hir::ExprKind::Closure(..) | @@ -1119,11 +1119,10 @@ impl<'a> State<'a> { } fn print_expr_call(&mut self, func: &hir::Expr, args: &[hir::Expr]) { - let prec = - match func.node { - hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN, - _ => parser::PREC_POSTFIX, - }; + let prec = match func.kind { + hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN, + _ => parser::PREC_POSTFIX, + }; self.print_expr_maybe_paren(func, prec); self.print_call_post(args) @@ -1161,7 +1160,7 @@ impl<'a> State<'a> { Fixity::None => (prec + 1, prec + 1), }; - let left_prec = match (&lhs.node, op.node) { + let left_prec = match (&lhs.kind, op.node) { // These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is // the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead // of `(x as i32) < ...`. We need to convince it _not_ to do that. @@ -1200,7 +1199,7 @@ impl<'a> State<'a> { self.print_outer_attributes(&expr.attrs); self.ibox(INDENT_UNIT); self.ann.pre(self, AnnNode::Expr(expr)); - match expr.node { + match expr.kind { hir::ExprKind::Box(ref expr) => { self.word_space("box"); self.print_expr_maybe_paren(expr, parser::PREC_PREFIX); @@ -1618,7 +1617,7 @@ impl<'a> State<'a> { self.ann.pre(self, AnnNode::Pat(pat)); // Pat isn't normalized, but the beauty of it // is that it doesn't matter - match pat.node { + match pat.kind { PatKind::Wild => self.s.word("_"), PatKind::Binding(binding_mode, _, ident, ref sub) => { match binding_mode { @@ -1711,7 +1710,7 @@ impl<'a> State<'a> { self.pclose(); } PatKind::Box(ref inner) => { - let is_range_inner = match inner.node { + let is_range_inner = match inner.kind { PatKind::Range(..) => true, _ => false, }; @@ -1725,7 +1724,7 @@ impl<'a> State<'a> { } } PatKind::Ref(ref inner, mutbl) => { - let is_range_inner = match inner.node { + let is_range_inner = match inner.kind { PatKind::Range(..) => true, _ => false, }; @@ -1758,7 +1757,7 @@ impl<'a> State<'a> { if !before.is_empty() { self.word_space(","); } - if let PatKind::Wild = p.node { + if let PatKind::Wild = p.kind { // Print nothing. } else { self.print_pat(&p); @@ -1803,7 +1802,7 @@ impl<'a> State<'a> { } self.word_space("=>"); - match arm.body.node { + match arm.body.kind { hir::ExprKind::Block(ref blk, opt_label) => { if let Some(label) = opt_label { self.print_ident(label.ident); @@ -1881,7 +1880,7 @@ impl<'a> State<'a> { s.ann.nested(s, Nested::BodyParamPat(body_id, i)); i += 1; - if let hir::TyKind::Infer = ty.node { + if let hir::TyKind::Infer = ty.kind { // Print nothing. } else { s.s.word(":"); @@ -2222,7 +2221,7 @@ impl<'a> State<'a> { // // Duplicated from `parse::classify`, but adapted for the HIR. fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool { - match e.node { + match e.kind { hir::ExprKind::Match(..) | hir::ExprKind::Block(..) | hir::ExprKind::Loop(..) => false, @@ -2273,7 +2272,7 @@ fn bin_op_to_assoc_op(op: hir::BinOpKind) -> AssocOp { /// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and /// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not. fn contains_exterior_struct_lit(value: &hir::Expr) -> bool { - match value.node { + match value.kind { hir::ExprKind::Struct(..) => true, hir::ExprKind::Assign(ref lhs, ref rhs) | diff --git a/src/librustc/hir/upvars.rs b/src/librustc/hir/upvars.rs index cc532cb064ebe..5c5f7f6120082 100644 --- a/src/librustc/hir/upvars.rs +++ b/src/librustc/hir/upvars.rs @@ -47,7 +47,7 @@ impl Visitor<'tcx> for LocalCollector { } fn visit_pat(&mut self, pat: &'tcx hir::Pat) { - if let hir::PatKind::Binding(_, hir_id, ..) = pat.node { + if let hir::PatKind::Binding(_, hir_id, ..) = pat.kind { self.locals.insert(hir_id); } intravisit::walk_pat(self, pat); @@ -82,7 +82,7 @@ impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - if let hir::ExprKind::Closure(..) = expr.node { + if let hir::ExprKind::Closure(..) = expr.kind { let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id); if let Some(upvars) = self.tcx.upvars(closure_def_id) { // Every capture of a closure expression is a local in scope, diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 6e6492d0426f2..8e74f1e11eb51 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -144,11 +144,11 @@ impl<'a> HashStable> for hir::Ty { hcx.while_hashing_hir_bodies(true, |hcx| { let hir::Ty { hir_id: _, - ref node, + ref kind, ref span, } = *self; - node.hash_stable(hcx, hasher); + kind.hash_stable(hcx, hasher); span.hash_stable(hcx, hasher); }) } @@ -158,7 +158,7 @@ impl_stable_hash_for_spanned!(hir::BinOpKind); impl_stable_hash_for!(struct hir::Stmt { hir_id, - node, + kind, span, }); @@ -173,12 +173,12 @@ impl<'a> HashStable> for hir::Expr { let hir::Expr { hir_id: _, ref span, - ref node, + ref kind, ref attrs } = *self; span.hash_stable(hcx, hasher); - node.hash_stable(hcx, hasher); + kind.hash_stable(hcx, hasher); attrs.hash_stable(hcx, hasher); }) } @@ -200,7 +200,7 @@ impl<'a> HashStable> for hir::TraitItem { ident, ref attrs, ref generics, - ref node, + ref kind, span } = *self; @@ -208,7 +208,7 @@ impl<'a> HashStable> for hir::TraitItem { ident.name.hash_stable(hcx, hasher); attrs.hash_stable(hcx, hasher); generics.hash_stable(hcx, hasher); - node.hash_stable(hcx, hasher); + kind.hash_stable(hcx, hasher); span.hash_stable(hcx, hasher); }); } @@ -226,7 +226,7 @@ impl<'a> HashStable> for hir::ImplItem { defaultness, ref attrs, ref generics, - ref node, + ref kind, span } = *self; @@ -236,7 +236,7 @@ impl<'a> HashStable> for hir::ImplItem { defaultness.hash_stable(hcx, hasher); attrs.hash_stable(hcx, hasher); generics.hash_stable(hcx, hasher); - node.hash_stable(hcx, hasher); + kind.hash_stable(hcx, hasher); span.hash_stable(hcx, hasher); }); } @@ -312,7 +312,7 @@ impl<'a> HashStable> for hir::Item { ident, ref attrs, hir_id: _, - ref node, + ref kind, ref vis, span } = *self; @@ -320,7 +320,7 @@ impl<'a> HashStable> 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); }); diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index a33181e5925cd..91c6c968f9853 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -142,7 +142,7 @@ impl_stable_hash_for!(enum ::syntax::ast::LitIntType { }); impl_stable_hash_for!(struct ::syntax::ast::Lit { - node, + kind, token, span }); @@ -361,7 +361,7 @@ impl_stable_hash_for!(enum ::syntax::ast::NestedMetaItem { impl_stable_hash_for!(struct ::syntax::ast::MetaItem { path, - node, + kind, span }); diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index f28a52a1d8d7d..d31b527a55b69 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -90,7 +90,7 @@ impl<'tcx> TyCtxt<'tcx> { let span = scope.span(self, region_scope_tree); let tag = match self.hir().find(scope.hir_id(region_scope_tree)) { Some(Node::Block(_)) => "block", - Some(Node::Expr(expr)) => match expr.node { + Some(Node::Expr(expr)) => match expr.kind { hir::ExprKind::Call(..) => "call", hir::ExprKind::MethodCall(..) => "method call", hir::ExprKind::Match(.., hir::MatchSource::IfLetDesugar { .. }) => "if let", @@ -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", @@ -260,14 +260,14 @@ impl<'tcx> TyCtxt<'tcx> { } fn trait_item_scope_tag(item: &hir::TraitItem) -> &'static str { - match item.node { + match item.kind { hir::TraitItemKind::Method(..) => "method body", hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => "associated item", } } fn impl_item_scope_tag(item: &hir::ImplItem) -> &'static str { - match item.node { + match item.kind { hir::ImplItemKind::Method(..) => "method body", hir::ImplItemKind::Const(..) | hir::ImplItemKind::OpaqueTy(..) @@ -639,7 +639,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { hir::MatchSource::TryDesugar => { if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found { let discrim_expr = self.tcx.hir().expect_expr(discrim_hir_id); - let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.node { + let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.kind { let arg_expr = args.first().expect("try desugaring call w/out arg"); self.in_progress_tables.and_then(|tables| { tables.borrow().expr_ty_opt(arg_expr) diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index d56a6cf1f7bcb..1df60dfc63ef3 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -92,10 +92,10 @@ impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr) { if let (ExprKind::Closure(_, _fn_decl, _id, _sp, _), Some(_)) = ( - &expr.node, + &expr.kind, self.node_matches_type(expr.hir_id), ) { - self.found_closure = Some(&expr.node); + self.found_closure = Some(&expr.kind); } intravisit::walk_expr(self, expr); } @@ -114,7 +114,7 @@ fn closure_return_type_suggestion( FunctionRetTy::DefaultReturn(_) => ("-> ", " "), _ => ("", ""), }; - let suggestion = match body.value.node { + let suggestion = match body.value.kind { ExprKind::Block(..) => { vec![(output.span(), format!("{}{}{}", arrow, ret, post))] } diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index 34f3b8a2c7205..9c362a5e20791 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -31,15 +31,15 @@ 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 { - node: hir::TraitItemKind::Method(ref m, ..), + kind: hir::TraitItemKind::Method(ref m, ..), .. }) | Node::ImplItem(&hir::ImplItem { - node: hir::ImplItemKind::Method(ref m, ..), + kind: hir::ImplItemKind::Method(ref m, ..), .. }) => &m.decl, _ => return None, @@ -98,7 +98,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> { } fn visit_ty(&mut self, arg: &'tcx hir::Ty) { - match arg.node { + match arg.kind { hir::TyKind::BareFn(_) => { self.current_index.shift_in(1); intravisit::walk_ty(self, arg); diff --git a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs index 604115cfc3711..a9a2c15d7d99b 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs @@ -87,7 +87,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { return None; } if let FunctionRetTy::Return(ty) = &fndecl.output { - if let (TyKind::Def(_, _), ty::ReStatic) = (&ty.node, sub) { + if let (TyKind::Def(_, _), ty::ReStatic) = (&ty.kind, sub) { // This is an impl Trait return that evaluates de need of 'static. // We handle this case better in `static_impl_trait`. return None; diff --git a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs index f5a4dac2c2cb8..9231e4f779eb7 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs @@ -50,7 +50,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { let hir = &self.tcx().hir(); if let Some(hir_id) = hir.as_local_hir_id(free_region.scope) { if let Node::Expr(Expr { - node: Closure(_, _, _, closure_span, None), + kind: Closure(_, _, _, closure_span, None), .. }) = hir.get(hir_id) { let sup_sp = sup_origin.span(); diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 0b746e5dfb623..3b3649fd8112f 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -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), @@ -1060,7 +1060,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> { (def_scope_default(), hir::OpaqueTyOrigin::TypeAlias) } }, - Some(Node::ImplItem(item)) => match item.node { + Some(Node::ImplItem(item)) => match item.kind { hir::ImplItemKind::OpaqueTy(_) => ( may_define_opaque_type( tcx, diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 3483efbd8408f..fa73a3c6c4628 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -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); diff --git a/src/librustc/lint/internal.rs b/src/librustc/lint/internal.rs index 13834eaf40f57..a08722e940295 100644 --- a/src/librustc/lint/internal.rs +++ b/src/librustc/lint/internal.rs @@ -94,7 +94,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyTyKind { } fn check_ty(&mut self, cx: &LateContext<'_, '_>, ty: &'tcx Ty) { - match &ty.node { + match &ty.kind { TyKind::Path(qpath) => { if let QPath::Resolved(_, path) = qpath { if let Some(last) = path.segments.iter().last() { @@ -169,7 +169,7 @@ fn lint_ty_kind_usage(cx: &LateContext<'_, '_>, segment: &PathSegment) -> bool { } fn is_ty_or_ty_ctxt(cx: &LateContext<'_, '_>, ty: &Ty) -> Option { - match &ty.node { + match &ty.kind { TyKind::Path(qpath) => { if let QPath::Resolved(_, path) = qpath { let did = path.res.opt_def_id()?; @@ -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(); diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index cbc6dbdba7e6c..16d19e41db4f4 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -218,7 +218,7 @@ impl<'a> LintLevelsBuilder<'a> { let mut reason = None; let tail_li = &metas[metas.len()-1]; if let Some(item) = tail_li.meta_item() { - match item.node { + match item.kind { ast::MetaItemKind::Word => {} // actual lint names handled later ast::MetaItemKind::NameValue(ref name_value) => { if item.path == sym::reason { @@ -226,7 +226,7 @@ impl<'a> LintLevelsBuilder<'a> { metas = &metas[0..metas.len()-1]; // FIXME (#55112): issue unused-attributes lint if we thereby // don't have any lint names (`#[level(reason = "foo")]`) - if let ast::LitKind::Str(rationale, _) = name_value.node { + if let ast::LitKind::Str(rationale, _) = name_value.kind { if !self.sess.features_untracked().lint_reasons { feature_gate::emit_feature_err( &self.sess.parse_sess, @@ -264,7 +264,7 @@ impl<'a> LintLevelsBuilder<'a> { let mut err = bad_attr(sp); let mut add_label = true; if let Some(item) = li.meta_item() { - if let ast::MetaItemKind::NameValue(_) = item.node { + if let ast::MetaItemKind::NameValue(_) = item.kind { if item.path == sym::reason { err.span_label(sp, "reason in lint attribute must come last"); add_label = false; diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 821ede37229b5..7c75a1447e26d 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -133,7 +133,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { _ => span_bug!(lhs.span, "non-ADT in struct pattern") }; for pat in pats { - if let PatKind::Wild = pat.pat.node { + if let PatKind::Wild = pat.pat.kind { continue; } let index = self.tcx.field_index(pat.hir_id, self.tables); @@ -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); @@ -236,7 +236,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) => { let res = self.tables.qpath_res(qpath, expr.hir_id); self.handle_res(res); @@ -269,7 +269,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> { } fn visit_pat(&mut self, pat: &'tcx hir::Pat) { - match pat.node { + match pat.kind { PatKind::Struct(ref path, ref fields, _) => { let res = self.tables.qpath_res(path, pat.hir_id); self.handle_field_pattern_match(pat, res, fields); @@ -292,7 +292,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> { } fn visit_ty(&mut self, ty: &'tcx hir::Ty) { - match ty.node { + match ty.kind { TyKind::Def(item_id, _) => { let item = self.tcx.hir().expect_item(item_id.id); intravisit::walk_item(self, item); @@ -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)); @@ -384,7 +384,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { hir::ItemKind::Trait(.., ref trait_item_refs) => { for trait_item_ref in trait_item_refs { let trait_item = self.krate.trait_item(trait_item_ref.id); - match trait_item.node { + match trait_item.kind { hir::TraitItemKind::Const(_, Some(_)) | hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => { if has_allow_dead_code_or_lang_attr(self.tcx, @@ -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 { @@ -613,7 +613,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> { fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem) { if self.should_warn_about_foreign_item(fi) { self.warn_dead_code(fi.hir_id, fi.span, fi.ident.name, - fi.node.descriptive_variant(), "used"); + fi.kind.descriptive_variant(), "used"); } intravisit::walk_foreign_item(self, fi); } @@ -626,7 +626,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> { } fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) { - match impl_item.node { + match impl_item.kind { hir::ImplItemKind::Const(_, body_id) => { if !self.symbol_is_live(impl_item.hir_id) { self.warn_dead_code(impl_item.hir_id, @@ -652,7 +652,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> { // Overwrite so that we don't warn the trait item itself. fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) { - match trait_item.node { + match trait_item.kind { hir::TraitItemKind::Const(_, Some(body_id)) | hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)) => { self.visit_nested_body(body_id) diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index ba27d332e43f7..660fe14ba0700 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -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 diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 1b1491a8febff..45b660f5c67f6 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -397,7 +397,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.walk_adjustment(expr); - match expr.node { + match expr.kind { hir::ExprKind::Path(_) => { } hir::ExprKind::Type(ref subexpr, _) => { @@ -590,7 +590,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } fn walk_stmt(&mut self, stmt: &hir::Stmt) { - match stmt.node { + match stmt.kind { hir::StmtKind::Local(ref local) => { self.walk_local(&local); } @@ -812,7 +812,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr, pat); return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| { - if let PatKind::Binding(..) = pat.node { + if let PatKind::Binding(..) = pat.kind { let bm = *self.mc.tables.pat_binding_modes() .get(pat.hir_id) .expect("missing binding mode"); @@ -839,7 +839,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { let tcx = self.tcx(); let ExprUseVisitor { ref mc, ref mut delegate, param_env } = *self; return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |cmt_pat, pat| { - if let PatKind::Binding(_, canonical_id, ..) = pat.node { + if let PatKind::Binding(_, canonical_id, ..) = pat.kind { debug!( "walk_pat: binding cmt_pat={:?} pat={:?} match_mode={:?}", cmt_pat, @@ -885,7 +885,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { // to the above loop's visit of than the bindings that form // the leaves of the pattern tree structure. return_if_err!(mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| { - let qpath = match pat.node { + let qpath = match pat.kind { PatKind::Path(ref qpath) | PatKind::TupleStruct(ref qpath, ..) | PatKind::Struct(ref qpath, ..) => qpath, diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 73a2e7dff6b15..ecca62349c985 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -150,7 +150,7 @@ impl Visitor<'tcx> for ExprVisitor<'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - let res = if let hir::ExprKind::Path(ref qpath) = expr.node { + let res = if let hir::ExprKind::Path(ref qpath) = expr.kind { self.tables.qpath_res(qpath, expr.hir_id) } else { Res::Err diff --git a/src/librustc/middle/lib_features.rs b/src/librustc/middle/lib_features.rs index 0d6d016e50701..2d726fcd17612 100644 --- a/src/librustc/middle/lib_features.rs +++ b/src/librustc/middle/lib_features.rs @@ -59,7 +59,7 @@ impl LibFeatureCollector<'tcx> { attr.check_name(**stab_attr) }) { let meta_item = attr.meta(); - if let Some(MetaItem { node: MetaItemKind::List(ref metas), .. }) = meta_item { + if let Some(MetaItem { kind: MetaItemKind::List(ref metas), .. }) = meta_item { let mut feature = None; let mut since = None; for meta in metas { diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 9f6611712a8aa..a654a26eb0b76 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -372,7 +372,7 @@ fn visit_fn<'tcx>( let body = ir.tcx.hir().body(body_id); for param in &body.params { - let is_shorthand = match param.pat.node { + let is_shorthand = match param.pat.kind { crate::hir::PatKind::Struct(..) => true, _ => false, }; @@ -412,7 +412,7 @@ fn add_from_pat(ir: &mut IrMaps<'_>, pat: &P) { pats.push_back(pat); while let Some(pat) = pats.pop_front() { use crate::hir::PatKind::*; - match &pat.node { + match &pat.kind { Binding(.., inner_pat) => { pats.extend(inner_pat.iter()); } @@ -456,7 +456,7 @@ fn visit_arm<'tcx>(ir: &mut IrMaps<'tcx>, arm: &'tcx hir::Arm) { } fn visit_expr<'tcx>(ir: &mut IrMaps<'tcx>, expr: &'tcx Expr) { - match expr.node { + match expr.kind { // live nodes required for uses or definitions of variables: hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { debug!("expr {}: path that leads to {:?}", expr.hir_id, path.res); @@ -947,7 +947,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn propagate_through_stmt(&mut self, stmt: &hir::Stmt, succ: LiveNode) -> LiveNode { - match stmt.node { + match stmt.kind { hir::StmtKind::Local(ref local) => { // Note: we mark the variable as defined regardless of whether // there is an initializer. Initially I had thought to only mark @@ -991,7 +991,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { -> LiveNode { debug!("propagate_through_expr: {}", self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id)); - match expr.node { + match expr.kind { // Interesting cases with control flow or which gen/kill hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { self.access_path(expr.hir_id, path, succ, ACC_READ | ACC_USE) @@ -1259,7 +1259,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // these errors are detected in the later pass borrowck. We // just ignore such cases and treat them as reads. - match expr.node { + match expr.kind { hir::ExprKind::Path(_) => succ, hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ), _ => self.propagate_through_expr(expr, succ) @@ -1268,7 +1268,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // see comment on propagate_through_place() fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32) -> LiveNode { - match expr.node { + match expr.kind { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { self.access_path(expr.hir_id, path, succ, acc) } @@ -1377,7 +1377,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> { } fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Assign(ref l, _) => { this.check_place(&l); } @@ -1420,7 +1420,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) { impl<'tcx> Liveness<'_, 'tcx> { fn check_place(&mut self, expr: &'tcx Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { if let Res::Local(var_hid) = path.res { let upvars = self.ir.tcx.upvars(self.ir.body_owner); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index e0149a3b9de55..c6a46f60927e8 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -271,7 +271,7 @@ impl MutabilityCategory { id: hir::HirId, ) -> MutabilityCategory { let ret = match tcx.hir().get(id) { - Node::Binding(p) => match p.node { + Node::Binding(p) => match p.kind { PatKind::Binding(..) => { let bm = *tables.pat_binding_modes() .get(p.hir_id) @@ -486,7 +486,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { // This code detects whether we are looking at a `ref x`, // and if so, figures out what the type *being borrowed* is. - let ret_ty = match pat.node { + let ret_ty = match pat.kind { PatKind::Binding(..) => { let bm = *self.tables .pat_binding_modes() @@ -577,7 +577,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr); let expr_ty = self.expr_ty(expr)?; - match expr.node { + match expr.kind { hir::ExprKind::Unary(hir::UnDeref, ref e_base) => { if self.tables.is_method_call(expr) { self.cat_overloaded_place(expr, e_base, NoteNone) @@ -1212,7 +1212,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { // that (where the `ref` on `x` is implied). op(cmt.clone(), pat); - match pat.node { + match pat.kind { PatKind::TupleStruct(ref qpath, ref subpats, ddpos) => { let res = self.tables.qpath_res(qpath, pat.hir_id); let (cmt, expected_len) = match res { diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index c2bcd46216324..8be64bf64b5e9 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -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; } @@ -55,7 +55,7 @@ fn method_might_be_inlined( if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) { return true } - if let hir::ImplItemKind::Method(method_sig, _) = &impl_item.node { + if let hir::ImplItemKind::Method(method_sig, _) = &impl_item.kind { if method_sig.header.is_const() { return true } @@ -100,7 +100,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - let res = match expr.node { + let res = match expr.kind { hir::ExprKind::Path(ref qpath) => { Some(self.tables.qpath_res(qpath, expr.hir_id)) } @@ -157,14 +157,14 @@ 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, } } Some(Node::TraitItem(trait_method)) => { - match trait_method.node { + match trait_method.kind { hir::TraitItemKind::Const(_, ref default) => default.is_some(), hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true, hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) | @@ -172,7 +172,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } } Some(Node::ImplItem(impl_item)) => { - match impl_item.node { + match impl_item.kind { hir::ImplItemKind::Const(..) => true, hir::ImplItemKind::Method(..) => { let attrs = self.tcx.codegen_fn_attrs(def_id); @@ -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, @@ -286,7 +286,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } } Node::TraitItem(trait_method) => { - match trait_method.node { + match trait_method.kind { hir::TraitItemKind::Const(_, None) | hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => { // Keep going, nothing to get exported @@ -299,7 +299,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } } Node::ImplItem(impl_item) => { - match impl_item.node { + match impl_item.kind { hir::ImplItemKind::Const(_, body) => { self.visit_nested_body(body); } @@ -313,7 +313,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { hir::ImplItemKind::TyAlias(_) => {} } } - Node::Expr(&hir::Expr { node: hir::ExprKind::Closure(.., body, _, _), .. }) => { + Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(.., body, _, _), .. }) => { self.visit_nested_body(body); } // Nothing to recurse on for these @@ -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)); diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 87470140e3148..28bf88321ae66 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -796,7 +796,7 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h // index information.) for (i, statement) in blk.stmts.iter().enumerate() { - match statement.node { + match statement.kind { hir::StmtKind::Local(..) | hir::StmtKind::Item(..) => { // Each declaration introduces a subscope for bindings @@ -850,7 +850,7 @@ fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir visitor.record_child_scope(Scope { id: pat.hir_id.local_id, data: ScopeData::Node }); // If this is a binding then record the lifetime of that binding. - if let PatKind::Binding(..) = pat.node { + if let PatKind::Binding(..) = pat.kind { record_var_lifetime(visitor, pat.hir_id.local_id, pat.span); } @@ -893,7 +893,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h let mut terminating = |id: hir::ItemLocalId| { terminating_scopes.insert(id); }; - match expr.node { + match expr.kind { // Conditional or repeating scopes are always terminating // scopes, meaning that temporaries cannot outlive them. // This ensures fixed size stacks. @@ -996,7 +996,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h // properly, we can't miss any types. - match expr.node { + match expr.kind { // Manually recurse over closures, because they are the only // case of nested bodies that share the parent environment. hir::ExprKind::Closure(.., body, _, _) => { @@ -1053,7 +1053,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h debug!("resolve_expr post-increment {}, expr = {:?}", visitor.expr_and_pat_count, expr); - if let hir::ExprKind::Yield(_, source) = &expr.node { + if let hir::ExprKind::Yield(_, source) = &expr.kind { // Mark this expr's scope and all parent scopes as containing `yield`. let mut scope = Scope { id: expr.hir_id.local_id, data: ScopeData::Node }; loop { @@ -1198,7 +1198,7 @@ fn resolve_local<'tcx>( // In the former case (the implicit ref version), the temporary is created by the // & expression, and its lifetime would be extended to the end of the block (due // to a different rule, not the below code). - match pat.node { + match pat.kind { PatKind::Binding(hir::BindingAnnotation::Ref, ..) | PatKind::Binding(hir::BindingAnnotation::RefMut, ..) => true, @@ -1240,7 +1240,7 @@ fn resolve_local<'tcx>( expr: &hir::Expr, blk_id: Option, ) { - match expr.node { + match expr.kind { hir::ExprKind::AddrOf(_, ref subexpr) => { record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id); record_rvalue_scope(visitor, &subexpr, blk_id); @@ -1300,7 +1300,7 @@ fn resolve_local<'tcx>( // outer expression. visitor.scope_tree.record_rvalue_scope(expr.hir_id.local_id, blk_scope); - match expr.node { + match expr.kind { hir::ExprKind::AddrOf(_, ref subexpr) | hir::ExprKind::Unary(hir::UnDeref, ref subexpr) | hir::ExprKind::Field(ref subexpr, _) | diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index d833a34385b2d..94a85a97d36c9 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -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 @@ -541,7 +541,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { } fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) { - match item.node { + match item.kind { hir::ForeignItemKind::Fn(ref decl, _, ref generics) => { self.visit_early_late(None, decl, generics, |this| { intravisit::walk_foreign_item(this, item); @@ -558,8 +558,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_ty(&mut self, ty: &'tcx hir::Ty) { debug!("visit_ty: id={:?} ty={:?}", ty.hir_id, ty); - debug!("visit_ty: ty.node={:?}", ty.node); - match ty.node { + debug!("visit_ty: ty.kind={:?}", ty.kind); + match ty.kind { hir::TyKind::BareFn(ref c) => { let next_early_index = self.next_early_index(); let was_in_fn_syntax = self.is_in_fn_syntax; @@ -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 { @@ -778,7 +777,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) { use self::hir::TraitItemKind::*; - match trait_item.node { + match trait_item.kind { Method(ref sig, _) => { let tcx = self.tcx; self.visit_early_late( @@ -830,7 +829,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) { use self::hir::ImplItemKind::*; - match impl_item.node { + match impl_item.kind { Method(ref sig, _) => { let tcx = self.tcx; self.visit_early_late( @@ -1214,7 +1213,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { } fn expression_label(ex: &hir::Expr) -> Option { - if let hir::ExprKind::Loop(_, Some(label), _) = ex.node { + if let hir::ExprKind::Loop(_, Some(label), _) = ex.kind { Some(label.ident) } else { None @@ -1263,7 +1262,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap> { 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) @@ -1352,7 +1351,7 @@ fn object_lifetime_defaults_for_item( continue; } - let res = match data.bounded_ty.node { + let res = match data.bounded_ty.kind { hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => path.res, _ => continue, }; @@ -1487,7 +1486,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let mut elide_use = None; let mut find_arg_use_span = |inputs: &hir::HirVec| { for input in inputs { - match input.node { + match input.kind { hir::TyKind::Rptr(lt, _) => { if lt.name.ident() == name { // include the trailing whitespace between the lifetime and type names @@ -1525,12 +1524,12 @@ 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); } }, Node::ImplItem(impl_item) => { - if let hir::ImplItemKind::Method(sig, _) = &impl_item.node { + if let hir::ImplItemKind::Method(sig, _) = &impl_item.kind { find_arg_use_span(&sig.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,15 +1866,15 @@ 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 { - node: hir::TraitItemKind::Method(..), + kind: hir::TraitItemKind::Method(..), .. }) | Node::ImplItem(&hir::ImplItem { - node: hir::ImplItemKind::Method(..), + kind: hir::ImplItemKind::Method(..), .. }) => { let scope = self.tcx.hir().local_def_id(fn_id); @@ -2165,18 +2164,18 @@ 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), Node::TraitItem(&hir::TraitItem { - node: hir::TraitItemKind::Method(_, ref m), + kind: hir::TraitItemKind::Method(_, ref m), .. }) => { 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() @@ -2190,13 +2189,13 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } Node::ImplItem(&hir::ImplItem { - node: hir::ImplItemKind::Method(_, body), + kind: hir::ImplItemKind::Method(_, body), .. }) => { 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 @@ -2270,8 +2269,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } fn visit_ty(&mut self, ty: &'a hir::Ty) { - if let hir::TyKind::Rptr(lifetime_ref, ref mt) = ty.node { - if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.node + if let hir::TyKind::Rptr(lifetime_ref, ref mt) = ty.kind { + if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.kind { if self.is_self_ty(path.res) { if let Some(lifetime) = self.map.defs.get(&lifetime_ref.hir_id) { @@ -2286,7 +2285,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let mut visitor = SelfVisitor { map: self.map, - impl_self: impl_self.map(|ty| &ty.node), + impl_self: impl_self.map(|ty| &ty.kind), lifetime: Set1::Empty, }; visitor.visit_ty(&inputs[0]); @@ -2364,10 +2363,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } fn visit_ty(&mut self, ty: &hir::Ty) { - if let hir::TyKind::BareFn(_) = ty.node { + if let hir::TyKind::BareFn(_) = ty.kind { self.outer_index.shift_in(1); } - match ty.node { + match ty.kind { hir::TyKind::TraitObject(ref bounds, ref lifetime) => { for bound in bounds { self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None); @@ -2384,7 +2383,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { intravisit::walk_ty(self, ty); } } - if let hir::TyKind::BareFn(_) = ty.node { + if let hir::TyKind::BareFn(_) = ty.kind { self.outer_index.shift_out(1); } } @@ -2991,7 +2990,7 @@ fn insert_late_bound_lifetimes( } fn visit_ty(&mut self, ty: &'v hir::Ty) { - match ty.node { + match ty.kind { hir::TyKind::Path(hir::QPath::Resolved(Some(_), _)) | hir::TyKind::Path(hir::QPath::TypeRelative(..)) => { // ignore lifetimes appearing in associated type diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index c06a0feb6a993..9e053ce4e69c2 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -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) @@ -382,7 +382,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> { } fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem) { - 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_foreign_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 } diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index a9a20a924347c..73b731b07619d 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1879,11 +1879,11 @@ pub fn parse_cfgspecs(cfgspecs: Vec) -> FxHashSet<(String, Option { error!(r#"expected `key` or `key="value"`"#); } - MetaItemKind::NameValue(lit) if !lit.node.is_str() => { + MetaItemKind::NameValue(lit) if !lit.kind.is_str() => { error!("argument value must be a string"); } MetaItemKind::NameValue(..) | MetaItemKind::Word => { diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 0683940af985e..1ce5d72ba848e 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -956,7 +956,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let parent_node = self.tcx.hir().get_parent_node(hir_id); if let Some(Node::Local(ref local)) = self.tcx.hir().find(parent_node) { if let Some(ref expr) = local.init { - if let hir::ExprKind::Index(_, _) = expr.node { + if let hir::ExprKind::Index(_, _) = expr.kind { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) { err.span_suggestion( expr.span, @@ -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); @@ -1010,7 +1010,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { "{}({})", ident, body.params.iter() - .map(|arg| match &arg.pat.node { + .map(|arg| match &arg.pat.kind { hir::PatKind::Binding(_, _, ident, None) if ident.name != kw::SelfLower => ident.to_string(), _ => "_".to_string(), @@ -1106,11 +1106,11 @@ 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); - if let hir::ExprKind::Block(blk, _) = &body.value.node { + if let hir::ExprKind::Block(blk, _) = &body.value.kind { if decl.output.span().overlaps(span) && blk.expr.is_none() && "()" == &trait_ref.self_ty().to_string() { @@ -1134,14 +1134,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn get_fn_like_arguments(&self, node: Node<'_>) -> (Span, Vec) { match node { Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(_, ref _decl, id, span, _), + kind: hir::ExprKind::Closure(_, ref _decl, id, span, _), .. }) => { (self.tcx.sess.source_map().def_span(span), self.tcx.hir().body(id).params.iter() .map(|arg| { if let hir::Pat { - node: hir::PatKind::Tuple(ref args, _), + kind: hir::PatKind::Tuple(ref args, _), span, .. } = *arg.pat { @@ -1163,21 +1163,21 @@ 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 { span, - node: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _), + kind: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _), .. }) | Node::TraitItem(&hir::TraitItem { span, - node: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _), + kind: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _), .. }) => { (self.tcx.sess.source_map().def_span(span), decl.inputs.iter() - .map(|arg| match arg.clone().node { + .map(|arg| match arg.clone().kind { hir::TyKind::Tup(ref tys) => ArgKind::Tuple( Some(arg.span), vec![("_".to_owned(), "_".to_owned()); tys.len()] diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 6a99d12d1a425..6d0347563d003 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -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 diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 6c3bb3ebb7795..daf871463b2b6 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -604,7 +604,7 @@ impl<'tcx> TypeckTables<'tcx> { pub fn is_method_call(&self, expr: &hir::Expr) -> bool { // Only paths and method calls/overloaded operators have // entries in type_dependent_defs, ignore the former here. - if let hir::ExprKind::Path(_) = expr.node { + if let hir::ExprKind::Path(_) = expr.kind { return false; } @@ -1150,7 +1150,7 @@ impl<'tcx> TyCtxt<'tcx> { None => return Bound::Unbounded, }; for meta in attr.meta_item_list().expect("rustc_layout_scalar_valid_range takes args") { - match meta.literal().expect("attribute takes lit").node { + match meta.literal().expect("attribute takes lit").kind { ast::LitKind::Int(a, _) => return Bound::Included(a), _ => span_bug!(attr.span, "rustc_layout_scalar_valid_range expects int arg"), } @@ -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; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index bd5ac5e5ab478..f107af0cd07ec 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -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 { pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option { 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; } } diff --git a/src/librustc_ast_borrowck/borrowck/check_loans.rs b/src/librustc_ast_borrowck/borrowck/check_loans.rs index fcede3eae976f..dd2aeb4276faa 100644 --- a/src/librustc_ast_borrowck/borrowck/check_loans.rs +++ b/src/librustc_ast_borrowck/borrowck/check_loans.rs @@ -177,7 +177,7 @@ pub fn check_loans<'a, 'tcx>( let hir_id = bccx.tcx.hir().as_local_hir_id(def_id).unwrap(); let movable_generator = !match bccx.tcx.hir().get(hir_id) { Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), + kind: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), .. }) => true, _ => false, diff --git a/src/librustc_ast_borrowck/borrowck/mod.rs b/src/librustc_ast_borrowck/borrowck/mod.rs index 23d5480c60562..40e28299a5c0a 100644 --- a/src/librustc_ast_borrowck/borrowck/mod.rs +++ b/src/librustc_ast_borrowck/borrowck/mod.rs @@ -338,7 +338,7 @@ pub enum LoanPathElem<'tcx> { fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_>) -> HirId { let closure_id = tcx.hir().local_def_id_to_hir_id(closure_id); match tcx.hir().get(closure_id) { - Node::Expr(expr) => match expr.node { + Node::Expr(expr) => match expr.kind { hir::ExprKind::Closure(.., body_id, _, _) => { body_id.hir_id } diff --git a/src/librustc_ast_borrowck/cfg/construct.rs b/src/librustc_ast_borrowck/cfg/construct.rs index e2c5de648a276..ec7f40f8c9718 100644 --- a/src/librustc_ast_borrowck/cfg/construct.rs +++ b/src/librustc_ast_borrowck/cfg/construct.rs @@ -99,7 +99,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex { - let exit = match stmt.node { + let exit = match stmt.kind { hir::StmtKind::Local(ref local) => { let init_exit = self.opt_expr(&local.init, pred); self.pat(&local.pat, init_exit) @@ -114,7 +114,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex { - match pat.node { + match pat.kind { PatKind::Binding(.., None) | PatKind::Path(_) | PatKind::Lit(..) | @@ -163,7 +163,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex { - match expr.node { + match expr.kind { hir::ExprKind::Block(ref blk, _) => { let blk_exit = self.block(&blk, pred); self.add_ast_node(expr.hir_id.local_id, &[blk_exit]) diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 4fd971ca1153d..cba5ee3260c16 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -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() { @@ -249,7 +249,7 @@ impl CodegenCx<'ll, 'tcx> { } Node::ForeignItem(&hir::ForeignItem { - ref attrs, span, node: hir::ForeignItemKind::Static(..), .. + ref attrs, span, kind: hir::ForeignItemKind::Static(..), .. }) => { let fn_attrs = self.tcx.codegen_fn_attrs(def_id); (check_and_apply_linkage(&self, &fn_attrs, ty, sym, span), attrs) diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index 3e4b7695447c8..d634b73430a58 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -94,14 +94,14 @@ 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 { - node: hir::ImplItemKind::Method(..), + kind: hir::ImplItemKind::Method(..), .. }) => { let def_id = tcx.hir().local_def_id(hir_id); @@ -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; diff --git a/src/librustc_codegen_ssa/mono_item.rs b/src/librustc_codegen_ssa/mono_item.rs index 5801963c101ef..10177d2997a76 100644 --- a/src/librustc_codegen_ssa/mono_item.rs +++ b/src/librustc_codegen_ssa/mono_item.rs @@ -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") diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 4a8681367410e..774a5af1b1ca8 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -700,7 +700,7 @@ impl RustcDefaultCalls { let mut cfgs = sess.parse_sess.config.iter().filter_map(|&(name, ref value)| { let gated_cfg = GatedCfg::gate(&ast::MetaItem { path: ast::Path::from_ident(ast::Ident::with_dummy_span(name)), - node: ast::MetaItemKind::Word, + kind: ast::MetaItemKind::Word, span: DUMMY_SP, }); diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 837aa9360c895..abe0ffb0e02c5 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -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,20 +391,20 @@ impl DirtyCleanVisitor<'tcx> { &format!( "clean/dirty auto-assertions not yet defined \ for Node::Item.node={:?}", - item.node + item.kind ) ), } }, HirNode::TraitItem(item) => { - match item.node { + match item.kind { TraitItemKind::Method(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT), TraitItemKind::Const(..) => ("NodeTraitConst", LABELS_CONST_IN_TRAIT), TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_IN_TRAIT), } }, HirNode::ImplItem(item) => { - match item.node { + match item.kind { ImplItemKind::Method(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL), ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL), ImplItemKind::TyAlias(..) => ("NodeImplType", LABELS_CONST_IN_IMPL), diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index b81f814de0f4a..72df875fc8f4f 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -556,7 +556,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec ReplaceBodyWithLoop<'a> { fn should_ignore_fn(ret_ty: &ast::FnDecl) -> bool { if let ast::FunctionRetTy::Ty(ref ty) = ret_ty.output { fn involves_impl_trait(ty: &ast::Ty) -> bool { - match ty.node { + match ty.kind { ast::TyKind::ImplTrait(..) => true, ast::TyKind::Slice(ref subty) | ast::TyKind::Array(ref subty, _) | @@ -796,7 +796,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> { } fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> { - let is_const = match i.node { + let is_const = match i.kind { ast::TraitItemKind::Const(..) => true, ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) => header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl), @@ -806,7 +806,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> { } fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> { - let is_const = match i.node { + let is_const = match i.kind { ast::ImplItemKind::Const(..) => true, ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) => header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl), @@ -834,21 +834,21 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> { fn block_to_stmt(b: ast::Block, sess: &Session) -> ast::Stmt { let expr = P(ast::Expr { id: sess.next_node_id(), - node: ast::ExprKind::Block(P(b), None), + kind: ast::ExprKind::Block(P(b), None), span: syntax_pos::DUMMY_SP, attrs: ThinVec::new(), }); ast::Stmt { id: sess.next_node_id(), - node: ast::StmtKind::Expr(expr), + kind: ast::StmtKind::Expr(expr), span: syntax_pos::DUMMY_SP, } } let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess); let loop_expr = P(ast::Expr { - node: ast::ExprKind::Loop(P(empty_block), None), + kind: ast::ExprKind::Loop(P(empty_block), None), id: self.sess.next_node_id(), span: syntax_pos::DUMMY_SP, attrs: ThinVec::new(), @@ -857,7 +857,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> { let loop_stmt = ast::Stmt { id: self.sess.next_node_id(), span: syntax_pos::DUMMY_SP, - node: ast::StmtKind::Expr(loop_expr), + kind: ast::StmtKind::Expr(loop_expr), }; if self.within_static_or_const { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index d08fd47dc169e..d0a7eab071c31 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -67,7 +67,7 @@ declare_lint_pass!(WhileTrue => [WHILE_TRUE]); /// Traverse through any amount of parenthesis and return the first non-parens expression. fn pierce_parens(mut expr: &ast::Expr) -> &ast::Expr { - while let ast::ExprKind::Paren(sub) = &expr.node { + while let ast::ExprKind::Paren(sub) = &expr.kind { expr = sub; } expr @@ -75,9 +75,9 @@ fn pierce_parens(mut expr: &ast::Expr) -> &ast::Expr { impl EarlyLintPass for WhileTrue { fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { - if let ast::ExprKind::While(cond, ..) = &e.node { - if let ast::ExprKind::Lit(ref lit) = pierce_parens(cond).node { - if let ast::LitKind::Bool(true) = lit.node { + if let ast::ExprKind::While(cond, ..) = &e.kind { + if let ast::ExprKind::Lit(ref lit) = pierce_parens(cond).kind { + if let ast::LitKind::Bool(true) = lit.kind { if !lit.span.from_expansion() { let msg = "denote infinite loops with `loop { ... }`"; let condition_span = cx.sess.source_map().def_span(e.span); @@ -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() { @@ -159,7 +159,7 @@ declare_lint_pass!(NonShorthandFieldPatterns => [NON_SHORTHAND_FIELD_PATTERNS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns { fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat) { - if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.node { + if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.kind { let variant = cx.tables.pat_ty(pat).ty_adt_def() .expect("struct pattern type is not an ADT") .variant_of_res(cx.tables.qpath_res(qpath, pat.hir_id)); @@ -173,7 +173,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns { // (Issue #49588) continue; } - if let PatKind::Binding(_, _, ident, None) = fieldpat.pat.node { + if let PatKind::Binding(_, _, ident, None) = fieldpat.pat.kind { if cx.tcx.find_field_index(ident, &variant) == Some(cx.tcx.field_index(fieldpat.hir_id, cx.tables)) { let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS, @@ -224,7 +224,7 @@ impl EarlyLintPass for UnsafeCode { } fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { - if let ast::ExprKind::Block(ref blk, _) = e.node { + if let ast::ExprKind::Block(ref blk, _) = e.kind { // Don't warn about generated blocks; that'll just pollute the output. if blk.rules == ast::BlockCheckMode::Unsafe(ast::UserProvided) { self.report_unsafe(cx, blk.span, "usage of an `unsafe` block"); @@ -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") } @@ -268,7 +268,7 @@ impl EarlyLintPass for UnsafeCode { } fn check_trait_item(&mut self, cx: &EarlyContext<'_>, item: &ast::TraitItem) { - if let ast::TraitItemKind::Method(ref sig, None) = item.node { + if let ast::TraitItemKind::Method(ref sig, None) = item.kind { if sig.header.unsafety == ast::Unsafety::Unsafe { self.report_unsafe(cx, item.span, "declaration of an `unsafe` method") } @@ -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", @@ -440,7 +440,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { return; } - let desc = match trait_item.node { + let desc = match trait_item.kind { hir::TraitItemKind::Const(..) => "an associated constant", hir::TraitItemKind::Method(..) => "a trait method", hir::TraitItemKind::Type(..) => "an associated type", @@ -459,7 +459,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { return; } - let desc = match impl_item.node { + let desc = match impl_item.kind { hir::ImplItemKind::Const(..) => "an associated constant", hir::ImplItemKind::Method(..) => "a method", hir::ImplItemKind::TyAlias(_) => "an associated type", @@ -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(..) => {} @@ -611,10 +611,10 @@ declare_lint_pass!( impl EarlyLintPass for AnonymousParameters { fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::TraitItem) { - match it.node { + match it.kind { ast::TraitItemKind::Method(ref sig, _) => { for arg in sig.decl.inputs.iter() { - match arg.pat.node { + match arg.pat.kind { ast::PatKind::Ident(_, ident, None) => { if ident.name == kw::Invalid { let ty_snip = cx @@ -766,13 +766,13 @@ 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); } } fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &ast::Stmt) { - let (kind, is_macro_expansion) = match stmt.node { + let (kind, is_macro_expansion) = match stmt.kind { ast::StmtKind::Local(..) => ("statements", false), ast::StmtKind::Item(..) => ("inner items", false), ast::StmtKind::Mac(..) => ("macro expansions", true), @@ -781,7 +781,7 @@ impl EarlyLintPass for UnusedDocComment { ast::StmtKind::Expr(..) => return, }; - self.warn_if_doc(cx, stmt.span, kind, is_macro_expansion, stmt.node.attrs()); + self.warn_if_doc(cx, stmt.span, kind, is_macro_expansion, stmt.kind.attrs()); } fn check_arm(&mut self, cx: &EarlyContext<'_>, arm: &ast::Arm) { @@ -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 { @@ -932,7 +932,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { (cx: &LateContext<'a, 'tcx>, expr: &hir::Expr) -> Option<(Ty<'tcx>, Ty<'tcx>)> { - let def = if let hir::ExprKind::Path(ref qpath) = expr.node { + let def = if let hir::ExprKind::Path(ref qpath) = expr.kind { cx.tables.qpath_res(qpath, expr.hir_id) } else { return None; @@ -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)); @@ -1090,7 +1090,7 @@ impl TypeAliasBounds { match *qpath { hir::QPath::TypeRelative(ref ty, _) => { // If this is a type variable, we found a `T::Assoc`. - match ty.node { + match ty.kind { hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => { match path.res { Res::Def(DefKind::TyParam, _) => true, @@ -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); }, @@ -1321,7 +1321,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns { /// If `pat` is a `...` pattern, return the start and end of the range, as well as the span /// corresponding to the ellipsis. fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(&P, &P, Span)> { - match &pat.node { + match &pat.kind { PatKind::Range(a, b, Spanned { span, node: RangeEnd::Included(DotDotDot), .. }) => { Some((a, b, *span)) } @@ -1329,7 +1329,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns { } } - let (parenthesise, endpoints) = match &pat.node { + let (parenthesise, endpoints) = match &pat.kind { PatKind::Ref(subpat, _) => (true, matches_ellipsis_pat(&subpat)), _ => (false, matches_ellipsis_pat(pat)), }; @@ -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() { @@ -1750,7 +1750,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements { hir::WherePredicate::BoundPredicate(predicate) => { // FIXME we can also infer bounds on associated types, // and should check for them here. - match predicate.bounded_ty.node { + match predicate.bounded_ty.kind { hir::TyKind::Path(hir::QPath::Resolved( None, ref path, @@ -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 { @@ -1900,7 +1900,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue { fn is_zero(expr: &hir::Expr) -> bool { use hir::ExprKind::*; use syntax::ast::LitKind::*; - match &expr.node { + match &expr.kind { Lit(lit) => if let Int(i, _) = lit.node { i == 0 @@ -1923,8 +1923,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue { const TRANSMUTE_PATH: &[Symbol] = &[sym::core, sym::intrinsics, kw::Invalid, sym::transmute]; - if let hir::ExprKind::Call(ref path_expr, ref args) = expr.node { - if let hir::ExprKind::Path(ref qpath) = path_expr.node { + if let hir::ExprKind::Call(ref path_expr, ref args) = expr.kind { + if let hir::ExprKind::Path(ref qpath) = path_expr.kind { let def_id = cx.tables.qpath_res(qpath, path_expr.hir_id).opt_def_id()?; if cx.match_def_path(def_id, ZEROED_PATH) { diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index bb6119d0ff2aa..dceb79fd30985 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -136,7 +136,7 @@ impl EarlyLintPass for NonCamelCaseTypes { return; } - match it.node { + match it.kind { ast::ItemKind::TyAlias(..) | ast::ItemKind::Enum(..) | ast::ItemKind::Struct(..) | @@ -258,7 +258,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { .and_then(|attr| attr.meta()) .and_then(|meta| { meta.name_value_literal().and_then(|lit| { - if let ast::LitKind::Str(name, ..) = lit.node { + if let ast::LitKind::Str(name, ..) = lit.kind { // Discard the double quotes surrounding the literal. let sp = cx.sess().source_map().span_to_snippet(lit.span) .ok() @@ -326,13 +326,13 @@ 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); } } fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem) { - if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.node { + if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.kind { self.check_snake_case(cx, "trait method", &item.ident); for param_name in pnames { self.check_snake_case(cx, "variable", param_name); @@ -341,7 +341,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { } fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) { - if let &PatKind::Binding(_, _, ident, _) = &p.node { + if let &PatKind::Binding(_, _, ident, _) = &p.kind { self.check_snake_case(cx, "variable", &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); } @@ -399,20 +399,20 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals { } fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, ti: &hir::TraitItem) { - if let hir::TraitItemKind::Const(..) = ti.node { + if let hir::TraitItemKind::Const(..) = ti.kind { NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ti.ident); } } fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, ii: &hir::ImplItem) { - if let hir::ImplItemKind::Const(..) = ii.node { + if let hir::ImplItemKind::Const(..) = ii.kind { NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ii.ident); } } fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) { // Lint for constants that look like binding identifiers (#7526) - if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.node { + if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.kind { if let Res::Def(DefKind::Const, _) = path.res { if path.segments.len() == 1 { NonUpperCaseGlobals::check_upper_case( diff --git a/src/librustc_lint/redundant_semicolon.rs b/src/librustc_lint/redundant_semicolon.rs index 7c9df3578b59c..0adf1eeb410b0 100644 --- a/src/librustc_lint/redundant_semicolon.rs +++ b/src/librustc_lint/redundant_semicolon.rs @@ -12,8 +12,8 @@ declare_lint_pass!(RedundantSemicolon => [REDUNDANT_SEMICOLON]); impl EarlyLintPass for RedundantSemicolon { fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &Stmt) { - if let StmtKind::Semi(expr) = &stmt.node { - if let ExprKind::Tup(ref v) = &expr.node { + if let StmtKind::Semi(expr) = &stmt.kind { + if let ExprKind::Tup(ref v) = &expr.kind { if v.is_empty() { // Strings of excess semicolons are encoded as empty tuple expressions // during the parsing stage, so we check for empty tuple expressions diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 3a037b4dfff1f..e4567dc8265d8 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -72,7 +72,7 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>( ) -> bool { // We only want to handle exclusive (`..`) ranges, // which are represented as `ExprKind::Struct`. - if let ExprKind::Struct(_, eps, _) = &parent_expr.node { + if let ExprKind::Struct(_, eps, _) = &parent_expr.kind { if eps.len() != 2 { return false; } @@ -279,7 +279,7 @@ fn lint_int_literal<'a, 'tcx>( let par_id = cx.tcx.hir().get_parent_node(e.hir_id); if let Node::Expr(par_e) = cx.tcx.hir().get(par_id) { - if let hir::ExprKind::Struct(..) = par_e.node { + if let hir::ExprKind::Struct(..) = par_e.kind { if is_range_literal(cx.sess(), par_e) && lint_overflowing_range_endpoint(cx, lit, v, max, e, par_e, t) { @@ -318,7 +318,7 @@ fn lint_uint_literal<'a, 'tcx>( if lit_val < min || lit_val > max { let parent_id = cx.tcx.hir().get_parent_node(e.hir_id); if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) { - match par_e.node { + match par_e.kind { hir::ExprKind::Cast(..) => { if let ty::Char = cx.tables.expr_ty(par_e).kind { let mut err = cx.struct_span_lint( @@ -400,7 +400,7 @@ fn lint_literal<'a, 'tcx>( impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) { - match e.node { + match e.kind { hir::ExprKind::Unary(hir::UnNeg, ref expr) => { // propagate negation, if the negation itself isn't negated if self.negated_expr_id != e.hir_id { @@ -445,7 +445,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { l: &hir::Expr, r: &hir::Expr) -> bool { - let (lit, expr, swap) = match (&l.node, &r.node) { + let (lit, expr, swap) = match (&l.kind, &r.kind) { (&hir::ExprKind::Lit(_), _) => (l, r, true), (_, &hir::ExprKind::Lit(_)) => (r, l, false), _ => return true, @@ -456,7 +456,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { match cx.tables.node_type(expr.hir_id).kind { ty::Int(int_ty) => { let (min, max) = int_ty_range(int_ty); - let lit_val: i128 = match lit.node { + let lit_val: i128 = match lit.kind { hir::ExprKind::Lit(ref li) => { match li.node { ast::LitKind::Int(v, ast::LitIntType::Signed(_)) | @@ -470,7 +470,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { } ty::Uint(uint_ty) => { let (min, max) :(u128, u128) = uint_ty_range(uint_ty); - let lit_val: u128 = match lit.node { + let lit_val: u128 = match lit.kind { hir::ExprKind::Lit(ref li) => { match li.node { ast::LitKind::Int(v, _) => v, @@ -978,7 +978,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { if let Abi::Rust | Abi::RustCall | Abi::RustIntrinsic | Abi::PlatformIntrinsic = abi { // Don't worry about types in internal ABIs. } else { - match it.node { + match it.kind { hir::ForeignItemKind::Fn(ref decl, _, _) => { vis.check_foreign_fn(it.hir_id, decl); } @@ -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); diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 86df0b9f681e4..3b3995832cb4c 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -38,12 +38,12 @@ declare_lint_pass!(UnusedResults => [UNUSED_MUST_USE, UNUSED_RESULTS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { - let expr = match s.node { + let expr = match s.kind { hir::StmtKind::Semi(ref expr) => &**expr, _ => return, }; - if let hir::ExprKind::Ret(..) = expr.node { + if let hir::ExprKind::Ret(..) = expr.kind { return; } @@ -52,9 +52,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { let mut fn_warned = false; let mut op_warned = false; - let maybe_def_id = match expr.node { + let maybe_def_id = match expr.kind { hir::ExprKind::Call(ref callee, _) => { - match callee.node { + match callee.kind { hir::ExprKind::Path(ref qpath) => { match cx.tables.qpath_res(qpath, callee.hir_id) { Res::Def(DefKind::Fn, def_id) @@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { return; } - let must_use_op = match expr.node { + let must_use_op = match expr.kind { // Hardcoding operators here seemed more expedient than the // refactoring that would be needed to look up the `#[must_use]` // attribute which does exist on the comparison trait methods @@ -193,7 +193,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { } ty::Tuple(ref tys) => { let mut has_emitted = false; - let spans = if let hir::ExprKind::Tup(comps) = &expr.node { + let spans = if let hir::ExprKind::Tup(comps) = &expr.kind { debug_assert_eq!(comps.len(), tys.len()); comps.iter().map(|e| e.span).collect() } else { @@ -269,8 +269,8 @@ declare_lint_pass!(PathStatements => [PATH_STATEMENTS]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements { fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { - if let hir::StmtKind::Semi(ref expr) = s.node { - if let hir::ExprKind::Path(_) = expr.node { + if let hir::StmtKind::Semi(ref expr) = s.kind { + if let hir::ExprKind::Path(_) = expr.kind { cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect"); } } @@ -363,7 +363,7 @@ declare_lint_pass!(UnusedParens => [UNUSED_PARENS]); impl UnusedParens { fn is_expr_parens_necessary(inner: &ast::Expr, followed_by_block: bool) -> bool { - followed_by_block && match inner.node { + followed_by_block && match inner.kind { ast::ExprKind::Ret(_) | ast::ExprKind::Break(..) => true, _ => parser::contains_exterior_struct_lit(&inner), } @@ -376,7 +376,7 @@ impl UnusedParens { followed_by_block: bool, left_pos: Option, right_pos: Option) { - match value.node { + match value.kind { ast::ExprKind::Paren(ref inner) => { if !Self::is_expr_parens_necessary(inner, followed_by_block) && value.attrs.is_empty() { @@ -416,8 +416,8 @@ impl UnusedParens { ) { use ast::{PatKind, BindingMode::ByValue, Mutability::Mutable}; - if let PatKind::Paren(inner) = &value.node { - match inner.node { + if let PatKind::Paren(inner) = &value.kind { + match inner.kind { // The lint visitor will visit each subpattern of `p`. We do not want to lint // any range pattern no matter where it occurs in the pattern. For something like // `&(a..=b)`, there is a recursive `check_pat` on `a` and `b`, but we will assume @@ -501,7 +501,7 @@ impl UnusedParens { impl EarlyLintPass for UnusedParens { fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) { use syntax::ast::ExprKind::*; - let (value, msg, followed_by_block, left_pos, right_pos) = match e.node { + let (value, msg, followed_by_block, left_pos, right_pos) = match e.kind { Let(ref pat, ..) => { self.check_unused_parens_pat(cx, pat, false, false); return; @@ -566,7 +566,7 @@ impl EarlyLintPass for UnusedParens { fn check_pat(&mut self, cx: &EarlyContext<'_>, p: &ast::Pat) { use ast::{PatKind::*, Mutability}; - match &p.node { + match &p.kind { // Do not lint on `(..)` as that will result in the other arms being useless. Paren(_) // The other cases do not contain sub-patterns. @@ -587,7 +587,7 @@ impl EarlyLintPass for UnusedParens { } fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) { - if let ast::StmtKind::Local(ref local) = s.node { + if let ast::StmtKind::Local(ref local) = s.kind { self.check_unused_parens_pat(cx, &local.pat, false, false); if let Some(ref value) = local.init { @@ -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); } } @@ -663,7 +663,7 @@ declare_lint_pass!(UnusedAllocation => [UNUSED_ALLOCATION]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation { fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) { - match e.node { + match e.kind { hir::ExprKind::Box(_) => {} _ => return, } diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index af41b6a4c857f..0a2a481bb1500 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -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); diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 11121ee875dda..8a7e599ebeb63 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -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, }), diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 8a68581ff8b14..0bb4f52be14c2 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -862,7 +862,7 @@ impl EncodeContext<'tcx> { let kind = match trait_item.kind { ty::AssocKind::Const => { let const_qualif = - if let hir::TraitItemKind::Const(_, Some(body)) = ast_item.node { + if let hir::TraitItemKind::Const(_, Some(body)) = ast_item.kind { self.const_qualif(0, body) } else { ConstQualif { mir: 0, ast_promotable: false } @@ -875,7 +875,7 @@ impl EncodeContext<'tcx> { EntryKind::AssocConst(container, const_qualif, rendered_const) } ty::AssocKind::Method => { - let fn_data = if let hir::TraitItemKind::Method(method_sig, m) = &ast_item.node { + let fn_data = if let hir::TraitItemKind::Method(method_sig, m) = &ast_item.kind { let param_names = match *m { hir::TraitMethod::Required(ref names) => { self.encode_fn_param_names(names) @@ -970,7 +970,7 @@ impl EncodeContext<'tcx> { let kind = match impl_item.kind { ty::AssocKind::Const => { - if let hir::ImplItemKind::Const(_, body_id) = ast_item.node { + if let hir::ImplItemKind::Const(_, body_id) = ast_item.kind { let mir = self.tcx.at(ast_item.span).mir_const_qualif(def_id).0; EntryKind::AssocConst(container, @@ -981,7 +981,7 @@ impl EncodeContext<'tcx> { } } ty::AssocKind::Method => { - let fn_data = if let hir::ImplItemKind::Method(ref sig, body) = ast_item.node { + let fn_data = if let hir::ImplItemKind::Method(ref sig, body) = ast_item.kind { FnData { asyncness: sig.header.asyncness, constness: sig.header.constness, @@ -1001,21 +1001,20 @@ impl EncodeContext<'tcx> { ty::AssocKind::Type => EntryKind::AssocType(container) }; - let mir = - match ast_item.node { - hir::ImplItemKind::Const(..) => true, - hir::ImplItemKind::Method(ref sig, _) => { - let generics = self.tcx.generics_of(def_id); - let needs_inline = (generics.requires_monomorphization(self.tcx) || - tcx.codegen_fn_attrs(def_id).requests_inline()) && - !self.metadata_output_only(); - let is_const_fn = sig.header.constness == hir::Constness::Const; - let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir; - needs_inline || is_const_fn || always_encode_mir - }, - hir::ImplItemKind::OpaqueTy(..) | - hir::ImplItemKind::TyAlias(..) => false, - }; + let mir = match ast_item.kind { + hir::ImplItemKind::Const(..) => true, + hir::ImplItemKind::Method(ref sig, _) => { + let generics = self.tcx.generics_of(def_id); + let needs_inline = (generics.requires_monomorphization(self.tcx) || + tcx.codegen_fn_attrs(def_id).requests_inline()) && + !self.metadata_output_only(); + let is_const_fn = sig.header.constness == hir::Constness::Const; + let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir; + needs_inline || is_const_fn || always_encode_mir + }, + hir::ImplItemKind::OpaqueTy(..) | + hir::ImplItemKind::TyAlias(..) => false, + }; Entry { kind, @@ -1047,7 +1046,7 @@ impl EncodeContext<'tcx> { self.tcx.dep_graph.with_ignore(|| { let body = self.tcx.hir().body(body_id); self.lazy(body.params.iter().map(|arg| { - match arg.pat.node { + match arg.pat.kind { PatKind::Binding(_, _, ident, _) => ident.name, _ => kw::Invalid, } @@ -1118,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) => { @@ -1234,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); @@ -1253,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() @@ -1287,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(..) | @@ -1300,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(..) | @@ -1321,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(..) | @@ -1341,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 @@ -1678,7 +1677,7 @@ impl EncodeContext<'tcx> { debug!("EncodeContext::encode_info_for_foreign_item({:?})", def_id); - let kind = match nitem.node { + let kind = match nitem.kind { hir::ForeignItemKind::Fn(_, ref names, _) => { let data = FnData { asyncness: hir::IsAsync::NotAsync, @@ -1704,7 +1703,7 @@ impl EncodeContext<'tcx> { ty: Some(self.encode_item_type(def_id)), inherent_impls: Lazy::empty(), - variances: match nitem.node { + variances: match nitem.kind { hir::ForeignItemKind::Fn(..) => self.encode_variances_of(def_id), _ => Lazy::empty(), }, @@ -1729,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)), @@ -1800,7 +1799,7 @@ impl EncodeContext<'tcx> { } fn encode_info_for_ty(&mut self, ty: &hir::Ty) { - match ty.node { + match ty.kind { hir::TyKind::Array(_, ref length) => { let def_id = self.tcx.hir().local_def_id(length.hir_id); self.record(def_id, EncodeContext::encode_info_for_anon_const, def_id); @@ -1810,7 +1809,7 @@ impl EncodeContext<'tcx> { } fn encode_info_for_expr(&mut self, expr: &hir::Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Closure(..) => { let def_id = self.tcx.hir().local_def_id(expr.hir_id); self.record(def_id, EncodeContext::encode_info_for_closure, def_id); @@ -1825,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(..) | @@ -1894,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 diff --git a/src/librustc_metadata/foreign_modules.rs b/src/librustc_metadata/foreign_modules.rs index b2e40282d9332..8a4f6e6f17a51 100644 --- a/src/librustc_metadata/foreign_modules.rs +++ b/src/librustc_metadata/foreign_modules.rs @@ -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, }; diff --git a/src/librustc_metadata/link_args.rs b/src/librustc_metadata/link_args.rs index 728fd004fcb69..527d4421fca65 100644 --- a/src/librustc_metadata/link_args.rs +++ b/src/librustc_metadata/link_args.rs @@ -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, }; diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index ada1a8c615d44..fe215d9c7999e 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -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, }; diff --git a/src/librustc_mir/borrow_check/conflict_errors.rs b/src/librustc_mir/borrow_check/conflict_errors.rs index 5fb41dc20c741..9788631fc9590 100644 --- a/src/librustc_mir/borrow_check/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/conflict_errors.rs @@ -1845,7 +1845,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Need to use the `rustc::ty` types to compare against the // `return_region`. Then use the `rustc::hir` type to get only // the lifetime span. - if let hir::TyKind::Rptr(lifetime, _) = &fn_decl.inputs[index].node { + if let hir::TyKind::Rptr(lifetime, _) = &fn_decl.inputs[index].kind { // With access to the lifetime, we can get // the span of it. arguments.push((*argument, lifetime.span)); @@ -1866,7 +1866,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let return_ty = *sig.output().skip_binder(); let mut return_span = fn_decl.output.span(); if let hir::FunctionRetTy::Return(ty) = &fn_decl.output { - if let hir::TyKind::Rptr(lifetime, _) = ty.node { + if let hir::TyKind::Rptr(lifetime, _) = ty.kind { return_span = lifetime.span; } } diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index c0c0e7a32b672..dc7e4b2206588 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -890,7 +890,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { def_id, target_place, places ); let hir_id = self.infcx.tcx.hir().as_local_hir_id(def_id)?; - let expr = &self.infcx.tcx.hir().expect_expr(hir_id).node; + let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind; debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr); if let hir::ExprKind::Closure( .., args_span, _ diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index b12af1a0e9522..811ad6bb46627 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -236,7 +236,7 @@ fn do_mir_borrowck<'a, 'tcx>( let movable_generator = match tcx.hir().get(id) { Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), + kind: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), .. }) => false, _ => true, diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index c3aed74bcaad2..33520b6755ca4 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -338,7 +338,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { _, upvar_ident, _, - ) = pat.node + ) = pat.kind { err.span_suggestion( upvar_ident.span, @@ -642,7 +642,7 @@ fn annotate_struct_field( if let hir::TyKind::Rptr(lifetime, hir::MutTy { mutbl: hir::Mutability::MutImmutable, ref ty - }) = field.ty.node { + }) = field.ty.kind { // Get the snippets in two parts - the named lifetime (if there is one) and // type being referenced, that way we can reconstruct the snippet without loss // of detail. diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index 90e5480d2fb79..c4b508e030f39 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -292,7 +292,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { if let DefiningTy::Closure(def_id, substs) = def_ty { let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) = - tcx.hir().expect_expr(mir_hir_id).node + tcx.hir().expect_expr(mir_hir_id).kind { span } else { @@ -425,7 +425,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let mir_hir_id = infcx.tcx.hir().as_local_hir_id(mir_def_id)?; let fn_decl = infcx.tcx.hir().fn_decl_by_hir_id(mir_hir_id)?; let argument_hir_ty: &hir::Ty = &fn_decl.inputs[argument_index]; - match argument_hir_ty.node { + match argument_hir_ty.kind { // This indicates a variable with no type annotation, like // `|x|`... in that case, we can't highlight the type but // must highlight the variable. @@ -527,7 +527,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { &mut vec![(argument_ty, argument_hir_ty)]; while let Some((ty, hir_ty)) = search_stack.pop() { - match (&ty.kind, &hir_ty.node) { + match (&ty.kind, &hir_ty.kind) { // Check if the `argument_ty` is `&'X ..` where `'X` // is the region we are looking for -- if so, and we have a `&T` // on the RHS, then we want to highlight the `&` like so: @@ -758,7 +758,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let (return_span, mir_description) = match tcx.hir().get(mir_hir_id) { hir::Node::Expr(hir::Expr { - node: hir::ExprKind::Closure(_, return_ty, _, span, gen_move), + kind: hir::ExprKind::Closure(_, return_ty, _, span, gen_move), .. }) => ( match return_ty.output { @@ -772,7 +772,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { }, ), hir::Node::ImplItem(hir::ImplItem { - node: hir::ImplItemKind::Method(method_sig, _), + kind: hir::ImplItemKind::Method(method_sig, _), .. }) => (method_sig.decl.output.span(), ""), _ => (body.span, ""), @@ -821,7 +821,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let yield_span = match tcx.hir().get(mir_hir_id) { hir::Node::Expr(hir::Expr { - node: hir::ExprKind::Closure(_, _, _, span, _), + kind: hir::ExprKind::Closure(_, _, _, span, _), .. }) => ( tcx.sess.source_map().end_point(*span) diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index 7ea08b15b443d..7353ca9285ddb 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -98,7 +98,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { initializer, lint_level } => { - let ignores_expr_result = if let PatternKind::Wild = *pattern.kind { + let ignores_expr_result = if let PatKind::Wild = *pattern.kind { true } else { false diff --git a/src/librustc_mir/build/expr/stmt.rs b/src/librustc_mir/build/expr/stmt.rs index cf3d8778da193..0cd32acdb665b 100644 --- a/src/librustc_mir/build/expr/stmt.rs +++ b/src/librustc_mir/build/expr/stmt.rs @@ -159,7 +159,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if let ExprKind::Block { body } = expr.kind { if let Some(tail_expr) = &body.expr { let mut expr = tail_expr; - while let rustc::hir::ExprKind::Block(subblock, _label) = &expr.node { + while let rustc::hir::ExprKind::Block(subblock, _label) = &expr.kind { if let Some(subtail_expr) = &subblock.expr { expr = subtail_expr } else { diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 5f1bd3e9115ca..8db06aa375e23 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -298,12 +298,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { pub(super) fn expr_into_pattern( &mut self, mut block: BasicBlock, - irrefutable_pat: Pattern<'tcx>, + irrefutable_pat: Pat<'tcx>, initializer: ExprRef<'tcx>, ) -> BlockAnd<()> { match *irrefutable_pat.kind { // Optimize the case of `let x = ...` to write directly into `x` - PatternKind::Binding { + PatKind::Binding { mode: BindingMode::ByValue, var, subpattern: None, @@ -336,9 +336,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // test works with uninitialized values in a rather // dubious way, so it may be that the test is kind of // broken. - PatternKind::AscribeUserType { - subpattern: Pattern { - kind: box PatternKind::Binding { + PatKind::AscribeUserType { + subpattern: Pat { + kind: box PatKind::Binding { mode: BindingMode::ByValue, var, subpattern: None, @@ -414,7 +414,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { pub fn place_into_pattern( &mut self, block: BasicBlock, - irrefutable_pat: Pattern<'tcx>, + irrefutable_pat: Pat<'tcx>, initializer: &Place<'tcx>, set_match_place: bool, ) -> BlockAnd<()> { @@ -486,7 +486,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, mut visibility_scope: Option, scope_span: Span, - pattern: &Pattern<'tcx>, + pattern: &Pat<'tcx>, has_guard: ArmHasGuard, opt_match_place: Option<(Option<&Place<'tcx>>, Span)>, ) -> Option { @@ -556,7 +556,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { pub(super) fn visit_bindings( &mut self, - pattern: &Pattern<'tcx>, + pattern: &Pat<'tcx>, pattern_user_ty: UserTypeProjections, f: &mut impl FnMut( &mut Self, @@ -571,7 +571,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) { debug!("visit_bindings: pattern={:?} pattern_user_ty={:?}", pattern, pattern_user_ty); match *pattern.kind { - PatternKind::Binding { + PatKind::Binding { mutability, name, mode, @@ -586,12 +586,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - PatternKind::Array { + PatKind::Array { ref prefix, ref slice, ref suffix, } - | PatternKind::Slice { + | PatKind::Slice { ref prefix, ref slice, ref suffix, @@ -609,13 +609,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - PatternKind::Constant { .. } | PatternKind::Range { .. } | PatternKind::Wild => {} + PatKind::Constant { .. } | PatKind::Range { .. } | PatKind::Wild => {} - PatternKind::Deref { ref subpattern } => { + PatKind::Deref { ref subpattern } => { self.visit_bindings(subpattern, pattern_user_ty.deref(), f); } - PatternKind::AscribeUserType { + PatKind::AscribeUserType { ref subpattern, ascription: hair::pattern::Ascription { ref user_ty, @@ -644,7 +644,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.visit_bindings(subpattern, subpattern_user_ty, f) } - PatternKind::Leaf { ref subpatterns } => { + PatKind::Leaf { ref subpatterns } => { for subpattern in subpatterns { let subpattern_user_ty = pattern_user_ty.clone().leaf(subpattern.field); debug!("visit_bindings: subpattern_user_ty={:?}", subpattern_user_ty); @@ -652,14 +652,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - PatternKind::Variant { adt_def, substs: _, variant_index, ref subpatterns } => { + PatKind::Variant { adt_def, substs: _, variant_index, ref subpatterns } => { for subpattern in subpatterns { let subpattern_user_ty = pattern_user_ty.clone().variant( adt_def, variant_index, subpattern.field); self.visit_bindings(&subpattern.pattern, subpattern_user_ty, f); } } - PatternKind::Or { ref pats } => { + PatKind::Or { ref pats } => { for pat in pats { self.visit_bindings(&pat, pattern_user_ty.clone(), f); } @@ -708,7 +708,7 @@ struct Binding<'tcx> { struct Ascription<'tcx> { span: Span, source: Place<'tcx>, - user_ty: PatternTypeProjection<'tcx>, + user_ty: PatTyProj<'tcx>, variance: ty::Variance, } @@ -718,7 +718,7 @@ pub struct MatchPair<'pat, 'tcx> { place: Place<'tcx>, // ... must match this pattern. - pattern: &'pat Pattern<'tcx>, + pattern: &'pat Pat<'tcx>, } #[derive(Clone, Debug, PartialEq)] @@ -760,7 +760,7 @@ enum TestKind<'tcx> { }, /// Test whether the value falls within an inclusive or exclusive range - Range(PatternRange<'tcx>), + Range(PatRange<'tcx>), /// Test length of the slice is equal to len Len { @@ -1339,7 +1339,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } /////////////////////////////////////////////////////////////////////////// -// Pattern binding - used for `let` and function parameters as well. +// Pat binding - used for `let` and function parameters as well. impl<'a, 'tcx> Builder<'a, 'tcx> { /// Initializes each of the bindings from the candidate by diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs index 224b1a2b4efee..3826e5e3ba5e6 100644 --- a/src/librustc_mir/build/matches/simplify.rs +++ b/src/librustc_mir/build/matches/simplify.rs @@ -57,7 +57,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { -> Result<(), MatchPair<'pat, 'tcx>> { let tcx = self.hir.tcx(); match *match_pair.pattern.kind { - PatternKind::AscribeUserType { + PatKind::AscribeUserType { ref subpattern, ascription: hair::pattern::Ascription { variance, @@ -79,12 +79,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Ok(()) } - PatternKind::Wild => { + PatKind::Wild => { // nothing left to do Ok(()) } - PatternKind::Binding { name, mutability, mode, var, ty, ref subpattern } => { + PatKind::Binding { name, mutability, mode, var, ty, ref subpattern } => { candidate.bindings.push(Binding { name, mutability, @@ -103,12 +103,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Ok(()) } - PatternKind::Constant { .. } => { + PatKind::Constant { .. } => { // FIXME normalize patterns when possible Err(match_pair) } - PatternKind::Range(PatternRange { lo, hi, end }) => { + PatKind::Range(PatRange { lo, hi, end }) => { let (range, bias) = match lo.ty.kind { ty::Char => { (Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32))), 0) @@ -144,7 +144,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Err(match_pair) } - PatternKind::Slice { ref prefix, ref slice, ref suffix } => { + PatKind::Slice { ref prefix, ref slice, ref suffix } => { if prefix.is_empty() && slice.is_some() && suffix.is_empty() { // irrefutable self.prefix_slice_suffix(&mut candidate.match_pairs, @@ -158,7 +158,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - PatternKind::Variant { adt_def, substs, variant_index, ref subpatterns } => { + PatKind::Variant { adt_def, substs, variant_index, ref subpatterns } => { let irrefutable = adt_def.variants.iter_enumerated().all(|(i, v)| { i == variant_index || { self.hir.tcx().features().exhaustive_patterns && @@ -174,7 +174,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - PatternKind::Array { ref prefix, ref slice, ref suffix } => { + PatKind::Array { ref prefix, ref slice, ref suffix } => { self.prefix_slice_suffix(&mut candidate.match_pairs, &match_pair.place, prefix, @@ -183,20 +183,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Ok(()) } - PatternKind::Leaf { ref subpatterns } => { + PatKind::Leaf { ref subpatterns } => { // tuple struct, match subpats (if any) candidate.match_pairs .extend(self.field_match_pairs(match_pair.place, subpatterns)); Ok(()) } - PatternKind::Deref { ref subpattern } => { + PatKind::Deref { ref subpattern } => { let place = match_pair.place.deref(); candidate.match_pairs.push(MatchPair::new(place, subpattern)); Ok(()) } - PatternKind::Or { .. } => { + PatKind::Or { .. } => { Err(match_pair) } } diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 03f9e4ccc970b..d8bb0b4f6cc57 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -26,7 +26,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// It is a bug to call this with a simplifiable pattern. pub fn test<'pat>(&mut self, match_pair: &MatchPair<'pat, 'tcx>) -> Test<'tcx> { match *match_pair.pattern.kind { - PatternKind::Variant { ref adt_def, substs: _, variant_index: _, subpatterns: _ } => { + PatKind::Variant { ref adt_def, substs: _, variant_index: _, subpatterns: _ } => { Test { span: match_pair.pattern.span, kind: TestKind::Switch { @@ -36,7 +36,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - PatternKind::Constant { .. } if is_switch_ty(match_pair.pattern.ty) => { + PatKind::Constant { .. } if is_switch_ty(match_pair.pattern.ty) => { // For integers, we use a `SwitchInt` match, which allows // us to handle more cases. Test { @@ -52,7 +52,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - PatternKind::Constant { value } => { + PatKind::Constant { value } => { Test { span: match_pair.pattern.span, kind: TestKind::Eq { @@ -62,7 +62,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - PatternKind::Range(range) => { + PatKind::Range(range) => { assert_eq!(range.lo.ty, match_pair.pattern.ty); assert_eq!(range.hi.ty, match_pair.pattern.ty); Test { @@ -71,7 +71,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - PatternKind::Slice { ref prefix, ref slice, ref suffix } => { + PatKind::Slice { ref prefix, ref slice, ref suffix } => { let len = prefix.len() + suffix.len(); let op = if slice.is_some() { BinOp::Ge @@ -84,13 +84,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - PatternKind::AscribeUserType { .. } | - PatternKind::Array { .. } | - PatternKind::Wild | - PatternKind::Or { .. } | - PatternKind::Binding { .. } | - PatternKind::Leaf { .. } | - PatternKind::Deref { .. } => { + PatKind::AscribeUserType { .. } | + PatKind::Array { .. } | + PatKind::Wild | + PatKind::Or { .. } | + PatKind::Binding { .. } | + PatKind::Leaf { .. } | + PatKind::Deref { .. } => { self.error_simplifyable(match_pair) } } @@ -110,7 +110,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }; match *match_pair.pattern.kind { - PatternKind::Constant { value } => { + PatKind::Constant { value } => { indices.entry(value) .or_insert_with(|| { options.push(value.eval_bits( @@ -120,22 +120,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }); true } - PatternKind::Variant { .. } => { + PatKind::Variant { .. } => { panic!("you should have called add_variants_to_switch instead!"); } - PatternKind::Range(range) => { + PatKind::Range(range) => { // Check that none of the switch values are in the range. self.values_not_contained_in_range(range, indices) .unwrap_or(false) } - PatternKind::Slice { .. } | - PatternKind::Array { .. } | - PatternKind::Wild | - PatternKind::Or { .. } | - PatternKind::Binding { .. } | - PatternKind::AscribeUserType { .. } | - PatternKind::Leaf { .. } | - PatternKind::Deref { .. } => { + PatKind::Slice { .. } | + PatKind::Array { .. } | + PatKind::Wild | + PatKind::Or { .. } | + PatKind::Binding { .. } | + PatKind::AscribeUserType { .. } | + PatKind::Leaf { .. } | + PatKind::Deref { .. } => { // don't know how to add these patterns to a switch false } @@ -154,7 +154,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }; match *match_pair.pattern.kind { - PatternKind::Variant { adt_def: _ , variant_index, .. } => { + PatKind::Variant { adt_def: _ , variant_index, .. } => { // We have a pattern testing for variant `variant_index` // set the corresponding index to true variants.insert(variant_index); @@ -283,7 +283,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - TestKind::Range(PatternRange { ref lo, ref hi, ref end }) => { + TestKind::Range(PatRange { ref lo, ref hi, ref end }) => { let lower_bound_success = self.cfg.start_new_block(); let target_blocks = make_target_blocks(self); @@ -533,7 +533,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // If we are performing a variant switch, then this // informs variant patterns, but nothing else. (&TestKind::Switch { adt_def: tested_adt_def, .. }, - &PatternKind::Variant { adt_def, variant_index, ref subpatterns, .. }) => { + &PatKind::Variant { adt_def, variant_index, ref subpatterns, .. }) => { assert_eq!(adt_def, tested_adt_def); self.candidate_after_variant_switch(match_pair_index, adt_def, @@ -548,10 +548,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // If we are performing a switch over integers, then this informs integer // equality, but nothing else. // - // FIXME(#29623) we could use PatternKind::Range to rule + // FIXME(#29623) we could use PatKind::Range to rule // things out here, in some cases. (&TestKind::SwitchInt { switch_ty: _, options: _, ref indices }, - &PatternKind::Constant { ref value }) + &PatKind::Constant { ref value }) if is_switch_ty(match_pair.pattern.ty) => { let index = indices[value]; self.candidate_without_match_pair(match_pair_index, candidate); @@ -559,7 +559,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } (&TestKind::SwitchInt { switch_ty: _, ref options, ref indices }, - &PatternKind::Range(range)) => { + &PatKind::Range(range)) => { let not_contained = self .values_not_contained_in_range(range, indices) .unwrap_or(false); @@ -577,7 +577,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { (&TestKind::SwitchInt { .. }, _) => None, (&TestKind::Len { len: test_len, op: BinOp::Eq }, - &PatternKind::Slice { ref prefix, ref slice, ref suffix }) => { + &PatKind::Slice { ref prefix, ref slice, ref suffix }) => { let pat_len = (prefix.len() + suffix.len()) as u64; match (test_len.cmp(&pat_len), slice) { (Ordering::Equal, &None) => { @@ -610,7 +610,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } (&TestKind::Len { len: test_len, op: BinOp::Ge }, - &PatternKind::Slice { ref prefix, ref slice, ref suffix }) => { + &PatKind::Slice { ref prefix, ref slice, ref suffix }) => { // the test is `$actual_len >= test_len` let pat_len = (prefix.len() + suffix.len()) as u64; match (test_len.cmp(&pat_len), slice) { @@ -644,7 +644,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } (&TestKind::Range(test), - &PatternKind::Range(pat)) => { + &PatKind::Range(pat)) => { if test == pat { self.candidate_without_match_pair( match_pair_index, @@ -683,7 +683,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - (&TestKind::Range(range), &PatternKind::Constant { value }) => { + (&TestKind::Range(range), &PatKind::Constant { value }) => { if self.const_range_contains(range, value) == Some(false) { // `value` is not contained in the testing range, // so `value` can be matched only if this test fails. @@ -722,9 +722,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fn candidate_after_slice_test<'pat>(&mut self, match_pair_index: usize, candidate: &mut Candidate<'pat, 'tcx>, - prefix: &'pat [Pattern<'tcx>], - opt_slice: Option<&'pat Pattern<'tcx>>, - suffix: &'pat [Pattern<'tcx>]) { + prefix: &'pat [Pat<'tcx>], + opt_slice: Option<&'pat Pat<'tcx>>, + suffix: &'pat [Pat<'tcx>]) { let removed_place = candidate.match_pairs.remove(match_pair_index).place; self.prefix_slice_suffix( &mut candidate.match_pairs, @@ -739,7 +739,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { match_pair_index: usize, adt_def: &'tcx ty::AdtDef, variant_index: VariantIdx, - subpatterns: &'pat [FieldPattern<'tcx>], + subpatterns: &'pat [FieldPat<'tcx>], candidate: &mut Candidate<'pat, 'tcx>, ) { let match_pair = candidate.match_pairs.remove(match_pair_index); @@ -771,7 +771,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fn const_range_contains( &self, - range: PatternRange<'tcx>, + range: PatRange<'tcx>, value: &'tcx ty::Const<'tcx>, ) -> Option { use std::cmp::Ordering::*; @@ -790,7 +790,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fn values_not_contained_in_range( &self, - range: PatternRange<'tcx>, + range: PatRange<'tcx>, indices: &FxHashMap<&'tcx ty::Const<'tcx>, usize>, ) -> Option { for &val in indices.keys() { diff --git a/src/librustc_mir/build/matches/util.rs b/src/librustc_mir/build/matches/util.rs index 011b3a8688837..83fb924af6381 100644 --- a/src/librustc_mir/build/matches/util.rs +++ b/src/librustc_mir/build/matches/util.rs @@ -8,7 +8,7 @@ use std::convert::TryInto; impl<'a, 'tcx> Builder<'a, 'tcx> { pub fn field_match_pairs<'pat>(&mut self, place: Place<'tcx>, - subpatterns: &'pat [FieldPattern<'tcx>]) + subpatterns: &'pat [FieldPat<'tcx>]) -> Vec> { subpatterns.iter() .map(|fieldpat| { @@ -22,9 +22,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { pub fn prefix_slice_suffix<'pat>(&mut self, match_pairs: &mut Vec>, place: &Place<'tcx>, - prefix: &'pat [Pattern<'tcx>], - opt_slice: Option<&'pat Pattern<'tcx>>, - suffix: &'pat [Pattern<'tcx>]) { + prefix: &'pat [Pat<'tcx>], + opt_slice: Option<&'pat Pat<'tcx>>, + suffix: &'pat [Pat<'tcx>]) { let min_length = prefix.len() + suffix.len(); let min_length = min_length.try_into().unwrap(); @@ -101,7 +101,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } impl<'pat, 'tcx> MatchPair<'pat, 'tcx> { - pub fn new(place: Place<'tcx>, pattern: &'pat Pattern<'tcx>) -> MatchPair<'pat, 'tcx> { + pub fn new(place: Place<'tcx>, pattern: &'pat Pat<'tcx>) -> MatchPair<'pat, 'tcx> { MatchPair { place, pattern, diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index b0572df9d0853..f1e045302eced 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -1,7 +1,7 @@ use crate::build; use crate::build::scope::DropKind; use crate::hair::cx::Cx; -use crate::hair::{LintLevel, BindingMode, PatternKind}; +use crate::hair::{LintLevel, BindingMode, PatKind}; use crate::transform::MirSource; use crate::util as mir_util; use rustc::hir; @@ -27,17 +27,17 @@ 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 { node: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) - | Node::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. }) + Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) + | Node::Item(hir::Item { kind: hir::ItemKind::Fn(decl, _, _, body_id), .. }) | Node::ImplItem( hir::ImplItem { - node: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id), + kind: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id), .. } ) | Node::TraitItem( hir::TraitItem { - node: hir::TraitItemKind::Method( + kind: hir::TraitItemKind::Method( hir::MethodSig { decl, .. }, hir::TraitMethod::Provided(body_id), ), @@ -46,11 +46,11 @@ 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::ImplItem(hir::ImplItem { node: hir::ImplItemKind::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 { node: hir::TraitItemKind::Const(ty, Some(body_id)), .. } + hir::TraitItem { kind: hir::TraitItemKind::Const(ty, Some(body_id)), .. } ) => { (*body_id, ty.span) } @@ -559,7 +559,7 @@ where }; let mut mutability = Mutability::Not; if let Some(Node::Binding(pat)) = tcx_hir.find(var_hir_id) { - if let hir::PatKind::Binding(_, _, ident, _) = pat.node { + if let hir::PatKind::Binding(_, _, ident, _) = pat.kind { debuginfo.debug_name = ident.name; if let Some(&bm) = hir.tables.pat_binding_modes().get(pat.hir_id) { if bm == ty::BindByValue(hir::MutMutable) { @@ -827,7 +827,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.set_correct_source_scope_for_arg(arg.hir_id, original_source_scope, span); match *pattern.kind { // Don't introduce extra copies for simple bindings - PatternKind::Binding { + PatKind::Binding { mutability, var, mode: BindingMode::ByValue, diff --git a/src/librustc_mir/hair/cx/block.rs b/src/librustc_mir/hair/cx/block.rs index 9a73842d2f02a..33d67dcf91448 100644 --- a/src/librustc_mir/hair/cx/block.rs +++ b/src/librustc_mir/hair/cx/block.rs @@ -49,7 +49,7 @@ fn mirror_stmts<'a, 'tcx>( for (index, stmt) in stmts.iter().enumerate() { let hir_id = stmt.hir_id; let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id); - match stmt.node { + match stmt.kind { hir::StmtKind::Expr(ref expr) | hir::StmtKind::Semi(ref expr) => { result.push(StmtRef::Mirror(Box::new(Stmt { @@ -78,12 +78,12 @@ fn mirror_stmts<'a, 'tcx>( if let Some(ty) = &local.ty { if let Some(&user_ty) = cx.tables.user_provided_types().get(ty.hir_id) { debug!("mirror_stmts: user_ty={:?}", user_ty); - pattern = Pattern { + pattern = Pat { ty: pattern.ty, span: pattern.span, - kind: Box::new(PatternKind::AscribeUserType { + kind: Box::new(PatKind::AscribeUserType { ascription: hair::pattern::Ascription { - user_ty: PatternTypeProjection::from_user_type(user_ty), + user_ty: PatTyProj::from_user_type(user_ty), user_ty_span: ty.span, variance: ty::Variance::Covariant, }, diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index a24b14598eb59..da1b9ed7693e6 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -204,7 +204,7 @@ fn make_mirror_unadjusted<'a, 'tcx>( let expr_ty = cx.tables().expr_ty(expr); let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id); - let kind = match expr.node { + let kind = match expr.kind { // Here comes the interesting stuff: hir::ExprKind::MethodCall(_, method_span, ref args) => { // Rewrite a.b(c) into UFCS form like Trait::b(a, c) @@ -247,7 +247,7 @@ fn make_mirror_unadjusted<'a, 'tcx>( } } else { let adt_data = if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = - fun.node + fun.kind { // Tuple-like ADTs are represented as ExprKind::Call. We convert them here. expr_ty.ty_adt_def().and_then(|adt_def| { @@ -427,7 +427,7 @@ fn make_mirror_unadjusted<'a, 'tcx>( if cx.tables().is_method_call(expr) { overloaded_operator(cx, expr, vec![arg.to_ref()]) } else { - if let hir::ExprKind::Lit(ref lit) = arg.node { + if let hir::ExprKind::Lit(ref lit) = arg.kind { ExprKind::Literal { literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, true), user_ty: None, @@ -639,7 +639,7 @@ fn make_mirror_unadjusted<'a, 'tcx>( // } // The correct solution would be to add symbolic computations to miri, // so we wouldn't have to compute and store the actual value - let var = if let hir::ExprKind::Path(ref qpath) = source.node { + let var = if let hir::ExprKind::Path(ref qpath) = source.kind { let res = cx.tables().qpath_res(qpath, source.hir_id); cx .tables() diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 676827d3b3eba..f7cd29f2e67ef 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -153,16 +153,13 @@ impl<'a, 'tcx> Cx<'a, 'tcx> { } } - pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> { + pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pat<'tcx> { let tcx = self.tcx.global_tcx(); let p = match tcx.hir().get(p.hir_id) { Node::Pat(p) | Node::Binding(p) => p, node => bug!("pattern became {:?}", node) }; - Pattern::from_hir(tcx, - self.param_env.and(self.identity_substs), - self.tables(), - p) + Pat::from_hir(tcx, self.param_env.and(self.identity_substs), self.tables(), p) } pub fn trait_method(&mut self, diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index 63a9a83154b4f..a76377d24bdf9 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -20,8 +20,8 @@ pub mod cx; mod constant; pub mod pattern; -pub use self::pattern::{BindingMode, Pattern, PatternKind, PatternRange, FieldPattern}; -pub(crate) use self::pattern::PatternTypeProjection; +pub use self::pattern::{BindingMode, Pat, PatKind, PatRange, FieldPat}; +pub(crate) use self::pattern::PatTyProj; mod util; @@ -83,7 +83,7 @@ pub enum StmtKind<'tcx> { /// `let = ...` /// /// if a type is included, it is added as an ascription pattern - pattern: Pattern<'tcx>, + pattern: Pat<'tcx>, /// let pat: ty = ... initializer: Option>, @@ -293,7 +293,7 @@ pub struct FruInfo<'tcx> { #[derive(Clone, Debug)] pub struct Arm<'tcx> { - pub pattern: Pattern<'tcx>, + pub pattern: Pat<'tcx>, pub guard: Option>, pub body: ExprRef<'tcx>, pub lint_level: LintLevel, @@ -304,9 +304,9 @@ pub struct Arm<'tcx> { impl Arm<'tcx> { // HACK(or_patterns; Centril | dlrobertson): Remove this and // correctly handle each case in which this method is used. - pub fn top_pats_hack(&self) -> &[Pattern<'tcx>] { + pub fn top_pats_hack(&self) -> &[Pat<'tcx>] { match &*self.pattern.kind { - PatternKind::Or { pats } => pats, + PatKind::Or { pats } => pats, _ => std::slice::from_ref(&self.pattern), } } diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index e570ace8df1d2..75a84f6ec648b 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -163,7 +163,7 @@ use self::WitnessPreference::*; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; -use super::{FieldPattern, Pattern, PatternKind, PatternRange}; +use super::{FieldPat, Pat, PatKind, PatRange}; use super::{PatternFoldable, PatternFolder, compare_const_vals}; use rustc::hir::def_id::DefId; @@ -188,9 +188,7 @@ use std::ops::RangeInclusive; use std::u128; use std::convert::TryInto; -pub fn expand_pattern<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, pat: Pattern<'tcx>) - -> &'a Pattern<'tcx> -{ +pub fn expand_pattern<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, pat: Pat<'tcx>) -> &'a Pat<'tcx> { cx.pattern_arena.alloc(LiteralExpander { tcx: cx.tcx }.fold_pattern(&pat)) } @@ -243,24 +241,24 @@ impl LiteralExpander<'tcx> { } impl PatternFolder<'tcx> for LiteralExpander<'tcx> { - fn fold_pattern(&mut self, pat: &Pattern<'tcx>) -> Pattern<'tcx> { + fn fold_pattern(&mut self, pat: &Pat<'tcx>) -> Pat<'tcx> { debug!("fold_pattern {:?} {:?} {:?}", pat, pat.ty.kind, pat.kind); match (&pat.ty.kind, &*pat.kind) { ( &ty::Ref(_, rty, _), - &PatternKind::Constant { value: Const { + &PatKind::Constant { value: Const { val, ty: ty::TyS { kind: ty::Ref(_, crty, _), .. }, } }, ) => { - Pattern { + Pat { ty: pat.ty, span: pat.span, - kind: box PatternKind::Deref { - subpattern: Pattern { + kind: box PatKind::Deref { + subpattern: Pat { ty: rty, span: pat.span, - kind: box PatternKind::Constant { value: self.tcx.mk_const(Const { + kind: box PatKind::Constant { value: self.tcx.mk_const(Const { val: self.fold_const_value_deref(*val, rty, crty), ty: rty, }) }, @@ -268,7 +266,7 @@ impl PatternFolder<'tcx> for LiteralExpander<'tcx> { } } } - (_, &PatternKind::Binding { subpattern: Some(ref s), .. }) => { + (_, &PatKind::Binding { subpattern: Some(ref s), .. }) => { s.fold_with(self) } _ => pat.super_fold_with(self) @@ -276,10 +274,10 @@ impl PatternFolder<'tcx> for LiteralExpander<'tcx> { } } -impl<'tcx> Pattern<'tcx> { +impl<'tcx> Pat<'tcx> { fn is_wildcard(&self) -> bool { match *self.kind { - PatternKind::Binding { subpattern: None, .. } | PatternKind::Wild => + PatKind::Binding { subpattern: None, .. } | PatKind::Wild => true, _ => false } @@ -288,14 +286,14 @@ impl<'tcx> Pattern<'tcx> { /// A 2D matrix. Nx1 matrices are very common, which is why `SmallVec[_; 2]` /// works well for each row. -pub struct Matrix<'p, 'tcx>(Vec; 2]>>); +pub struct Matrix<'p, 'tcx>(Vec; 2]>>); impl<'p, 'tcx> Matrix<'p, 'tcx> { pub fn empty() -> Self { Matrix(vec![]) } - pub fn push(&mut self, row: SmallVec<[&'p Pattern<'tcx>; 2]>) { + pub fn push(&mut self, row: SmallVec<[&'p Pat<'tcx>; 2]>) { self.0.push(row) } } @@ -344,9 +342,9 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> { } } -impl<'p, 'tcx> FromIterator; 2]>> for Matrix<'p, 'tcx> { +impl<'p, 'tcx> FromIterator; 2]>> for Matrix<'p, 'tcx> { fn from_iter(iter: T) -> Self - where T: IntoIterator; 2]>> + where T: IntoIterator; 2]>> { Matrix(iter.into_iter().collect()) } @@ -362,8 +360,8 @@ pub struct MatchCheckCtxt<'a, 'tcx> { /// statement. pub module: DefId, param_env: ty::ParamEnv<'tcx>, - pub pattern_arena: &'a TypedArena>, - pub byte_array_map: FxHashMap<*const Pattern<'tcx>, Vec<&'a Pattern<'tcx>>>, + pub pattern_arena: &'a TypedArena>, + pub byte_array_map: FxHashMap<*const Pat<'tcx>, Vec<&'a Pat<'tcx>>>, } impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> { @@ -395,9 +393,9 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> { } } - fn is_non_exhaustive_variant<'p>(&self, pattern: &'p Pattern<'tcx>) -> bool { + fn is_non_exhaustive_variant<'p>(&self, pattern: &'p Pat<'tcx>) -> bool { match *pattern.kind { - PatternKind::Variant { adt_def, variant_index, .. } => { + PatKind::Variant { adt_def, variant_index, .. } => { let ref variant = adt_def.variants[variant_index]; variant.is_field_list_non_exhaustive() } @@ -476,7 +474,7 @@ pub enum WitnessPreference { } #[derive(Copy, Clone, Debug)] -struct PatternContext<'tcx> { +struct PatCtxt<'tcx> { ty: Ty<'tcx>, max_slice_length: u64, } @@ -514,10 +512,10 @@ struct PatternContext<'tcx> { /// /// The final `Pair(Some(_), true)` is then the resulting witness. #[derive(Clone, Debug)] -pub struct Witness<'tcx>(Vec>); +pub struct Witness<'tcx>(Vec>); impl<'tcx> Witness<'tcx> { - pub fn single_pattern(self) -> Pattern<'tcx> { + pub fn single_pattern(self) -> Pat<'tcx> { assert_eq!(self.0.len(), 1); self.0.into_iter().next().unwrap() } @@ -531,10 +529,10 @@ impl<'tcx> Witness<'tcx> { { let sub_pattern_tys = constructor_sub_pattern_tys(cx, ctor, ty); self.0.extend(sub_pattern_tys.into_iter().map(|ty| { - Pattern { + Pat { ty, span: DUMMY_SP, - kind: box PatternKind::Wild, + kind: box PatKind::Wild, } })); self.apply_constructor(cx, ctor, ty) @@ -569,7 +567,7 @@ impl<'tcx> Witness<'tcx> { ty::Adt(..) | ty::Tuple(..) => { let pats = pats.enumerate().map(|(i, p)| { - FieldPattern { + FieldPat { field: Field::new(i), pattern: p } @@ -577,26 +575,26 @@ impl<'tcx> Witness<'tcx> { if let ty::Adt(adt, substs) = ty.kind { if adt.is_enum() { - PatternKind::Variant { + PatKind::Variant { adt_def: adt, substs, variant_index: ctor.variant_index_for_adt(cx, adt), subpatterns: pats } } else { - PatternKind::Leaf { subpatterns: pats } + PatKind::Leaf { subpatterns: pats } } } else { - PatternKind::Leaf { subpatterns: pats } + PatKind::Leaf { subpatterns: pats } } } ty::Ref(..) => { - PatternKind::Deref { subpattern: pats.nth(0).unwrap() } + PatKind::Deref { subpattern: pats.nth(0).unwrap() } } ty::Slice(_) | ty::Array(..) => { - PatternKind::Slice { + PatKind::Slice { prefix: pats.collect(), slice: None, suffix: vec![] @@ -605,19 +603,19 @@ impl<'tcx> Witness<'tcx> { _ => { match *ctor { - ConstantValue(value) => PatternKind::Constant { value }, - ConstantRange(lo, hi, ty, end) => PatternKind::Range(PatternRange { + ConstantValue(value) => PatKind::Constant { value }, + ConstantRange(lo, hi, ty, end) => PatKind::Range(PatRange { lo: ty::Const::from_bits(cx.tcx, lo, ty::ParamEnv::empty().and(ty)), hi: ty::Const::from_bits(cx.tcx, hi, ty::ParamEnv::empty().and(ty)), end, }), - _ => PatternKind::Wild, + _ => PatKind::Wild, } } } }; - self.0.push(Pattern { + self.0.push(Pat { ty, span: DUMMY_SP, kind: Box::new(pat), @@ -636,7 +634,7 @@ impl<'tcx> Witness<'tcx> { /// `Option`, we do not include `Some(_)` in the returned list of constructors. fn all_constructors<'a, 'tcx>( cx: &mut MatchCheckCtxt<'a, 'tcx>, - pcx: PatternContext<'tcx>, + pcx: PatCtxt<'tcx>, ) -> Vec> { debug!("all_constructors({:?})", pcx.ty); let ctors = match pcx.ty.kind { @@ -710,7 +708,7 @@ fn all_constructors<'a, 'tcx>( fn max_slice_length<'p, 'a, 'tcx, I>(cx: &mut MatchCheckCtxt<'a, 'tcx>, patterns: I) -> u64 where - I: Iterator>, + I: Iterator>, 'tcx: 'p, { // The exhaustiveness-checking paper does not include any details on @@ -783,7 +781,7 @@ where for row in patterns { match *row.kind { - PatternKind::Constant { value } => { + PatKind::Constant { value } => { // extract the length of an array/slice from a constant match (value.val, &value.ty.kind) { (_, ty::Array(_, n)) => max_fixed_len = cmp::max( @@ -797,11 +795,11 @@ where _ => {}, } } - PatternKind::Slice { ref prefix, slice: None, ref suffix } => { + PatKind::Slice { ref prefix, slice: None, ref suffix } => { let fixed_len = prefix.len() as u64 + suffix.len() as u64; max_fixed_len = cmp::max(max_fixed_len, fixed_len); } - PatternKind::Slice { ref prefix, slice: Some(_), ref suffix } => { + PatKind::Slice { ref prefix, slice: Some(_), ref suffix } => { max_prefix_len = cmp::max(max_prefix_len, prefix.len() as u64); max_suffix_len = cmp::max(max_suffix_len, suffix.len() as u64); } @@ -874,18 +872,18 @@ impl<'tcx> IntRange<'tcx> { fn from_pat( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, - mut pat: &Pattern<'tcx>, + mut pat: &Pat<'tcx>, ) -> Option> { let range = loop { match pat.kind { - box PatternKind::Constant { value } => break ConstantValue(value), - box PatternKind::Range(PatternRange { lo, hi, end }) => break ConstantRange( + box PatKind::Constant { value } => break ConstantValue(value), + box PatKind::Range(PatRange { lo, hi, end }) => break ConstantRange( lo.eval_bits(tcx, param_env, lo.ty), hi.eval_bits(tcx, param_env, hi.ty), lo.ty, end, ), - box PatternKind::AscribeUserType { ref subpattern, .. } => { + box PatKind::AscribeUserType { ref subpattern, .. } => { pat = subpattern; }, _ => return None, @@ -1058,7 +1056,7 @@ fn compute_missing_ctors<'tcx>( /// inputs that will match `v` but not any of the sets in `m`. /// /// All the patterns at each column of the `matrix ++ v` matrix must -/// have the same type, except that wildcard (PatternKind::Wild) patterns +/// have the same type, except that wildcard (PatKind::Wild) patterns /// with type `TyErr` are also allowed, even if the "type of the column" /// is not `TyErr`. That is used to represent private fields, as using their /// real type would assert that they are inhabited. @@ -1070,7 +1068,7 @@ fn compute_missing_ctors<'tcx>( pub fn is_useful<'p, 'a, 'tcx>( cx: &mut MatchCheckCtxt<'a, 'tcx>, matrix: &Matrix<'p, 'tcx>, - v: &[&Pattern<'tcx>], + v: &[&Pat<'tcx>], witness: WitnessPreference, ) -> Usefulness<'tcx> { let &Matrix(ref rows) = matrix; @@ -1094,7 +1092,7 @@ pub fn is_useful<'p, 'a, 'tcx>( assert!(rows.iter().all(|r| r.len() == v.len())); - let pcx = PatternContext { + let pcx = PatCtxt { // TyErr is used to represent the type of wildcard patterns matching // against inaccessible (private) fields of structs, so that we won't // be able to observe whether the types of the struct's fields are @@ -1247,10 +1245,10 @@ pub fn is_useful<'p, 'a, 'tcx>( // All constructors are unused. Add wild patterns // rather than each individual constructor. pats.into_iter().map(|mut witness| { - witness.0.push(Pattern { + witness.0.push(Pat { ty: pcx.ty, span: DUMMY_SP, - kind: box PatternKind::Wild, + kind: box PatKind::Wild, }); witness }).collect() @@ -1285,7 +1283,7 @@ pub fn is_useful<'p, 'a, 'tcx>( fn is_useful_specialized<'p, 'a, 'tcx>( cx: &mut MatchCheckCtxt<'a, 'tcx>, &Matrix(ref m): &Matrix<'p, 'tcx>, - v: &[&Pattern<'tcx>], + v: &[&Pat<'tcx>], ctor: Constructor<'tcx>, lty: Ty<'tcx>, witness: WitnessPreference, @@ -1293,10 +1291,10 @@ fn is_useful_specialized<'p, 'a, 'tcx>( debug!("is_useful_specialized({:#?}, {:#?}, {:?})", v, ctor, lty); let sub_pat_tys = constructor_sub_pattern_tys(cx, &ctor, lty); let wild_patterns_owned: Vec<_> = sub_pat_tys.iter().map(|ty| { - Pattern { + Pat { ty, span: DUMMY_SP, - kind: box PatternKind::Wild, + kind: box PatKind::Wild, } }).collect(); let wild_patterns: Vec<_> = wild_patterns_owned.iter().collect(); @@ -1325,33 +1323,33 @@ fn is_useful_specialized<'p, 'a, 'tcx>( /// /// Returns `None` in case of a catch-all, which can't be specialized. fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>, - pat: &Pattern<'tcx>, - pcx: PatternContext<'tcx>) + pat: &Pat<'tcx>, + pcx: PatCtxt<'tcx>) -> Option>> { match *pat.kind { - PatternKind::AscribeUserType { ref subpattern, .. } => + PatKind::AscribeUserType { ref subpattern, .. } => pat_constructors(cx, subpattern, pcx), - PatternKind::Binding { .. } | PatternKind::Wild => None, - PatternKind::Leaf { .. } | PatternKind::Deref { .. } => Some(vec![Single]), - PatternKind::Variant { adt_def, variant_index, .. } => { + PatKind::Binding { .. } | PatKind::Wild => None, + PatKind::Leaf { .. } | PatKind::Deref { .. } => Some(vec![Single]), + PatKind::Variant { adt_def, variant_index, .. } => { Some(vec![Variant(adt_def.variants[variant_index].def_id)]) } - PatternKind::Constant { value } => Some(vec![ConstantValue(value)]), - PatternKind::Range(PatternRange { lo, hi, end }) => + PatKind::Constant { value } => Some(vec![ConstantValue(value)]), + PatKind::Range(PatRange { lo, hi, end }) => Some(vec![ConstantRange( lo.eval_bits(cx.tcx, cx.param_env, lo.ty), hi.eval_bits(cx.tcx, cx.param_env, hi.ty), lo.ty, end, )]), - PatternKind::Array { .. } => match pcx.ty.kind { + PatKind::Array { .. } => match pcx.ty.kind { ty::Array(_, length) => Some(vec![ Slice(length.eval_usize(cx.tcx, cx.param_env)) ]), _ => span_bug!(pat.span, "bad ty {:?} for array pattern", pcx.ty) }, - PatternKind::Slice { ref prefix, ref slice, ref suffix } => { + PatKind::Slice { ref prefix, ref slice, ref suffix } => { let pat_len = prefix.len() as u64 + suffix.len() as u64; if slice.is_some() { Some((pat_len..pcx.max_slice_length+1).map(Slice).collect()) @@ -1359,7 +1357,7 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>, Some(vec![Slice(pat_len)]) } } - PatternKind::Or { .. } => { + PatKind::Or { .. } => { bug!("support for or-patterns has not been fully implemented yet."); } } @@ -1446,9 +1444,9 @@ fn slice_pat_covered_by_const<'tcx>( tcx: TyCtxt<'tcx>, _span: Span, const_val: &'tcx ty::Const<'tcx>, - prefix: &[Pattern<'tcx>], - slice: &Option>, - suffix: &[Pattern<'tcx>], + prefix: &[Pat<'tcx>], + slice: &Option>, + suffix: &[Pat<'tcx>], param_env: ty::ParamEnv<'tcx>, ) -> Result { let data: &[u8] = match (const_val.val, &const_val.ty.kind) { @@ -1481,7 +1479,7 @@ fn slice_pat_covered_by_const<'tcx>( data[data.len()-suffix.len()..].iter().zip(suffix)) { match pat.kind { - box PatternKind::Constant { value } => { + box PatKind::Constant { value } => { let b = value.eval_bits(tcx, param_env, pat.ty); assert_eq!(b as u8 as u128, b); if b as u8 != *ch { @@ -1625,8 +1623,8 @@ fn constructor_intersects_pattern<'p, 'tcx>( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, ctor: &Constructor<'tcx>, - pat: &'p Pattern<'tcx>, -) -> Option; 2]>> { + pat: &'p Pat<'tcx>, +) -> Option; 2]>> { if should_treat_range_exhaustively(tcx, ctor) { match (IntRange::from_ctor(tcx, param_env, ctor), IntRange::from_pat(tcx, param_env, pat)) { (Some(ctor), Some(pat)) => { @@ -1654,11 +1652,11 @@ fn constructor_covered_by_range<'tcx>( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, ctor: &Constructor<'tcx>, - pat: &Pattern<'tcx>, + pat: &Pat<'tcx>, ) -> Result { let (from, to, end, ty) = match pat.kind { - box PatternKind::Constant { value } => (value, value, RangeEnd::Included, value.ty), - box PatternKind::Range(PatternRange { lo, hi, end }) => (lo, hi, end, lo.ty), + box PatKind::Constant { value } => (value, value, RangeEnd::Included, value.ty), + box PatKind::Range(PatRange { lo, hi, end }) => (lo, hi, end, lo.ty), _ => bug!("`constructor_covered_by_range` called with {:?}", pat), }; trace!("constructor_covered_by_range {:#?}, {:#?}, {:#?}, {}", ctor, from, to, ty); @@ -1714,9 +1712,9 @@ fn constructor_covered_by_range<'tcx>( } fn patterns_for_variant<'p, 'tcx>( - subpatterns: &'p [FieldPattern<'tcx>], - wild_patterns: &[&'p Pattern<'tcx>]) - -> SmallVec<[&'p Pattern<'tcx>; 2]> + subpatterns: &'p [FieldPat<'tcx>], + wild_patterns: &[&'p Pat<'tcx>]) + -> SmallVec<[&'p Pat<'tcx>; 2]> { let mut result = SmallVec::from_slice(wild_patterns); @@ -1738,37 +1736,37 @@ fn patterns_for_variant<'p, 'tcx>( /// fields filled with wild patterns. fn specialize<'p, 'a: 'p, 'tcx>( cx: &mut MatchCheckCtxt<'a, 'tcx>, - r: &[&'p Pattern<'tcx>], + r: &[&'p Pat<'tcx>], constructor: &Constructor<'tcx>, - wild_patterns: &[&'p Pattern<'tcx>], -) -> Option; 2]>> { + wild_patterns: &[&'p Pat<'tcx>], +) -> Option; 2]>> { let pat = &r[0]; let head = match *pat.kind { - PatternKind::AscribeUserType { ref subpattern, .. } => { + PatKind::AscribeUserType { ref subpattern, .. } => { specialize(cx, ::std::slice::from_ref(&subpattern), constructor, wild_patterns) } - PatternKind::Binding { .. } | PatternKind::Wild => { + PatKind::Binding { .. } | PatKind::Wild => { Some(SmallVec::from_slice(wild_patterns)) } - PatternKind::Variant { adt_def, variant_index, ref subpatterns, .. } => { + PatKind::Variant { adt_def, variant_index, ref subpatterns, .. } => { let ref variant = adt_def.variants[variant_index]; Some(Variant(variant.def_id)) .filter(|variant_constructor| variant_constructor == constructor) .map(|_| patterns_for_variant(subpatterns, wild_patterns)) } - PatternKind::Leaf { ref subpatterns } => { + PatKind::Leaf { ref subpatterns } => { Some(patterns_for_variant(subpatterns, wild_patterns)) } - PatternKind::Deref { ref subpattern } => { + PatKind::Deref { ref subpattern } => { Some(smallvec![subpattern]) } - PatternKind::Constant { value } => { + PatKind::Constant { value } => { match *constructor { Slice(..) => { // we extract an `Option` for the pointer because slices of zero elements don't @@ -1827,10 +1825,10 @@ fn specialize<'p, 'a: 'p, 'tcx>( ).ok()?; let scalar = scalar.not_undef().ok()?; let value = ty::Const::from_scalar(cx.tcx, scalar, ty); - let pattern = Pattern { + let pattern = Pat { ty, span: pat.span, - kind: box PatternKind::Constant { value }, + kind: box PatKind::Constant { value }, }; Some(&*cx.pattern_arena.alloc(pattern)) }).collect() @@ -1847,15 +1845,15 @@ fn specialize<'p, 'a: 'p, 'tcx>( } } - PatternKind::Range { .. } => { + PatKind::Range { .. } => { // If the constructor is a: // Single value: add a row if the pattern contains the constructor. // Range: add a row if the constructor intersects the pattern. constructor_intersects_pattern(cx.tcx, cx.param_env, constructor, pat) } - PatternKind::Array { ref prefix, ref slice, ref suffix } | - PatternKind::Slice { ref prefix, ref slice, ref suffix } => { + PatKind::Array { ref prefix, ref slice, ref suffix } | + PatKind::Slice { ref prefix, ref slice, ref suffix } => { match *constructor { Slice(..) => { let pat_len = prefix.len() + suffix.len(); @@ -1888,7 +1886,7 @@ fn specialize<'p, 'a: 'p, 'tcx>( } } - PatternKind::Or { .. } => { + PatKind::Or { .. } => { bug!("support for or-patterns has not been fully implemented yet."); } }; diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 3791ae1c41e4a..4572519683d4f 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -2,7 +2,7 @@ use super::_match::{MatchCheckCtxt, Matrix, expand_pattern, is_useful}; use super::_match::Usefulness::*; use super::_match::WitnessPreference::*; -use super::{Pattern, PatternContext, PatternError, PatternKind}; +use super::{PatCtxt, PatternError, PatKind}; use rustc::middle::borrowck::SignalledError; use rustc::session::Session; @@ -14,7 +14,7 @@ use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc::hir::def::*; use rustc::hir::def_id::DefId; use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; -use rustc::hir::{self, Pat, PatKind}; +use rustc::hir::{self, Pat}; use smallvec::smallvec; use std::slice; @@ -59,7 +59,7 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> { fn visit_expr(&mut self, ex: &'tcx hir::Expr) { intravisit::walk_expr(self, ex); - if let hir::ExprKind::Match(ref scrut, ref arms, source) = ex.node { + if let hir::ExprKind::Match(ref scrut, ref arms, source) = ex.kind { self.check_match(scrut, arms, source); } } @@ -88,7 +88,7 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> { } } -impl PatternContext<'_, '_> { +impl PatCtxt<'_, '_> { fn report_inlining_errors(&self, pat_span: Span) { for error in &self.errors { match *error { @@ -152,7 +152,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> { let inlined_arms : Vec<(Vec<_>, _)> = arms.iter().map(|arm| ( arm.top_pats_hack().iter().map(|pat| { - let mut patcx = PatternContext::new(self.tcx, + let mut patcx = PatCtxt::new(self.tcx, self.param_env.and(self.identity_substs), self.tables); patcx.include_lint_checks(); @@ -249,7 +249,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> { fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) { let module = self.tcx.hir().get_module_parent(pat.hir_id); MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| { - let mut patcx = PatternContext::new(self.tcx, + let mut patcx = PatCtxt::new(self.tcx, self.param_env.and(self.identity_substs), self.tables); patcx.include_lint_checks(); @@ -270,8 +270,8 @@ impl<'tcx> MatchVisitor<'_, 'tcx> { "refutable pattern in {}: {} not covered", origin, joined_patterns ); - err.span_label(pat.span, match &pat.node { - PatKind::Path(hir::QPath::Resolved(None, path)) + err.span_label(pat.span, match &pat.kind { + hir::PatKind::Path(hir::QPath::Resolved(None, path)) if path.segments.len() == 1 && path.segments[0].args.is_none() => { format!("interpreted as {} {} pattern, not new variable", path.res.article(), path.res.descr()) @@ -286,7 +286,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> { fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pat) { pat.walk(|p| { - if let PatKind::Binding(_, _, ident, None) = p.node { + if let hir::PatKind::Binding(_, _, ident, None) = p.kind { if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) { if bm != ty::BindByValue(hir::MutImmutable) { // Nothing to check. @@ -321,11 +321,11 @@ fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pa /// Checks for common cases of "catchall" patterns that may not be intended as such. fn pat_is_catchall(pat: &Pat) -> bool { - match pat.node { - PatKind::Binding(.., None) => true, - PatKind::Binding(.., Some(ref s)) => pat_is_catchall(s), - PatKind::Ref(ref s, _) => pat_is_catchall(s), - PatKind::Tuple(ref v, _) => v.iter().all(|p| { + match pat.kind { + hir::PatKind::Binding(.., None) => true, + hir::PatKind::Binding(.., Some(ref s)) => pat_is_catchall(s), + hir::PatKind::Ref(ref s, _) => pat_is_catchall(s), + hir::PatKind::Tuple(ref v, _) => v.iter().all(|p| { pat_is_catchall(&p) }), _ => false @@ -335,7 +335,7 @@ fn pat_is_catchall(pat: &Pat) -> bool { // Check for unreachable patterns fn check_arms<'tcx>( cx: &mut MatchCheckCtxt<'_, 'tcx>, - arms: &[(Vec<(&Pattern<'tcx>, &hir::Pat)>, Option<&hir::Expr>)], + arms: &[(Vec<(&super::Pat<'tcx>, &hir::Pat)>, Option<&hir::Expr>)], source: hir::MatchSource, ) { let mut seen = Matrix::empty(); @@ -420,8 +420,8 @@ fn check_not_useful( cx: &mut MatchCheckCtxt<'_, 'tcx>, ty: Ty<'tcx>, matrix: &Matrix<'_, 'tcx>, -) -> Result<(), Vec>> { - let wild_pattern = Pattern { ty, span: DUMMY_SP, kind: box PatternKind::Wild }; +) -> Result<(), Vec>> { + let wild_pattern = super::Pat { ty, span: DUMMY_SP, kind: box PatKind::Wild }; match is_useful(cx, matrix, &[&wild_pattern], ConstructWitness) { NotUseful => Ok(()), // This is good, wildcard pattern isn't reachable. UsefulWithWitness(pats) => Err(if pats.is_empty() { @@ -458,7 +458,7 @@ fn check_exhaustive<'tcx>( .emit(); } -fn joined_uncovered_patterns(witnesses: &[Pattern<'_>]) -> String { +fn joined_uncovered_patterns(witnesses: &[super::Pat<'_>]) -> String { const LIMIT: usize = 3; match witnesses { [] => bug!(), @@ -475,7 +475,7 @@ fn joined_uncovered_patterns(witnesses: &[Pattern<'_>]) -> String { } } -fn pattern_not_convered_label(witnesses: &[Pattern<'_>], joined_patterns: &str) -> String { +fn pattern_not_convered_label(witnesses: &[super::Pat<'_>], joined_patterns: &str) -> String { format!("pattern{} {} not covered", rustc_errors::pluralise!(witnesses.len()), joined_patterns) } @@ -484,7 +484,7 @@ fn adt_defined_here( cx: &MatchCheckCtxt<'_, '_>, err: &mut DiagnosticBuilder<'_>, ty: Ty<'_>, - witnesses: &[Pattern<'_>], + witnesses: &[super::Pat<'_>], ) { let ty = ty.peel_refs(); if let ty::Adt(def, _) = ty.kind { @@ -500,13 +500,13 @@ fn adt_defined_here( } } -fn maybe_point_at_variant(ty: Ty<'_>, patterns: &[Pattern<'_>]) -> Vec { +fn maybe_point_at_variant(ty: Ty<'_>, patterns: &[super::Pat<'_>]) -> Vec { let mut covered = vec![]; if let ty::Adt(def, _) = ty.kind { // Don't point at variants that have already been covered due to other patterns to avoid // visual clutter. for pattern in patterns { - use PatternKind::{AscribeUserType, Deref, Variant, Or, Leaf}; + use PatKind::{AscribeUserType, Deref, Variant, Or, Leaf}; match &*pattern.kind { AscribeUserType { subpattern, .. } | Deref { subpattern } => { covered.extend(maybe_point_at_variant(ty, slice::from_ref(&subpattern))); @@ -568,7 +568,7 @@ fn check_legality_of_move_bindings(cx: &mut MatchVisitor<'_, '_>, has_guard: boo }; pat.walk(|p| { - if let PatKind::Binding(.., sub) = &p.node { + if let hir::PatKind::Binding(.., sub) = &p.kind { if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) { if let ty::BindByValue(..) = bm { let pat_ty = cx.tables.node_type(p.hir_id); @@ -618,8 +618,8 @@ impl<'v> Visitor<'v> for AtBindingPatternVisitor<'_, '_, '_> { } fn visit_pat(&mut self, pat: &Pat) { - match pat.node { - PatKind::Binding(.., ref subpat) => { + match pat.kind { + hir::PatKind::Binding(.., ref subpat) => { if !self.bindings_allowed { struct_span_err!(self.cx.tcx.sess, pat.span, E0303, "pattern bindings are not allowed after an `@`") diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index e42f6125f21d9..4d2fee3d160ed 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -19,7 +19,7 @@ use rustc::ty::{self, Region, TyCtxt, AdtDef, Ty, UserType, DefIdTree}; use rustc::ty::{CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations}; use rustc::ty::subst::{SubstsRef, GenericArg}; use rustc::ty::layout::{VariantIdx, Size}; -use rustc::hir::{self, PatKind, RangeEnd}; +use rustc::hir::{self, RangeEnd}; use rustc::hir::def::{CtorOf, Res, DefKind, CtorKind}; use rustc::hir::pat_util::EnumerateAndAdjustIterator; use rustc::hir::ptr::P; @@ -48,25 +48,25 @@ pub enum BindingMode { } #[derive(Clone, Debug)] -pub struct FieldPattern<'tcx> { +pub struct FieldPat<'tcx> { pub field: Field, - pub pattern: Pattern<'tcx>, + pub pattern: Pat<'tcx>, } #[derive(Clone, Debug)] -pub struct Pattern<'tcx> { +pub struct Pat<'tcx> { pub ty: Ty<'tcx>, pub span: Span, - pub kind: Box>, + pub kind: Box>, } #[derive(Copy, Clone, Debug, PartialEq)] -pub struct PatternTypeProjection<'tcx> { +pub struct PatTyProj<'tcx> { pub user_ty: CanonicalUserType<'tcx>, } -impl<'tcx> PatternTypeProjection<'tcx> { +impl<'tcx> PatTyProj<'tcx> { pub(crate) fn from_user_type(user_annotation: CanonicalUserType<'tcx>) -> Self { Self { user_ty: user_annotation, @@ -92,7 +92,7 @@ impl<'tcx> PatternTypeProjection<'tcx> { #[derive(Copy, Clone, Debug, PartialEq)] pub struct Ascription<'tcx> { - pub user_ty: PatternTypeProjection<'tcx>, + pub user_ty: PatTyProj<'tcx>, /// Variance to use when relating the type `user_ty` to the **type of the value being /// matched**. Typically, this is `Variance::Covariant`, since the value being matched must /// have a type that is some subtype of the ascribed type. @@ -116,12 +116,12 @@ pub struct Ascription<'tcx> { } #[derive(Clone, Debug)] -pub enum PatternKind<'tcx> { +pub enum PatKind<'tcx> { Wild, AscribeUserType { ascription: Ascription<'tcx>, - subpattern: Pattern<'tcx>, + subpattern: Pat<'tcx>, }, /// `x`, `ref x`, `x @ P`, etc. @@ -131,7 +131,7 @@ pub enum PatternKind<'tcx> { mode: BindingMode, var: hir::HirId, ty: Ty<'tcx>, - subpattern: Option>, + subpattern: Option>, }, /// `Foo(...)` or `Foo{...}` or `Foo`, where `Foo` is a variant name from an ADT with @@ -140,57 +140,57 @@ pub enum PatternKind<'tcx> { adt_def: &'tcx AdtDef, substs: SubstsRef<'tcx>, variant_index: VariantIdx, - subpatterns: Vec>, + subpatterns: Vec>, }, /// `(...)`, `Foo(...)`, `Foo{...}`, or `Foo`, where `Foo` is a variant name from an ADT with /// a single variant. Leaf { - subpatterns: Vec>, + subpatterns: Vec>, }, /// `box P`, `&P`, `&mut P`, etc. Deref { - subpattern: Pattern<'tcx>, + subpattern: Pat<'tcx>, }, Constant { value: &'tcx ty::Const<'tcx>, }, - Range(PatternRange<'tcx>), + Range(PatRange<'tcx>), /// Matches against a slice, checking the length and extracting elements. /// irrefutable when there is a slice pattern and both `prefix` and `suffix` are empty. /// e.g., `&[ref xs @ ..]`. Slice { - prefix: Vec>, - slice: Option>, - suffix: Vec>, + prefix: Vec>, + slice: Option>, + suffix: Vec>, }, /// Fixed match against an array; irrefutable. Array { - prefix: Vec>, - slice: Option>, - suffix: Vec>, + prefix: Vec>, + slice: Option>, + suffix: Vec>, }, /// An or-pattern, e.g. `p | q`. /// Invariant: `pats.len() >= 2`. Or { - pats: Vec>, + pats: Vec>, }, } #[derive(Copy, Clone, Debug, PartialEq)] -pub struct PatternRange<'tcx> { +pub struct PatRange<'tcx> { pub lo: &'tcx ty::Const<'tcx>, pub hi: &'tcx ty::Const<'tcx>, pub end: RangeEnd, } -impl<'tcx> fmt::Display for Pattern<'tcx> { +impl<'tcx> fmt::Display for Pat<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Printing lists is a chore. let mut first = true; @@ -205,10 +205,10 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { let mut start_or_comma = || start_or_continue(", "); match *self.kind { - PatternKind::Wild => write!(f, "_"), - PatternKind::AscribeUserType { ref subpattern, .. } => + PatKind::Wild => write!(f, "_"), + PatKind::AscribeUserType { ref subpattern, .. } => write!(f, "{}: _", subpattern), - PatternKind::Binding { mutability, name, mode, ref subpattern, .. } => { + PatKind::Binding { mutability, name, mode, ref subpattern, .. } => { let is_mut = match mode { BindingMode::ByValue => mutability == Mutability::Mut, BindingMode::ByRef(bk) => { @@ -225,10 +225,10 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { } Ok(()) } - PatternKind::Variant { ref subpatterns, .. } | - PatternKind::Leaf { ref subpatterns } => { + PatKind::Variant { ref subpatterns, .. } | + PatKind::Leaf { ref subpatterns } => { let variant = match *self.kind { - PatternKind::Variant { adt_def, variant_index, .. } => { + PatKind::Variant { adt_def, variant_index, .. } => { Some(&adt_def.variants[variant_index]) } _ => if let ty::Adt(adt, _) = self.ty.kind { @@ -252,7 +252,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { let mut printed = 0; for p in subpatterns { - if let PatternKind::Wild = *p.pattern.kind { + if let PatKind::Wild = *p.pattern.kind { continue; } let name = variant.fields[p.field.index()].ident; @@ -294,7 +294,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { Ok(()) } - PatternKind::Deref { ref subpattern } => { + PatKind::Deref { ref subpattern } => { match self.ty.kind { ty::Adt(def, _) if def.is_box() => write!(f, "box ")?, ty::Ref(_, _, mutbl) => { @@ -307,10 +307,10 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { } write!(f, "{}", subpattern) } - PatternKind::Constant { value } => { + PatKind::Constant { value } => { write!(f, "{}", value) } - PatternKind::Range(PatternRange { lo, hi, end }) => { + PatKind::Range(PatRange { lo, hi, end }) => { write!(f, "{}", lo)?; match end { RangeEnd::Included => write!(f, "..=")?, @@ -318,8 +318,8 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { } write!(f, "{}", hi) } - PatternKind::Slice { ref prefix, ref slice, ref suffix } | - PatternKind::Array { ref prefix, ref slice, ref suffix } => { + PatKind::Slice { ref prefix, ref slice, ref suffix } | + PatKind::Array { ref prefix, ref slice, ref suffix } => { write!(f, "[")?; for p in prefix { write!(f, "{}{}", start_or_comma(), p)?; @@ -327,7 +327,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { if let Some(ref slice) = *slice { write!(f, "{}", start_or_comma())?; match *slice.kind { - PatternKind::Wild => {} + PatKind::Wild => {} _ => write!(f, "{}", slice)? } write!(f, "..")?; @@ -337,7 +337,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { } write!(f, "]") } - PatternKind::Or { ref pats } => { + PatKind::Or { ref pats } => { for pat in pats { write!(f, "{}{}", start_or_continue(" | "), pat)?; } @@ -347,7 +347,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { } } -pub struct PatternContext<'a, 'tcx> { +pub struct PatCtxt<'a, 'tcx> { pub tcx: TyCtxt<'tcx>, pub param_env: ty::ParamEnv<'tcx>, pub tables: &'a ty::TypeckTables<'tcx>, @@ -356,31 +356,31 @@ pub struct PatternContext<'a, 'tcx> { include_lint_checks: bool, } -impl<'a, 'tcx> Pattern<'tcx> { +impl<'a, 'tcx> Pat<'tcx> { pub fn from_hir( tcx: TyCtxt<'tcx>, param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>, tables: &'a ty::TypeckTables<'tcx>, pat: &'tcx hir::Pat, ) -> Self { - let mut pcx = PatternContext::new(tcx, param_env_and_substs, tables); + let mut pcx = PatCtxt::new(tcx, param_env_and_substs, tables); let result = pcx.lower_pattern(pat); if !pcx.errors.is_empty() { let msg = format!("encountered errors lowering pattern: {:?}", pcx.errors); tcx.sess.delay_span_bug(pat.span, &msg); } - debug!("Pattern::from_hir({:?}) = {:?}", pat, result); + debug!("Pat::from_hir({:?}) = {:?}", pat, result); result } } -impl<'a, 'tcx> PatternContext<'a, 'tcx> { +impl<'a, 'tcx> PatCtxt<'a, 'tcx> { pub fn new( tcx: TyCtxt<'tcx>, param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>, tables: &'a ty::TypeckTables<'tcx>, ) -> Self { - PatternContext { + PatCtxt { tcx, param_env: param_env_and_substs.param_env, tables, @@ -395,7 +395,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { self } - pub fn lower_pattern(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> { + pub fn lower_pattern(&mut self, pat: &'tcx hir::Pat) -> Pat<'tcx> { // When implicit dereferences have been inserted in this pattern, the unadjusted lowered // pattern has the type that results *after* dereferencing. For example, in this code: // @@ -412,7 +412,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { // `vec![&&Option, &Option]`. // // Applying the adjustments, we want to instead output `&&Some(n)` (as a HAIR pattern). So - // we wrap the unadjusted pattern in `PatternKind::Deref` repeatedly, consuming the + // we wrap the unadjusted pattern in `PatKind::Deref` repeatedly, consuming the // adjustments in *reverse order* (last-in-first-out, so that the last `Deref` inserted // gets the least-dereferenced type). let unadjusted_pat = self.lower_pattern_unadjusted(pat); @@ -424,10 +424,10 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { .rev() .fold(unadjusted_pat, |pat, ref_ty| { debug!("{:?}: wrapping pattern with type {:?}", pat, ref_ty); - Pattern { + Pat { span: pat.span, ty: ref_ty, - kind: Box::new(PatternKind::Deref { subpattern: pat }), + kind: Box::new(PatKind::Deref { subpattern: pat }), } }, ) @@ -436,30 +436,30 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { fn lower_range_expr( &mut self, expr: &'tcx hir::Expr, - ) -> (PatternKind<'tcx>, Option>) { + ) -> (PatKind<'tcx>, Option>) { match self.lower_lit(expr) { - PatternKind::AscribeUserType { + PatKind::AscribeUserType { ascription: lo_ascription, - subpattern: Pattern { kind: box kind, .. }, + subpattern: Pat { kind: box kind, .. }, } => (kind, Some(lo_ascription)), kind => (kind, None), } } - fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> { + fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pat<'tcx> { let mut ty = self.tables.node_type(pat.hir_id); - let kind = match pat.node { - PatKind::Wild => PatternKind::Wild, + let kind = match pat.kind { + hir::PatKind::Wild => PatKind::Wild, - PatKind::Lit(ref value) => self.lower_lit(value), + hir::PatKind::Lit(ref value) => self.lower_lit(value), - PatKind::Range(ref lo_expr, ref hi_expr, end) => { + hir::PatKind::Range(ref lo_expr, ref hi_expr, end) => { let (lo, lo_ascription) = self.lower_range_expr(lo_expr); let (hi, hi_ascription) = self.lower_range_expr(hi_expr); let mut kind = match (lo, hi) { - (PatternKind::Constant { value: lo }, PatternKind::Constant { value: hi }) => { + (PatKind::Constant { value: lo }, PatKind::Constant { value: hi }) => { assert_eq!(lo.ty, ty); assert_eq!(hi.ty, ty); let cmp = compare_const_vals( @@ -471,7 +471,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ); match (end, cmp) { (RangeEnd::Excluded, Some(Ordering::Less)) => - PatternKind::Range(PatternRange { lo, hi, end }), + PatKind::Range(PatRange { lo, hi, end }), (RangeEnd::Excluded, _) => { span_err!( self.tcx.sess, @@ -479,13 +479,13 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { E0579, "lower range bound must be less than upper", ); - PatternKind::Wild + PatKind::Wild } (RangeEnd::Included, Some(Ordering::Equal)) => { - PatternKind::Constant { value: lo } + PatKind::Constant { value: lo } } (RangeEnd::Included, Some(Ordering::Less)) => { - PatternKind::Range(PatternRange { lo, hi, end }) + PatKind::Range(PatRange { lo, hi, end }) } (RangeEnd::Included, _) => { let mut err = struct_span_err!( @@ -506,7 +506,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { to be less than or equal to the end of the range."); } err.emit(); - PatternKind::Wild + PatKind::Wild } } }, @@ -519,7 +519,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ), ); - PatternKind::Wild + PatKind::Wild }, }; @@ -528,9 +528,9 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { // constants somewhere. Have them on the range pattern. for ascription in &[lo_ascription, hi_ascription] { if let Some(ascription) = ascription { - kind = PatternKind::AscribeUserType { + kind = PatKind::AscribeUserType { ascription: *ascription, - subpattern: Pattern { span: pat.span, ty, kind: Box::new(kind), }, + subpattern: Pat { span: pat.span, ty, kind: Box::new(kind), }, }; } } @@ -538,20 +538,20 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { kind } - PatKind::Path(ref qpath) => { + hir::PatKind::Path(ref qpath) => { return self.lower_path(qpath, pat.hir_id, pat.span); } - PatKind::Ref(ref subpattern, _) | - PatKind::Box(ref subpattern) => { - PatternKind::Deref { subpattern: self.lower_pattern(subpattern) } + hir::PatKind::Ref(ref subpattern, _) | + hir::PatKind::Box(ref subpattern) => { + PatKind::Deref { subpattern: self.lower_pattern(subpattern) } } - PatKind::Slice(ref prefix, ref slice, ref suffix) => { + hir::PatKind::Slice(ref prefix, ref slice, ref suffix) => { match ty.kind { ty::Ref(_, ty, _) => - PatternKind::Deref { - subpattern: Pattern { + PatKind::Deref { + subpattern: Pat { ty, span: pat.span, kind: Box::new(self.slice_or_array_pattern( @@ -562,7 +562,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ty::Array(..) => self.slice_or_array_pattern(pat.span, ty, prefix, slice, suffix), ty::Error => { // Avoid ICE - return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; + return Pat { span: pat.span, ty, kind: Box::new(PatKind::Wild) }; } _ => span_bug!( @@ -572,32 +572,32 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } } - PatKind::Tuple(ref subpatterns, ddpos) => { + hir::PatKind::Tuple(ref subpatterns, ddpos) => { match ty.kind { ty::Tuple(ref tys) => { let subpatterns = subpatterns.iter() .enumerate_and_adjust(tys.len(), ddpos) - .map(|(i, subpattern)| FieldPattern { + .map(|(i, subpattern)| FieldPat { field: Field::new(i), pattern: self.lower_pattern(subpattern) }) .collect(); - PatternKind::Leaf { subpatterns } + PatKind::Leaf { subpatterns } } ty::Error => { // Avoid ICE (#50577) - return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; + return Pat { span: pat.span, ty, kind: Box::new(PatKind::Wild) }; } _ => span_bug!(pat.span, "unexpected type for tuple pattern: {:?}", ty), } } - PatKind::Binding(_, id, ident, ref sub) => { + hir::PatKind::Binding(_, id, ident, ref sub) => { let var_ty = self.tables.node_type(pat.hir_id); if let ty::Error = var_ty.kind { // Avoid ICE - return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; + return Pat { span: pat.span, ty, kind: Box::new(PatKind::Wild) }; }; let bm = *self.tables.pat_binding_modes().get(pat.hir_id) .expect("missing binding mode"); @@ -624,7 +624,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } } - PatternKind::Binding { + PatKind::Binding { mutability, mode, name: ident.name, @@ -634,12 +634,12 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } } - PatKind::TupleStruct(ref qpath, ref subpatterns, ddpos) => { + hir::PatKind::TupleStruct(ref qpath, ref subpatterns, ddpos) => { let res = self.tables.qpath_res(qpath, pat.hir_id); let adt_def = match ty.kind { ty::Adt(adt_def, _) => adt_def, ty::Error => { // Avoid ICE (#50585) - return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) }; + return Pat { span: pat.span, ty, kind: Box::new(PatKind::Wild) }; } _ => span_bug!(pat.span, "tuple struct pattern not applied to an ADT {:?}", @@ -650,7 +650,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { let subpatterns = subpatterns.iter() .enumerate_and_adjust(variant_def.fields.len(), ddpos) - .map(|(i, field)| FieldPattern { + .map(|(i, field)| FieldPat { field: Field::new(i), pattern: self.lower_pattern(field), }) @@ -659,12 +659,12 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { self.lower_variant_or_leaf(res, pat.hir_id, pat.span, ty, subpatterns) } - PatKind::Struct(ref qpath, ref fields, _) => { + hir::PatKind::Struct(ref qpath, ref fields, _) => { let res = self.tables.qpath_res(qpath, pat.hir_id); let subpatterns = fields.iter() .map(|field| { - FieldPattern { + FieldPat { field: Field::new(self.tcx.field_index(field.hir_id, self.tables)), pattern: self.lower_pattern(&field.pat), @@ -675,35 +675,35 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { self.lower_variant_or_leaf(res, pat.hir_id, pat.span, ty, subpatterns) } - PatKind::Or(ref pats) => { - PatternKind::Or { + hir::PatKind::Or(ref pats) => { + PatKind::Or { pats: pats.iter().map(|p| self.lower_pattern(p)).collect(), } } }; - Pattern { + Pat { span: pat.span, ty, kind: Box::new(kind), } } - fn lower_patterns(&mut self, pats: &'tcx [P]) -> Vec> { + fn lower_patterns(&mut self, pats: &'tcx [P]) -> Vec> { pats.iter().map(|p| self.lower_pattern(p)).collect() } - fn lower_opt_pattern(&mut self, pat: &'tcx Option>) -> Option> + fn lower_opt_pattern(&mut self, pat: &'tcx Option>) -> Option> { pat.as_ref().map(|p| self.lower_pattern(p)) } fn flatten_nested_slice_patterns( &mut self, - prefix: Vec>, - slice: Option>, - suffix: Vec>) - -> (Vec>, Option>, Vec>) + prefix: Vec>, + slice: Option>, + suffix: Vec>) + -> (Vec>, Option>, Vec>) { let orig_slice = match slice { Some(orig_slice) => orig_slice, @@ -715,8 +715,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { // dance because of intentional borrow-checker stupidity. let kind = *orig_slice.kind; match kind { - PatternKind::Slice { prefix, slice, mut suffix } | - PatternKind::Array { prefix, slice, mut suffix } => { + PatKind::Slice { prefix, slice, mut suffix } | + PatKind::Array { prefix, slice, mut suffix } => { let mut orig_prefix = orig_prefix; orig_prefix.extend(prefix); @@ -725,7 +725,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { (orig_prefix, slice, suffix) } _ => { - (orig_prefix, Some(Pattern { + (orig_prefix, Some(Pat { kind: box kind, ..orig_slice }), orig_suffix) } @@ -739,7 +739,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { prefix: &'tcx [P], slice: &'tcx Option>, suffix: &'tcx [P]) - -> PatternKind<'tcx> + -> PatKind<'tcx> { let prefix = self.lower_patterns(prefix); let slice = self.lower_opt_pattern(slice); @@ -750,14 +750,14 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { match ty.kind { ty::Slice(..) => { // matching a slice or fixed-length array - PatternKind::Slice { prefix: prefix, slice: slice, suffix: suffix } + PatKind::Slice { prefix: prefix, slice: slice, suffix: suffix } } ty::Array(_, len) => { // fixed-length array let len = len.eval_usize(self.tcx, self.param_env); assert!(len >= prefix.len() as u64 + suffix.len() as u64); - PatternKind::Array { prefix: prefix, slice: slice, suffix: suffix } + PatKind::Array { prefix: prefix, slice: slice, suffix: suffix } } _ => { @@ -772,8 +772,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { hir_id: hir::HirId, span: Span, ty: Ty<'tcx>, - subpatterns: Vec>, - ) -> PatternKind<'tcx> { + subpatterns: Vec>, + ) -> PatKind<'tcx> { let res = match res { Res::Def(DefKind::Ctor(CtorOf::Variant, ..), variant_ctor_id) => { let variant_id = self.tcx.parent(variant_ctor_id).unwrap(); @@ -791,18 +791,18 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ty::Adt(_, substs) | ty::FnDef(_, substs) => substs, ty::Error => { // Avoid ICE (#50585) - return PatternKind::Wild; + return PatKind::Wild; } _ => bug!("inappropriate type for def: {:?}", ty), }; - PatternKind::Variant { + PatKind::Variant { adt_def, substs, variant_index: adt_def.variant_index_with_id(variant_id), subpatterns, } } else { - PatternKind::Leaf { subpatterns } + PatKind::Leaf { subpatterns } } } @@ -813,25 +813,25 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { | Res::Def(DefKind::AssocTy, _) | Res::SelfTy(..) | Res::SelfCtor(..) => { - PatternKind::Leaf { subpatterns } + PatKind::Leaf { subpatterns } } _ => { self.errors.push(PatternError::NonConstPath(span)); - PatternKind::Wild + PatKind::Wild } }; if let Some(user_ty) = self.user_substs_applied_to_ty_of_hir_id(hir_id) { debug!("lower_variant_or_leaf: kind={:?} user_ty={:?} span={:?}", kind, user_ty, span); - kind = PatternKind::AscribeUserType { - subpattern: Pattern { + kind = PatKind::AscribeUserType { + subpattern: Pat { span, ty, kind: Box::new(kind), }, ascription: Ascription { - user_ty: PatternTypeProjection::from_user_type(user_ty), + user_ty: PatTyProj::from_user_type(user_ty), user_ty_span: span, variance: ty::Variance::Covariant, }, @@ -848,7 +848,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { qpath: &hir::QPath, id: hir::HirId, span: Span) - -> Pattern<'tcx> { + -> Pat<'tcx> { let ty = self.tables.node_type(id); let res = self.tables.qpath_res(qpath, id); let is_associated_const = match res { @@ -878,11 +878,11 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { let user_provided_types = self.tables().user_provided_types(); return if let Some(u_ty) = user_provided_types.get(id) { - let user_ty = PatternTypeProjection::from_user_type(*u_ty); - Pattern { + let user_ty = PatTyProj::from_user_type(*u_ty); + Pat { span, kind: Box::new( - PatternKind::AscribeUserType { + PatKind::AscribeUserType { subpattern: pattern, ascription: Ascription { /// Note that use `Contravariant` here. See the @@ -904,7 +904,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { span, "could not evaluate constant pattern", ); - PatternKind::Wild + PatKind::Wild } } }, @@ -914,14 +914,14 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } else { PatternError::StaticInPattern(span) }); - PatternKind::Wild + PatKind::Wild }, } } _ => self.lower_variant_or_leaf(res, id, span, ty, vec![]), }; - Pattern { + Pat { span, ty, kind: Box::new(kind), @@ -932,8 +932,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { /// The special case for negation exists to allow things like `-128_i8` /// which would overflow if we tried to evaluate `128_i8` and then negate /// afterwards. - fn lower_lit(&mut self, expr: &'tcx hir::Expr) -> PatternKind<'tcx> { - match expr.node { + fn lower_lit(&mut self, expr: &'tcx hir::Expr) -> PatKind<'tcx> { + match expr.kind { hir::ExprKind::Lit(ref lit) => { let ty = self.tables.expr_ty(expr); match lit_to_const(&lit.node, self.tcx, ty, false) { @@ -946,15 +946,15 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { }, Err(LitToConstError::UnparseableFloat) => { self.errors.push(PatternError::FloatBug); - PatternKind::Wild + PatKind::Wild }, - Err(LitToConstError::Reported) => PatternKind::Wild, + Err(LitToConstError::Reported) => PatKind::Wild, } }, hir::ExprKind::Path(ref qpath) => *self.lower_path(qpath, expr.hir_id, expr.span).kind, hir::ExprKind::Unary(hir::UnNeg, ref expr) => { let ty = self.tables.expr_ty(expr); - let lit = match expr.node { + let lit = match expr.kind { hir::ExprKind::Lit(ref lit) => lit, _ => span_bug!(expr.span, "not a literal: {:?}", expr), }; @@ -968,9 +968,9 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { }, Err(LitToConstError::UnparseableFloat) => { self.errors.push(PatternError::FloatBug); - PatternKind::Wild + PatKind::Wild }, - Err(LitToConstError::Reported) => PatternKind::Wild, + Err(LitToConstError::Reported) => PatKind::Wild, } } _ => span_bug!(expr.span, "not a literal: {:?}", expr), @@ -986,7 +986,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { cv: &'tcx ty::Const<'tcx>, id: hir::HirId, span: Span, - ) -> Pattern<'tcx> { + ) -> Pat<'tcx> { // This method is just a warpper handling a validity check; the heavy lifting is // performed by the recursive const_to_pat_inner method, which is not meant to be // invoked except by this method. @@ -1057,7 +1057,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { // value, so that we will not subsequently issue an irrelevant // lint for the same const value. saw_const_match_error: &mut bool, - ) -> Pattern<'tcx> { + ) -> Pat<'tcx> { let mut adt_subpattern = |i, variant_opt| { let field = Field::new(i); @@ -1069,7 +1069,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { let mut adt_subpatterns = |n, variant_opt| { (0..n).map(|i| { let field = Field::new(i); - FieldPattern { + FieldPat { field, pattern: adt_subpattern(i, variant_opt), } @@ -1085,7 +1085,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { span, "floating-point types cannot be used in patterns", ); - PatternKind::Constant { + PatKind::Constant { value: cv, } } @@ -1093,7 +1093,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { // Matching on union fields is unsafe, we can't hide it in constants *saw_const_match_error = true; self.tcx.sess.span_err(span, "cannot use unions in constant patterns"); - PatternKind::Wild + PatKind::Wild } // keep old code until future-compat upgraded to errors. ty::Adt(adt_def, _) if !self.tcx.has_attr(adt_def.did, sym::structural_match) => { @@ -1106,13 +1106,13 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ); *saw_const_match_error = true; self.tcx.sess.span_err(span, &msg); - PatternKind::Wild + PatKind::Wild } // keep old code until future-compat upgraded to errors. ty::Ref(_, ty::TyS { kind: ty::Adt(adt_def, _), .. }, _) if !self.tcx.has_attr(adt_def.did, sym::structural_match) => { // HACK(estebank): Side-step ICE #53708, but anything other than erroring here - // would be wrong. Returnging `PatternKind::Wild` is not technically correct. + // would be wrong. Returnging `PatKind::Wild` is not technically correct. let path = self.tcx.def_path_str(adt_def.did); let msg = format!( "to use a constant of type `{}` in a pattern, \ @@ -1122,7 +1122,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ); *saw_const_match_error = true; self.tcx.sess.span_err(span, &msg); - PatternKind::Wild + PatKind::Wild } ty::Adt(adt_def, substs) if adt_def.is_enum() => { let variant_index = const_variant_index(self.tcx, self.param_env, cv); @@ -1130,7 +1130,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { adt_def.variants[variant_index].fields.len(), Some(variant_index), ); - PatternKind::Variant { + PatKind::Variant { adt_def, substs, variant_index, @@ -1139,17 +1139,17 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } ty::Adt(adt_def, _) => { let struct_var = adt_def.non_enum_variant(); - PatternKind::Leaf { + PatKind::Leaf { subpatterns: adt_subpatterns(struct_var.fields.len(), None), } } ty::Tuple(fields) => { - PatternKind::Leaf { + PatKind::Leaf { subpatterns: adt_subpatterns(fields.len(), None), } } ty::Array(_, n) => { - PatternKind::Array { + PatKind::Array { prefix: (0..n.eval_usize(self.tcx, self.param_env)) .map(|i| adt_subpattern(i as usize, None)) .collect(), @@ -1158,13 +1158,13 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } } _ => { - PatternKind::Constant { + PatKind::Constant { value: cv, } } }; - Pattern { + Pat { span, ty: cv.ty, kind: Box::new(kind), @@ -1293,7 +1293,7 @@ fn search_for_adt_without_structural_match<'tcx>(tcx: TyCtxt<'tcx>, } } -impl UserAnnotatedTyHelpers<'tcx> for PatternContext<'_, 'tcx> { +impl UserAnnotatedTyHelpers<'tcx> for PatCtxt<'_, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -1313,11 +1313,11 @@ pub trait PatternFoldable<'tcx> : Sized { } pub trait PatternFolder<'tcx> : Sized { - fn fold_pattern(&mut self, pattern: &Pattern<'tcx>) -> Pattern<'tcx> { + fn fold_pattern(&mut self, pattern: &Pat<'tcx>) -> Pat<'tcx> { pattern.super_fold_with(self) } - fn fold_pattern_kind(&mut self, kind: &PatternKind<'tcx>) -> PatternKind<'tcx> { + fn fold_pattern_kind(&mut self, kind: &PatKind<'tcx>) -> PatKind<'tcx> { kind.super_fold_with(self) } } @@ -1358,25 +1358,25 @@ CloneImpls!{ <'tcx> Span, Field, Mutability, ast::Name, hir::HirId, usize, ty::Const<'tcx>, Region<'tcx>, Ty<'tcx>, BindingMode, &'tcx AdtDef, SubstsRef<'tcx>, &'tcx GenericArg<'tcx>, UserType<'tcx>, - UserTypeProjection, PatternTypeProjection<'tcx> + UserTypeProjection, PatTyProj<'tcx> } -impl<'tcx> PatternFoldable<'tcx> for FieldPattern<'tcx> { +impl<'tcx> PatternFoldable<'tcx> for FieldPat<'tcx> { fn super_fold_with>(&self, folder: &mut F) -> Self { - FieldPattern { + FieldPat { field: self.field.fold_with(folder), pattern: self.pattern.fold_with(folder) } } } -impl<'tcx> PatternFoldable<'tcx> for Pattern<'tcx> { +impl<'tcx> PatternFoldable<'tcx> for Pat<'tcx> { fn fold_with>(&self, folder: &mut F) -> Self { folder.fold_pattern(self) } fn super_fold_with>(&self, folder: &mut F) -> Self { - Pattern { + Pat { ty: self.ty.fold_with(folder), span: self.span.fold_with(folder), kind: self.kind.fold_with(folder) @@ -1384,22 +1384,22 @@ impl<'tcx> PatternFoldable<'tcx> for Pattern<'tcx> { } } -impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> { +impl<'tcx> PatternFoldable<'tcx> for PatKind<'tcx> { fn fold_with>(&self, folder: &mut F) -> Self { folder.fold_pattern_kind(self) } fn super_fold_with>(&self, folder: &mut F) -> Self { match *self { - PatternKind::Wild => PatternKind::Wild, - PatternKind::AscribeUserType { + PatKind::Wild => PatKind::Wild, + PatKind::AscribeUserType { ref subpattern, ascription: Ascription { variance, ref user_ty, user_ty_span, }, - } => PatternKind::AscribeUserType { + } => PatKind::AscribeUserType { subpattern: subpattern.fold_with(folder), ascription: Ascription { user_ty: user_ty.fold_with(folder), @@ -1407,14 +1407,14 @@ impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> { user_ty_span, }, }, - PatternKind::Binding { + PatKind::Binding { mutability, name, mode, var, ty, ref subpattern, - } => PatternKind::Binding { + } => PatKind::Binding { mutability: mutability.fold_with(folder), name: name.fold_with(folder), mode: mode.fold_with(folder), @@ -1422,52 +1422,52 @@ impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> { ty: ty.fold_with(folder), subpattern: subpattern.fold_with(folder), }, - PatternKind::Variant { + PatKind::Variant { adt_def, substs, variant_index, ref subpatterns, - } => PatternKind::Variant { + } => PatKind::Variant { adt_def: adt_def.fold_with(folder), substs: substs.fold_with(folder), variant_index, subpatterns: subpatterns.fold_with(folder) }, - PatternKind::Leaf { + PatKind::Leaf { ref subpatterns, - } => PatternKind::Leaf { + } => PatKind::Leaf { subpatterns: subpatterns.fold_with(folder), }, - PatternKind::Deref { + PatKind::Deref { ref subpattern, - } => PatternKind::Deref { + } => PatKind::Deref { subpattern: subpattern.fold_with(folder), }, - PatternKind::Constant { + PatKind::Constant { value - } => PatternKind::Constant { + } => PatKind::Constant { value, }, - PatternKind::Range(range) => PatternKind::Range(range), - PatternKind::Slice { + PatKind::Range(range) => PatKind::Range(range), + PatKind::Slice { ref prefix, ref slice, ref suffix, - } => PatternKind::Slice { + } => PatKind::Slice { prefix: prefix.fold_with(folder), slice: slice.fold_with(folder), suffix: suffix.fold_with(folder) }, - PatternKind::Array { + PatKind::Array { ref prefix, ref slice, ref suffix - } => PatternKind::Array { + } => PatKind::Array { prefix: prefix.fold_with(folder), slice: slice.fold_with(folder), suffix: suffix.fold_with(folder) }, - PatternKind::Or { ref pats } => PatternKind::Or { pats: pats.fold_with(folder) }, + PatKind::Or { ref pats } => PatKind::Or { pats: pats.fold_with(folder) }, } } } diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index e6fa833c7b25b..853fcb1beabf5 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -200,7 +200,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M if let Some((&var_hir_id, _)) = upvars.get_index(field) { let node = self.ecx.tcx.hir().get(var_hir_id); if let hir::Node::Binding(pat) = node { - if let hir::PatKind::Binding(_, _, ident, _) = pat.node { + if let hir::PatKind::Binding(_, _, ident, _) = pat.kind { name = Some(ident.name); } } diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index d7a837e7ede66..cc8f4759e1837 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -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(..) | @@ -1058,7 +1058,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> { } fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) { - match ii.node { + match ii.kind { hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => { let def_id = self.tcx.hir().local_def_id(ii.hir_id); self.push_if_root(def_id); @@ -1141,7 +1141,7 @@ fn create_mono_items_for_default_impls<'tcx>( item: &'tcx hir::Item, output: &mut Vec>, ) { - match item.node { + match item.kind { hir::ItemKind::Impl(_, _, _, ref generics, .., ref impl_item_refs) => { for param in &generics.params { match param.kind { diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index faec8c7cbe400..acd53ac68ae3f 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -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 { diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index abe2d2f4a549e..7423a668f94d2 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1768,7 +1768,7 @@ fn args_required_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option { ret.insert(a as usize); } _ => return None, } diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 5b78727fdd5ad..0339b85ca55e3 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -107,7 +107,7 @@ impl<'a> AstValidator<'a> { // rust-lang/rust#57979: bug in old `visit_generic_args` called // `walk_ty` rather than `visit_ty`, skipping outer `impl Trait` // if it happened to occur at `ty`. - if let TyKind::ImplTrait(..) = ty.node { + if let TyKind::ImplTrait(..) = ty.kind { self.warning_period_57979_didnt_record_next_impl_trait = true; } } @@ -126,7 +126,7 @@ impl<'a> AstValidator<'a> { // rust-lang/rust#57979: bug in old `visit_generic_args` called // `walk_ty` rather than `visit_ty`, skippping outer `impl Trait` // if it happened to occur at `ty`. - if let TyKind::ImplTrait(..) = ty.node { + if let TyKind::ImplTrait(..) = ty.kind { self.warning_period_57979_didnt_record_next_impl_trait = true; } self.visit_ty(ty); @@ -149,7 +149,7 @@ impl<'a> AstValidator<'a> { // Mirrors `visit::walk_ty`, but tracks relevant state. fn walk_ty(&mut self, t: &'a Ty) { - match t.node { + match t.kind { TyKind::ImplTrait(..) => { let outer_impl_trait = self.outer_impl_trait(t.span); self.with_impl_trait(Some(outer_impl_trait), |this| visit::walk_ty(this, t)) @@ -231,7 +231,7 @@ impl<'a> AstValidator<'a> { fn check_decl_no_pat(&self, decl: &FnDecl, report_err: ReportFn) { for arg in &decl.inputs { - match arg.pat.node { + match arg.pat.kind { PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), _, None) | PatKind::Wild => {} PatKind::Ident(BindingMode::ByValue(Mutability::Mutable), _, None) => @@ -286,11 +286,11 @@ impl<'a> AstValidator<'a> { // m!(S); // ``` fn check_expr_within_pat(&self, expr: &Expr, allow_paths: bool) { - match expr.node { + match expr.kind { ExprKind::Lit(..) | ExprKind::Err => {} ExprKind::Path(..) if allow_paths => {} ExprKind::Unary(UnOp::Neg, ref inner) - if match inner.node { ExprKind::Lit(_) => true, _ => false } => {} + if match inner.kind { ExprKind::Lit(_) => true, _ => false } => {} _ => self.err_handler().span_err(expr.span, "arbitrary expressions aren't allowed \ in patterns") } @@ -442,7 +442,7 @@ fn validate_generics_order<'a>( impl<'a> Visitor<'a> for AstValidator<'a> { fn visit_expr(&mut self, expr: &'a Expr) { - match &expr.node { + match &expr.kind { ExprKind::Closure(_, _, _, fn_decl, _, _) => { self.check_fn_decl(fn_decl); } @@ -456,7 +456,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } fn visit_ty(&mut self, ty: &'a Ty) { - match ty.node { + match ty.kind { TyKind::BareFn(ref bfty) => { self.check_fn_decl(&bfty.decl); self.check_decl_no_pat(&bfty.decl, |span, _| { @@ -538,10 +538,10 @@ 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.node { + if let TyKind::Err = ty.kind { self.err_handler() .struct_span_err(item.span, "`impl Trait for .. {}` is an obsolete syntax") .help("use `auto trait Trait {}` instead").emit(); @@ -551,7 +551,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } for impl_item in impl_items { self.invalid_visibility(&impl_item.vis, None); - if let ImplItemKind::Method(ref sig, _) = impl_item.node { + if let ImplItemKind::Method(ref sig, _) = impl_item.kind { self.check_trait_fn_not_const(sig.header.constness); self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness.node); } @@ -628,7 +628,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } self.no_questions_in_bounds(bounds, "supertraits", true); for trait_item in trait_items { - if let TraitItemKind::Method(ref sig, ref block) = trait_item.node { + if let TraitItemKind::Method(ref sig, ref block) = trait_item.kind { self.check_fn_decl(&sig.decl); self.check_trait_fn_not_async(trait_item.span, sig.header.asyncness.node); self.check_trait_fn_not_const(sig.header.constness); @@ -682,7 +682,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } fn visit_foreign_item(&mut self, fi: &'a ForeignItem) { - match fi.node { + match fi.kind { ForeignItemKind::Fn(ref decl, _) => { self.check_fn_decl(decl); self.check_decl_no_pat(decl, |span, _| { @@ -786,7 +786,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } fn visit_pat(&mut self, pat: &'a Pat) { - match pat.node { + match pat.kind { PatKind::Lit(ref expr) => { self.check_expr_within_pat(expr, false); } @@ -832,11 +832,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } fn visit_impl_item(&mut self, ii: &'a ImplItem) { - match ii.node { - ImplItemKind::Method(ref sig, _) => { - self.check_fn_decl(&sig.decl); - } - _ => {} + if let ImplItemKind::Method(ref sig, _) = ii.kind { + self.check_fn_decl(&sig.decl); } visit::walk_impl_item(self, ii); } diff --git a/src/librustc_passes/layout_test.rs b/src/librustc_passes/layout_test.rs index 45a185dccf29c..06683c16e4a9b 100644 --- a/src/librustc_passes/layout_test.rs +++ b/src/librustc_passes/layout_test.rs @@ -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); diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index dbfbec32a6fbf..6c9e018fafc4f 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -54,7 +54,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { } fn visit_expr(&mut self, e: &'hir hir::Expr) { - match e.node { + match e.kind { hir::ExprKind::Loop(ref b, _, source) => { self.with_context(Loop(source), |v| v.visit_block(&b)); } @@ -99,7 +99,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { let loop_kind = if loop_id == hir::DUMMY_HIR_ID { None } else { - Some(match self.hir_map.expect_expr(loop_id).node { + Some(match self.hir_map.expect_expr(loop_id).kind { hir::ExprKind::Loop(_, _, source) => source, ref r => span_bug!(e.span, "break label resolved to a non-loop: {:?}", r), diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index d4c3dc917e5e9..a93ca7847d68a 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -212,7 +212,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { } fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability { - match stmt.node { + match stmt.kind { hir::StmtKind::Local(ref local) => { if self.remove_mut_rvalue_borrow(&local.pat) { if let Some(init) = &local.init { @@ -280,7 +280,7 @@ fn check_expr_kind<'a, 'tcx>( _ => Promotable }; - let node_result = match e.node { + let kind_result = match e.kind { hir::ExprKind::Box(ref expr) => { let _ = v.check_expr(&expr); NotPromotable @@ -376,7 +376,7 @@ fn check_expr_kind<'a, 'tcx>( } let mut callee = &**callee; loop { - callee = match callee.node { + callee = match callee.kind { hir::ExprKind::Block(ref block, _) => match block.expr { Some(ref tail) => &tail, None => break @@ -385,7 +385,7 @@ fn check_expr_kind<'a, 'tcx>( }; } // The callee is an arbitrary expression, it doesn't necessarily have a definition. - let def = if let hir::ExprKind::Path(ref qpath) = callee.node { + let def = if let hir::ExprKind::Path(ref qpath) = callee.kind { v.tables.qpath_res(qpath, callee.hir_id) } else { Res::Err @@ -553,7 +553,7 @@ fn check_expr_kind<'a, 'tcx>( NotPromotable } }; - ty_result & node_result + ty_result & kind_result } /// Checks the adjustments of an expression. diff --git a/src/librustc_plugin/build.rs b/src/librustc_plugin/build.rs index f1bf1111cf700..01559a95c9c31 100644 --- a/src/librustc_plugin/build.rs +++ b/src/librustc_plugin/build.rs @@ -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)); } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index d7f5fdeb00c52..f44692b7aea7d 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -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::::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`. @@ -1028,7 +1028,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - match expr.node { + match expr.kind { hir::ExprKind::Struct(ref qpath, ref fields, ref base) => { let res = self.tables.qpath_res(qpath, expr.hir_id); let adt = self.tables.expr_ty(expr).ty_adt_def().unwrap(); @@ -1062,7 +1062,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { } fn visit_pat(&mut self, pat: &'tcx hir::Pat) { - match pat.node { + match pat.kind { PatKind::Struct(ref qpath, ref fields, _) => { let res = self.tables.qpath_res(qpath, pat.hir_id); let adt = self.tables.pat_ty(pat).ty_adt_def().unwrap(); @@ -1197,7 +1197,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { // Do not check nested expressions if the error already happened. return; } - match expr.node { + match expr.kind { hir::ExprKind::Assign(.., ref rhs) | hir::ExprKind::Match(ref rhs, ..) => { // Do not report duplicate errors for `x = y` and `match x { ... }`. if self.check_expr_pat_type(rhs.hir_id, rhs.span) { @@ -1389,14 +1389,14 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a } fn visit_ty(&mut self, ty: &hir::Ty) { - if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = ty.node { + if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = ty.kind { if self.inner.path_is_private_type(path) { self.contains_private = true; // Found what we're looking for, so let's stop working. return } } - if let hir::TyKind::Path(_) = ty.node { + if let hir::TyKind::Path(_) = ty.kind { if self.at_outer_type { self.outer_type_is_public_path = true; } @@ -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(_) => {} @@ -1489,7 +1489,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { impl_item_refs.iter() .any(|impl_item_ref| { let impl_item = self.tcx.hir().impl_item(impl_item_ref.id); - match impl_item.node { + match impl_item.kind { hir::ImplItemKind::Const(..) | hir::ImplItemKind::Method(..) => { self.access_levels.is_reachable( @@ -1515,7 +1515,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { // don't erroneously report errors for private // types in private items. let impl_item = self.tcx.hir().impl_item(impl_item_ref.id); - match impl_item.node { + match impl_item.kind { hir::ImplItemKind::Const(..) | hir::ImplItemKind::Method(..) if self.item_is_public(&impl_item.hir_id, &impl_item.vis) => @@ -1548,7 +1548,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { // Those in 3. are warned with this call. for impl_item_ref in impl_item_refs { let impl_item = self.tcx.hir().impl_item(impl_item_ref.id); - if let hir::ImplItemKind::TyAlias(ref ty) = impl_item.node { + if let hir::ImplItemKind::TyAlias(ref ty) = impl_item.kind { self.visit_ty(ty); } } @@ -1628,7 +1628,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { } fn visit_ty(&mut self, t: &'tcx hir::Ty) { - if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = t.node { + if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = t.kind { if self.path_is_private_type(path) { self.old_error_set.insert(t.hir_id); } @@ -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`. diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 11dcf5b4b0019..f76aa95dd2cc8 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -309,7 +309,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { fn block_needs_anonymous_module(&mut self, block: &Block) -> bool { // If any statements are items, we need to create an anonymous module - block.stmts.iter().any(|statement| match statement.node { + block.stmts.iter().any(|statement| match statement.kind { StmtKind::Item(_) | StmtKind::Mac(_) => true, _ => false, }) @@ -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 @@ -813,7 +813,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { /// Constructs the reduced graph for one foreign item. fn build_reduced_graph_for_foreign_item(&mut self, item: &ForeignItem) { - let (res, ns) = match item.node { + let (res, ns) = match item.kind { ForeignItemKind::Fn(..) => { (Res::Def(DefKind::Fn, self.r.definitions.local_def_id(item.id)), ValueNS) } @@ -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`"); @@ -944,7 +944,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { } let ill_formed = |span| span_err!(self.r.session, span, E0466, "bad macro import"); match attr.meta() { - Some(meta) => match meta.node { + Some(meta) => match meta.kind { MetaItemKind::Word => { import_all = Some(meta.span); break; @@ -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) @@ -1122,7 +1122,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { macro_rules! method { ($visit:ident: $ty:ty, $invoc:path, $walk:ident) => { fn $visit(&mut self, node: &'b $ty) { - if let $invoc(..) = node.node { + if let $invoc(..) = node.kind { self.visit_invoc(node.id); } else { visit::$walk(self, node); @@ -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 @@ -1161,7 +1161,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { } fn visit_stmt(&mut self, stmt: &'b ast::Stmt) { - if let ast::StmtKind::Mac(..) = stmt.node { + if let ast::StmtKind::Mac(..) = stmt.kind { self.parent_scope.legacy = self.visit_invoc(stmt.id); } else { visit::walk_stmt(self, stmt); @@ -1169,7 +1169,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { } fn visit_foreign_item(&mut self, foreign_item: &'b ForeignItem) { - if let ForeignItemKind::Macro(_) = foreign_item.node { + if let ForeignItemKind::Macro(_) = foreign_item.kind { self.visit_invoc(foreign_item.id); return; } @@ -1190,14 +1190,14 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { fn visit_trait_item(&mut self, item: &'b TraitItem) { let parent = self.parent_scope.module; - if let TraitItemKind::Macro(_) = item.node { + if let TraitItemKind::Macro(_) = item.kind { self.visit_invoc(item.id); return } // Add the item to the trait info. let item_def_id = self.r.definitions.local_def_id(item.id); - let (res, ns) = match item.node { + let (res, ns) = match item.kind { TraitItemKind::Const(..) => (Res::Def(DefKind::AssocConst, item_def_id), ValueNS), TraitItemKind::Method(ref sig, _) => { if sig.decl.has_self() { @@ -1219,7 +1219,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { fn visit_token(&mut self, t: Token) { if let token::Interpolated(nt) = t.kind { if let token::NtExpr(ref expr) = *nt { - if let ast::ExprKind::Mac(..) = expr.node { + if let ast::ExprKind::Mac(..) = expr.kind { self.visit_invoc(expr.id); } } diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 0d85be83e12e0..737589acf8d81 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -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; } diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index aae283b745236..33a85c6c77026 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -221,7 +221,7 @@ impl<'a> PathSource<'a> { ValueNS => "method or associated constant", MacroNS => bug!("associated macro"), }, - PathSource::Expr(parent) => match parent.map(|p| &p.node) { + PathSource::Expr(parent) => match parent.map(|p| &p.kind) { // "function" here means "anything callable" rather than `DefKind::Fn`, // this is not precise but usually more helpful than just "value". Some(&ExprKind::Call(..)) => "function", @@ -384,7 +384,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> { self.resolve_local(local); } fn visit_ty(&mut self, ty: &'tcx Ty) { - match ty.node { + match ty.kind { TyKind::Path(ref qself, ref path) => { self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type); } @@ -406,7 +406,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> { visit::walk_poly_trait_ref(self, tref, m); } fn visit_foreign_item(&mut self, foreign_item: &'tcx ForeignItem) { - let generic_params = match foreign_item.node { + let generic_params = match foreign_item.kind { ForeignItemKind::Fn(_, ref generics) => { HasGenericParams(generics, ItemRibKind) } @@ -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, _) => { @@ -740,7 +740,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { AssocItemRibKind, ); this.with_generic_param_rib(generic_params, |this| { - match trait_item.node { + match trait_item.kind { TraitItemKind::Const(ref ty, ref default) => { this.visit_ty(ty); @@ -938,7 +938,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { ) -> T { let trait_assoc_types = replace( &mut self.current_trait_assoc_types, - trait_items.iter().filter_map(|item| match &item.node { + trait_items.iter().filter_map(|item| match &item.kind { TraitItemKind::Type(bounds, _) if bounds.len() == 0 => Some(item.ident), _ => None, }).collect(), @@ -1035,7 +1035,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { AssocItemRibKind); this.with_generic_param_rib(generic_params, |this| { use crate::ResolutionError::*; - match impl_item.node { + match impl_item.kind { ImplItemKind::Const(..) => { debug!( "resolve_implementation ImplItemKind::Const", @@ -1146,7 +1146,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { let mut binding_map = FxHashMap::default(); pat.walk(&mut |pat| { - match pat.node { + match pat.kind { PatKind::Ident(binding_mode, ident, ref sub_pat) if sub_pat.is_some() || self.is_base_res_local(pat.id) => { @@ -1246,7 +1246,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { /// Check the consistency of the outermost or-patterns. fn check_consistent_bindings_top(&mut self, pat: &Pat) { - pat.walk(&mut |pat| match pat.node { + pat.walk(&mut |pat| match pat.kind { PatKind::Or(ref ps) => { self.check_consistent_bindings(ps); false @@ -1308,8 +1308,8 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { ) { // Visit all direct subpatterns of this pattern. pat.walk(&mut |pat| { - debug!("resolve_pattern pat={:?} node={:?}", pat, pat.node); - match pat.node { + debug!("resolve_pattern pat={:?} node={:?}", pat, pat.kind); + match pat.kind { PatKind::Ident(bmode, ident, ref sub) => { // First try to resolve the identifier as some existing entity, // then fall back to a fresh binding. @@ -1804,8 +1804,8 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { // Descend into the block. for stmt in &block.stmts { - if let StmtKind::Item(ref item) = stmt.node { - if let ItemKind::MacroDef(..) = item.node { + if let StmtKind::Item(ref item) = stmt.kind { + 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))); @@ -1836,7 +1836,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { self.record_candidate_traits_for_expr_if_necessary(expr); // Next, resolve the node. - match expr.node { + match expr.kind { ExprKind::Path(ref qself, ref path) => { self.smart_resolve_path(expr.id, qself.as_ref(), path, PathSource::Expr(parent)); visit::walk_expr(self, expr); @@ -1968,7 +1968,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { } fn record_candidate_traits_for_expr_if_necessary(&mut self, expr: &Expr) { - match expr.node { + match expr.kind { ExprKind::Field(_, ident) => { // FIXME(#6890): Even though you can't treat a method like a // field, we need to add any trait methods we find that match diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index cd1689f21cc6e..0d35cc53ac6f3 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -325,7 +325,7 @@ impl<'a> LateResolutionVisitor<'a, '_> { let ns = source.namespace(); let is_expected = &|res| source.is_expected(res); - let path_sep = |err: &mut DiagnosticBuilder<'_>, expr: &Expr| match expr.node { + let path_sep = |err: &mut DiagnosticBuilder<'_>, expr: &Expr| match expr.kind { ExprKind::Field(_, ident) => { err.span_suggestion( expr.span, @@ -472,7 +472,7 @@ impl<'a> LateResolutionVisitor<'a, '_> { where FilterFn: Fn(Res) -> bool { fn extract_node_id(t: &Ty) -> Option { - match t.node { + match t.kind { TyKind::Path(None, _) => Some(t.id), TyKind::Rptr(_, ref mut_ty) => extract_node_id(&mut_ty.ty), // This doesn't handle the remaining `Ty` variants as they are not diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 74f68e5147126..bf86a37433840 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -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 diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 55f6b91e71431..edd2db3c8f738 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -385,7 +385,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { } if let ast::FunctionRetTy::Ty(ref ret_ty) = decl.output { - if let ast::TyKind::ImplTrait(..) = ret_ty.node { + if let ast::TyKind::ImplTrait(..) = ret_ty.kind { // FIXME: Opaque type desugaring prevents us from easily // processing trait bounds. See `visit_ty` for more details. } else { @@ -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; @@ -864,7 +864,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { } fn process_pat(&mut self, p: &'l ast::Pat) { - match p.node { + match p.kind { PatKind::Struct(ref _path, ref fields, _) => { // FIXME do something with _path? let hir_id = self.tcx.hir().node_to_hir_id(p.id); @@ -1007,7 +1007,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId) { self.process_macro_use(trait_item.span); let vis_span = trait_item.span.shrink_to_lo(); - match trait_item.node { + match trait_item.kind { ast::TraitItemKind::Const(ref ty, ref expr) => { self.process_assoc_const( trait_item.id, @@ -1078,7 +1078,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { fn process_impl_item(&mut self, impl_item: &'l ast::ImplItem, impl_id: DefId) { self.process_macro_use(impl_item.span); - match impl_item.node { + match impl_item.kind { ast::ImplItemKind::Const(ref ty, ref expr) => { self.process_assoc_const( impl_item.id, @@ -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![], @@ -1421,7 +1421,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> { fn visit_ty(&mut self, t: &'l ast::Ty) { self.process_macro_use(t.span); - match t.node { + match t.kind { ast::TyKind::Path(_, ref path) => { if generated_code(t.span) { return; @@ -1461,9 +1461,9 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> { } fn visit_expr(&mut self, ex: &'l ast::Expr) { - debug!("visit_expr {:?}", ex.node); + debug!("visit_expr {:?}", ex.kind); self.process_macro_use(ex.span); - match ex.node { + match ex.kind { ast::ExprKind::Struct(ref path, ref fields, ref base) => { let expr_hir_id = self.save_ctxt.tcx.hir().node_to_hir_id(ex.id); let hir_expr = self.save_ctxt.tcx.hir().expect_expr(expr_hir_id); @@ -1509,7 +1509,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> { } ast::ExprKind::ForLoop(ref pattern, ref subexpression, ref block, _) => { self.process_var_decl(pattern); - debug!("for loop, walk sub-expr: {:?}", subexpression.node); + debug!("for loop, walk sub-expr: {:?}", subexpression.kind); self.visit_expr(subexpression); visit::walk_block(self, block); } @@ -1570,7 +1570,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> { let hir_id = self.tcx.hir().node_to_hir_id(item.id); let access = access_from!(self.save_ctxt, item, hir_id); - match item.node { + match item.kind { ast::ForeignItemKind::Fn(ref decl, ref generics) => { if let Some(fn_data) = self.save_ctxt.get_extern_item_data(item) { down_cast_data!(fn_data, DefData, item.span); diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 7b1a6a9765b80..e3c898610cde0 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -130,7 +130,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option { let qualname = format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))); - match item.node { + match item.kind { ast::ForeignItemKind::Fn(ref decl, ref generics) => { filter!(self.span_utils, item.ident.span); @@ -177,7 +177,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { } pub fn get_item_data(&self, item: &ast::Item) -> Option { - 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))); @@ -301,7 +301,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { })) } ast::ItemKind::Impl(.., ref trait_ref, ref typ, ref impls) => { - if let ast::TyKind::Path(None, ref path) = typ.node { + if let ast::TyKind::Path(None, ref path) = typ.kind { // Common case impl for a struct or something basic. if generated_code(path.span) { return None; @@ -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)); @@ -518,7 +518,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { if ty.is_none() || ty.unwrap().kind == ty::Error { return None; } - match expr.node { + match expr.kind { ast::ExprKind::Field(ref sub_ex, ident) => { let sub_ex_hir_id = self.tcx.hir().node_to_hir_id(sub_ex.id); let hir_node = match self.tcx.hir().find(sub_ex_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 { @@ -629,37 +629,37 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { } Node::Expr(&hir::Expr { - node: hir::ExprKind::Struct(ref qpath, ..), + kind: hir::ExprKind::Struct(ref qpath, ..), .. }) => { self.tables.qpath_res(qpath, hir_id) } Node::Expr(&hir::Expr { - node: hir::ExprKind::Path(ref qpath), + kind: hir::ExprKind::Path(ref qpath), .. }) | Node::Pat(&hir::Pat { - node: hir::PatKind::Path(ref qpath), + kind: hir::PatKind::Path(ref qpath), .. }) | Node::Pat(&hir::Pat { - node: hir::PatKind::Struct(ref qpath, ..), + kind: hir::PatKind::Struct(ref qpath, ..), .. }) | Node::Pat(&hir::Pat { - node: hir::PatKind::TupleStruct(ref qpath, ..), + kind: hir::PatKind::TupleStruct(ref qpath, ..), .. }) | Node::Ty(&hir::Ty { - node: hir::TyKind::Path(ref qpath), + kind: hir::TyKind::Path(ref qpath), .. }) => { self.tables.qpath_res(qpath, hir_id) } Node::Binding(&hir::Pat { - node: hir::PatKind::Binding(_, canonical_id, ..), + kind: hir::PatKind::Binding(_, canonical_id, ..), .. }) => Res::Local(canonical_id), @@ -965,7 +965,7 @@ impl<'l> PathCollector<'l> { impl<'l> Visitor<'l> for PathCollector<'l> { fn visit_pat(&mut self, p: &'l ast::Pat) { - match p.node { + match p.kind { PatKind::Struct(ref path, ..) => { self.collected_paths.push((p.id, path)); } diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index b34506a4f1d37..203bd4d4167e2 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -160,7 +160,7 @@ fn text_sig(text: String) -> Signature { impl Sig for ast::Ty { fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let id = Some(self.id); - match self.node { + match self.kind { ast::TyKind::Slice(ref ty) => { let nested = ty.make(offset + 1, id, scx)?; let text = format!("[{}]", nested.text); @@ -324,7 +324,7 @@ impl Sig for ast::Item { fn make(&self, offset: usize, _parent_id: Option, 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 { @@ -765,7 +765,7 @@ impl Sig for ast::Variant { impl Sig for ast::ForeignItem { fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let id = Some(self.id); - match self.node { + match self.kind { ast::ForeignItemKind::Fn(ref decl, ref generics) => { let mut text = String::new(); text.push_str("fn "); diff --git a/src/librustc_traits/lowering/environment.rs b/src/librustc_traits/lowering/environment.rs index 759eced131981..a2fbf8128b5d1 100644 --- a/src/librustc_traits/lowering/environment.rs +++ b/src/librustc_traits/lowering/environment.rs @@ -195,24 +195,24 @@ crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> { }; let node_kind = match node { - Node::TraitItem(item) => match item.node { + Node::TraitItem(item) => match item.kind { TraitItemKind::Method(..) => NodeKind::Fn, _ => NodeKind::Other, } - Node::ImplItem(item) => match item.node { + Node::ImplItem(item) => match item.kind { ImplItemKind::Method(..) => NodeKind::Fn, _ => 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, _ => NodeKind::Other, } - Node::ForeignItem(item) => match item.node { + Node::ForeignItem(item) => match item.kind { ForeignItemKind::Fn(..) => NodeKind::Fn, _ => NodeKind::Other, } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 339045a4bad8e..6f1d854481a10 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -2075,11 +2075,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { /// internal notion of a type. pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> { debug!("ast_ty_to_ty(id={:?}, ast_ty={:?} ty_ty={:?})", - ast_ty.hir_id, ast_ty, ast_ty.node); + ast_ty.hir_id, ast_ty, ast_ty.kind); let tcx = self.tcx(); - let result_ty = match ast_ty.node { + let result_ty = match ast_ty.kind { hir::TyKind::Slice(ref ty) => { tcx.mk_slice(self.ast_ty_to_ty(&ty)) } @@ -2123,7 +2123,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { debug!("ast_ty_to_ty: qself={:?} segment={:?}", qself, segment); let ty = self.ast_ty_to_ty(qself); - let res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.node { + let res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.kind { path.res } else { Res::Err @@ -2175,13 +2175,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { pub fn const_param_def_id(&self, expr: &hir::Expr) -> Option { // Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments // currently have to be wrapped in curly brackets, so it's necessary to special-case. - let expr = match &expr.node { + let expr = match &expr.kind { ExprKind::Block(block, _) if block.stmts.is_empty() && block.expr.is_some() => block.expr.as_ref().unwrap(), _ => expr, }; - match &expr.node { + match &expr.kind { ExprKind::Path(hir::QPath::Resolved(_, path)) => match path.res { Res::Def(DefKind::ConstParam, did) => Some(did), _ => None, @@ -2270,7 +2270,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { expected_ty: Option>) -> Ty<'tcx> { - match ty.node { + match ty.kind { hir::TyKind::Infer if expected_ty.is_some() => { self.record_ty(ty.hir_id, expected_ty.unwrap(), ty.span); expected_ty.unwrap() diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 14a07c8c9c7e2..13b6b1b8aa08d 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } } else { - let arm_span = if let hir::ExprKind::Block(blk, _) = &arm.body.node { + let arm_span = if let hir::ExprKind::Block(blk, _) = &arm.body.kind { // Point at the block expr instead of the entire block blk.expr.as_ref().map(|e| e.span).unwrap_or(arm.body.span) } else { @@ -219,7 +219,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { coercion.coerce_forced_unit(self, &cause, &mut |err| { if let Some((span, msg)) = &ret_reason { err.span_label(*span, msg.as_str()); - } else if let ExprKind::Block(block, _) = &then_expr.node { + } else if let ExprKind::Block(block, _) = &then_expr.kind { if let Some(expr) = &block.expr { err.span_label(expr.span, "found here".to_string()); } @@ -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 { @@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let mut remove_semicolon = None; - let error_sp = if let ExprKind::Block(block, _) = &else_expr.node { + let error_sp = if let ExprKind::Block(block, _) = &else_expr.kind { if let Some(expr) = &block.expr { expr.span } else if let Some(stmt) = block.stmts.last() { @@ -345,7 +345,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; // Compute `Span` of `then` part of `if`-expression. - let then_sp = if let ExprKind::Block(block, _) = &then_expr.node { + let then_sp = if let ExprKind::Block(block, _) = &then_expr.kind { if let Some(expr) = &block.expr { expr.span } else if let Some(stmt) = block.stmts.last() { diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index e1f239d3d08dd..4d8ec6fb0b83d 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -247,7 +247,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let hir_id = self.tcx.hir().get_parent_node(hir_id); let parent_node = self.tcx.hir().get(hir_id); if let ( - hir::Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, _, _, sp, ..), .. }), + hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, _, _, sp, ..), .. }), hir::ExprKind::Block(..), ) = (parent_node, callee_node) { let start = sp.shrink_to_lo(); @@ -278,13 +278,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut unit_variant = None; if let &ty::Adt(adt_def, ..) = t { if adt_def.is_enum() { - if let hir::ExprKind::Call(ref expr, _) = call_expr.node { + if let hir::ExprKind::Call(ref expr, _) = call_expr.kind { unit_variant = Some(self.tcx.hir().hir_to_pretty_string(expr.hir_id)) } } } - if let hir::ExprKind::Call(ref callee, _) = call_expr.node { + if let hir::ExprKind::Call(ref callee, _) = call_expr.kind { let mut err = type_error_struct!( self.tcx.sess, callee.span, @@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.identify_bad_closure_def_and_call( &mut err, call_expr.hir_id, - &callee.node, + &callee.kind, callee.span, ); @@ -318,7 +318,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let mut inner_callee_path = None; - let def = match callee.node { + let def = match callee.kind { hir::ExprKind::Path(ref qpath) => { self.tables.borrow().qpath_res(qpath, callee.hir_id) } @@ -337,7 +337,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Applicability::MaybeIncorrect, ); } - if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.node { + if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.kind { inner_callee_path = Some(inner_qpath); self.tables .borrow() @@ -375,8 +375,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.emit(); } else { bug!( - "call_expr.node should be an ExprKind::Call, got {:?}", - call_expr.node + "call_expr.kind should be an ExprKind::Call, got {:?}", + call_expr.kind ); } diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 51adf501b4db8..6818d5f521d00 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -425,7 +425,7 @@ fn extract_spans_for_error_reporting<'a, 'tcx>( let impl_m_hir_id = tcx.hir().as_local_hir_id(impl_m.def_id).unwrap(); let (impl_m_output, impl_m_iter) = match tcx.hir() .expect_impl_item(impl_m_hir_id) - .node { + .kind { ImplItemKind::Method(ref impl_m_sig, _) => { (&impl_m_sig.decl.output, impl_m_sig.decl.inputs.iter()) } @@ -437,7 +437,7 @@ fn extract_spans_for_error_reporting<'a, 'tcx>( if let Some(trait_m_hir_id) = tcx.hir().as_local_hir_id(trait_m.def_id) { let trait_m_iter = match tcx.hir() .expect_trait_item(trait_m_hir_id) - .node { + .kind { TraitItemKind::Method(ref trait_m_sig, _) => { trait_m_sig.decl.inputs.iter() } @@ -445,7 +445,7 @@ fn extract_spans_for_error_reporting<'a, 'tcx>( }; impl_m_iter.zip(trait_m_iter).find(|&(ref impl_arg, ref trait_arg)| { - match (&impl_arg.node, &trait_arg.node) { + match (&impl_arg.kind, &trait_arg.kind) { (&hir::TyKind::Rptr(_, ref impl_mt), &hir::TyKind::Rptr(_, ref trait_mt)) | (&hir::TyKind::Ptr(ref impl_mt), &hir::TyKind::Ptr(ref trait_mt)) => { impl_mt.mutbl != trait_mt.mutbl @@ -463,7 +463,7 @@ fn extract_spans_for_error_reporting<'a, 'tcx>( TypeError::Sorts(ExpectedFound { .. }) => { if let Some(trait_m_hir_id) = tcx.hir().as_local_hir_id(trait_m.def_id) { let (trait_m_output, trait_m_iter) = - match tcx.hir().expect_trait_item(trait_m_hir_id).node { + match tcx.hir().expect_trait_item(trait_m_hir_id).kind { TraitItemKind::Method(ref trait_m_sig, _) => { (&trait_m_sig.decl.output, trait_m_sig.decl.inputs.iter()) } @@ -715,7 +715,7 @@ fn compare_number_of_method_arguments<'tcx>( if trait_number_args != impl_number_args { let trait_m_hir_id = tcx.hir().as_local_hir_id(trait_m.def_id); let trait_span = if let Some(trait_id) = trait_m_hir_id { - match tcx.hir().expect_trait_item(trait_id).node { + match tcx.hir().expect_trait_item(trait_id).kind { TraitItemKind::Method(ref trait_m_sig, _) => { let pos = if trait_number_args > 0 { trait_number_args - 1 @@ -740,7 +740,7 @@ fn compare_number_of_method_arguments<'tcx>( trait_item_span }; let impl_m_hir_id = tcx.hir().as_local_hir_id(impl_m.def_id).unwrap(); - let impl_span = match tcx.hir().expect_impl_item(impl_m_hir_id).node { + let impl_span = match tcx.hir().expect_impl_item(impl_m_hir_id).kind { ImplItemKind::Method(ref impl_m_sig, _) => { let pos = if impl_number_args > 0 { impl_number_args - 1 @@ -883,7 +883,7 @@ fn compare_synthetic_generics<'tcx>( (|| { let impl_m = tcx.hir().as_local_hir_id(impl_m.def_id)?; let impl_m = tcx.hir().impl_item(hir::ImplItemId { hir_id: impl_m }); - let input_tys = match impl_m.node { + let input_tys = match impl_m.kind { hir::ImplItemKind::Method(ref sig, _) => &sig.decl.inputs, _ => unreachable!(), }; @@ -892,7 +892,7 @@ fn compare_synthetic_generics<'tcx>( fn visit_ty(&mut self, ty: &'v hir::Ty) { hir::intravisit::walk_ty(self, ty); if let hir::TyKind::Path( - hir::QPath::Resolved(None, ref path)) = ty.node + hir::QPath::Resolved(None, ref path)) = ty.kind { if let Res::Def(DefKind::TyParam, def_id) = path.res { if def_id == self.1 { @@ -1014,7 +1014,7 @@ pub fn compare_const_impl<'tcx>( trait_ty); // Locate the Span containing just the type of the offending impl - match tcx.hir().expect_impl_item(impl_c_hir_id).node { + match tcx.hir().expect_impl_item(impl_c_hir_id).kind { ImplItemKind::Const(ref ty, _) => cause.span = ty.span, _ => bug!("{:?} is not a impl const", impl_c), } @@ -1029,7 +1029,7 @@ pub fn compare_const_impl<'tcx>( let trait_c_hir_id = tcx.hir().as_local_hir_id(trait_c.def_id); let trait_c_span = trait_c_hir_id.map(|trait_c_hir_id| { // Add a label to the Span containing just the type of the const - match tcx.hir().expect_trait_item(trait_c_hir_id).node { + match tcx.hir().expect_trait_item(trait_c_hir_id).kind { TraitItemKind::Const(ref ty, _) => ty.span, _ => bug!("{:?} is not a trait const", trait_c), } diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 6c94f833196fb..2ea0afb179356 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Returns whether the expected type is `bool` and the expression is `x = y`. pub fn is_assign_to_bool(&self, expr: &hir::Expr, expected: Ty<'tcx>) -> bool { - if let hir::ExprKind::Assign(..) = expr.node { + if let hir::ExprKind::Assign(..) = expr.kind { return expected == self.tcx.types.bool; } false @@ -236,7 +236,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, expr: &hir::Expr, ) -> Option<(Span, &'static str, String)> { - let path = match expr.node { + let path = match expr.kind { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => path, _ => return None }; @@ -255,7 +255,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let param_parent = self.tcx.hir().get_parent_node(*param_hir_id); let (expr_hir_id, closure_fn_decl) = match self.tcx.hir().find(param_parent) { Some(Node::Expr( - hir::Expr { hir_id, node: hir::ExprKind::Closure(_, decl, ..), .. } + hir::Expr { hir_id, kind: hir::ExprKind::Closure(_, decl, ..), .. } )) => (hir_id, decl), _ => return None }; @@ -265,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let closure_params_len = closure_fn_decl.inputs.len(); let (method_path, method_span, method_expr) = match (hir, closure_params_len) { (Some(Node::Expr( - hir::Expr { node: hir::ExprKind::MethodCall(path, span, expr), .. } + hir::Expr { kind: hir::ExprKind::MethodCall(path, span, expr), .. } )), 1) => (path, span, expr), _ => return None }; @@ -298,7 +298,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(parent) = self.tcx.hir().find(parent_id) { // Account for fields if let Node::Expr(hir::Expr { - node: hir::ExprKind::Struct(_, fields, ..), .. + kind: hir::ExprKind::Struct(_, fields, ..), .. }) = parent { if let Ok(src) = cm.span_to_snippet(sp) { for field in fields { @@ -351,11 +351,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // and make a good suggestion, so don't bother. let is_macro = sp.from_expansion(); - match (&expr.node, &expected.kind, &checked_ty.kind) { + match (&expr.kind, &expected.kind, &checked_ty.kind) { (_, &ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (&exp.kind, &check.kind) { (&ty::Str, &ty::Array(arr, _)) | (&ty::Str, &ty::Slice(arr)) if arr == self.tcx.types.u8 => { - if let hir::ExprKind::Lit(_) = expr.node { + if let hir::ExprKind::Lit(_) = expr.kind { if let Ok(src) = cm.span_to_snippet(sp) { if src.starts_with("b\"") { return Some((sp, @@ -367,7 +367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }, (&ty::Array(arr, _), &ty::Str) | (&ty::Slice(arr), &ty::Str) if arr == self.tcx.types.u8 => { - if let hir::ExprKind::Lit(_) = expr.node { + if let hir::ExprKind::Lit(_) = expr.kind { if let Ok(src) = cm.span_to_snippet(sp) { if src.starts_with("\"") { return Some((sp, @@ -398,7 +398,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if self.can_coerce(ref_ty, expected) { let mut sugg_sp = sp; - if let hir::ExprKind::MethodCall(segment, _sp, args) = &expr.node { + if let hir::ExprKind::MethodCall(segment, _sp, args) = &expr.kind { let clone_trait = self.tcx.lang_items().clone_trait().unwrap(); if let ([arg], Some(true), "clone") = ( &args[..], @@ -414,7 +414,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } if let Ok(src) = cm.span_to_snippet(sugg_sp) { - let needs_parens = match expr.node { + let needs_parens = match expr.kind { // parenthesize if needed (Issue #46756) hir::ExprKind::Cast(_, _) | hir::ExprKind::Binary(_, _, _) => true, @@ -437,7 +437,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { String::new() }; if let Some(hir::Node::Expr(hir::Expr { - node: hir::ExprKind::Assign(left_expr, _), + kind: hir::ExprKind::Assign(left_expr, _), .. })) = self.tcx.hir().find( self.tcx.hir().get_parent_node(expr.hir_id), @@ -571,7 +571,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut prefix = String::new(); if let Some(hir::Node::Expr(hir::Expr { - node: hir::ExprKind::Struct(_, fields, _), + kind: hir::ExprKind::Struct(_, fields, _), .. })) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.hir_id)) { // `expr` is a literal field for a struct, only suggest if appropriate @@ -587,16 +587,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return false; } } - if let hir::ExprKind::Call(path, args) = &expr.node { + if let hir::ExprKind::Call(path, args) = &expr.kind { if let ( hir::ExprKind::Path(hir::QPath::TypeRelative(base_ty, path_segment)), 1, - ) = (&path.node, args.len()) { + ) = (&path.kind, args.len()) { // `expr` is a conversion like `u32::from(val)`, do not suggest anything (#63697). if let ( hir::TyKind::Path(hir::QPath::Resolved(None, base_ty_path)), sym::from, - ) = (&base_ty.node, path_segment.ident.name) { + ) = (&base_ty.kind, path_segment.ident.name) { if let Some(ident) = &base_ty_path.segments.iter().map(|s| s.ident).next() { match ident.name { sym::i128 | sym::i64 | sym::i32 | sym::i16 | sym::i8 | @@ -663,7 +663,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if needs_paren { ")" } else { "" }, ); let literal_is_ty_suffixed = |expr: &hir::Expr| { - if let hir::ExprKind::Lit(lit) = &expr.node { + if let hir::ExprKind::Lit(lit) = &expr.kind { lit.node.is_suffixed() } else { false diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index 97fcfd7151a1c..58f41ca4f88f9 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -84,7 +84,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if let Some(mut err) = self.demand_suptype_diag(expr.span, expected_ty, ty) { - let expr = match &expr.node { + let expr = match &expr.kind { ExprKind::DropTemps(expr) => expr, _ => expr, }; @@ -159,7 +159,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let ty = self.check_expr_kind(expr, expected, needs); // Warn for non-block expressions with diverging children. - match expr.node { + match expr.kind { ExprKind::Block(..) | ExprKind::Loop(..) | ExprKind::Match(..) => {}, ExprKind::Call(ref callee, _) => self.warn_if_unreachable(expr.hir_id, callee.span, "call"), @@ -202,7 +202,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let tcx = self.tcx; - match expr.node { + match expr.kind { ExprKind::Box(ref subexpr) => { self.check_expr_box(subexpr, expected) } @@ -602,7 +602,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // ... except when we try to 'break rust;'. // ICE this expression in particular (see #43162). - if let ExprKind::Path(QPath::Resolved(_, ref path)) = e.node { + if let ExprKind::Path(QPath::Resolved(_, ref path)) = e.kind { if path.segments.len() == 1 && path.segments[0].ident.name == sym::rust { fatally_break_rust(self.tcx.sess); @@ -1604,7 +1604,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut needs_note = true; // If the index is an integer, we can show the actual // fixed expression: - if let ExprKind::Lit(ref lit) = idx.node { + if let ExprKind::Lit(ref lit) = idx.kind { if let ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) = lit.node { let snip = self.tcx.sess.source_map().span_to_snippet(base.span); if let Ok(snip) = snip { diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index a7c307fdf894f..d2d3854d2758c 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -167,7 +167,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { self.expr_count += 1; - if let PatKind::Binding(..) = pat.node { + if let PatKind::Binding(..) = pat.kind { let scope = self.region_scope_tree.var_scope(pat.hir_id.local_id); let ty = self.fcx.tables.borrow().pat_ty(pat); self.record(ty, Some(scope), None, pat.span); diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index dfbf8bcd0f60f..d06d51dc81931 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -24,7 +24,7 @@ fn equate_intrinsic_type<'tcx>( ) { let def_id = tcx.hir().local_def_id(it.hir_id); - match it.node { + match it.kind { hir::ForeignItemKind::Fn(..) => {} _ => { struct_span_err!(tcx.sess, it.span, E0622, @@ -37,7 +37,7 @@ fn equate_intrinsic_type<'tcx>( let i_n_tps = tcx.generics_of(def_id).own_counts().types; if i_n_tps != n_tps { - let span = match it.node { + let span = match it.kind { hir::ForeignItemKind::Fn(_, _, ref generics) => generics.span, _ => bug!() }; diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 5d4893ae75483..9baf06be3f6b5 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -436,7 +436,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { let mut exprs = vec![self.self_expr]; loop { - match exprs.last().unwrap().node { + match exprs.last().unwrap().kind { hir::ExprKind::Field(ref expr, _) | hir::ExprKind::Index(ref expr, _) | hir::ExprKind::Unary(hir::UnDeref, ref expr) => exprs.push(&expr), @@ -480,7 +480,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self.tables.borrow_mut().adjustments_mut().insert(expr.hir_id, adjustments); } - match expr.node { + match expr.kind { hir::ExprKind::Index(ref base_expr, ref index_expr) => { let index_expr_ty = self.node_ty(index_expr.hir_id); self.convert_place_op_to_mutable( diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 408532d1d1ee8..2d4d2e32f23db 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -258,7 +258,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { "f32" }; - match expr.node { + match expr.kind { ExprKind::Lit(ref lit) => { // numeric literal let snippet = tcx.sess.source_map().span_to_snippet(lit.span) @@ -446,7 +446,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Ok(expr_string) = tcx.sess.source_map().span_to_snippet(expr.span) { report_function!(expr.span, expr_string); } else if let ExprKind::Path(QPath::Resolved(_, ref path)) = - expr.node + expr.kind { if let Some(segment) = path.segments.last() { report_function!(expr.span, segment.ident); @@ -895,7 +895,7 @@ fn compute_all_traits(tcx: TyCtxt<'_>) -> Vec { 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. diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c1eb65ee956ae..9f2c991fdd236 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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)), @@ -803,7 +803,7 @@ fn primary_body_of( } } Node::TraitItem(item) => { - match item.node { + match item.kind { hir::TraitItemKind::Const(ref ty, Some(body)) => Some((body, Some(ty), None, None)), hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => @@ -813,7 +813,7 @@ fn primary_body_of( } } Node::ImplItem(item) => { - match item.node { + match item.kind { hir::ImplItemKind::Const(ref ty, body) => Some((body, Some(ty), None, None)), hir::ImplItemKind::Method(ref sig, body) => @@ -886,7 +886,7 @@ fn typeck_tables_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::TypeckTables<'_> { fcx } else { let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id); - let expected_type = body_ty.and_then(|ty| match ty.node { + let expected_type = body_ty.and_then(|ty| match ty.kind { hir::TyKind::Infer => Some(AstConv::ast_ty_to_ty(&fcx, ty)), _ => None }).unwrap_or_else(|| tcx.type_of(def_id)); @@ -1032,7 +1032,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { // Add pattern bindings. fn visit_pat(&mut self, p: &'tcx hir::Pat) { - if let PatKind::Binding(_, _, ident, _) = p.node { + if let PatKind::Binding(_, _, ident, _) = p.kind { let var_ty = self.assign(p.span, p.hir_id, None); if !self.fcx.tcx.features().unsized_locals { @@ -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); @@ -1520,7 +1520,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item) { for item in items.iter() { let item = tcx.hir().trait_item(item.id); - if let hir::TraitItemKind::Method(sig, _) = &item.node { + if let hir::TraitItemKind::Method(sig, _) = &item.kind { let abi = sig.header.abi; fn_maybe_err(tcx, item.ident.span, abi); } @@ -1588,7 +1588,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item) { ).emit(); } - if let hir::ForeignItemKind::Fn(ref fn_decl, _, _) = item.node { + if let hir::ForeignItemKind::Fn(ref fn_decl, _, _) = item.kind { require_c_abi_if_c_variadic(tcx, fn_decl, m.abi, item.span); } } @@ -1681,7 +1681,7 @@ fn check_specialization_validity<'tcx>( ) { let ancestors = trait_def.ancestors(tcx, impl_id); - let kind = match impl_item.node { + let kind = match impl_item.kind { hir::ImplItemKind::Const(..) => ty::AssocKind::Const, hir::ImplItemKind::Method(..) => ty::AssocKind::Method, hir::ImplItemKind::OpaqueTy(..) => ty::AssocKind::OpaqueTy, @@ -1725,7 +1725,7 @@ fn check_impl_items_against_trait<'tcx>( let ty_impl_item = tcx.associated_item( tcx.hir().local_def_id(impl_item.hir_id)); let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id) - .find(|ac| Namespace::from(&impl_item.node) == Namespace::from(ac.kind) && + .find(|ac| Namespace::from(&impl_item.kind) == Namespace::from(ac.kind) && tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id)) .or_else(|| { // Not compatible, but needed for the error message @@ -1735,7 +1735,7 @@ fn check_impl_items_against_trait<'tcx>( // Check that impl definition matches trait definition if let Some(ty_trait_item) = ty_trait_item { - match impl_item.node { + match impl_item.kind { hir::ImplItemKind::Const(..) => { // Find associated const definition. if ty_trait_item.kind == ty::AssocKind::Const { @@ -3376,7 +3376,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.warn_if_unreachable(arg.hir_id, arg.span, "expression"); } - let is_closure = match arg.node { + let is_closure = match arg.kind { ExprKind::Closure(..) => true, _ => false }; @@ -3495,8 +3495,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { errors: &mut Vec>, call_expr: &'tcx hir::Expr, ) { - if let hir::ExprKind::Call(path, _) = &call_expr.node { - if let hir::ExprKind::Path(qpath) = &path.node { + if let hir::ExprKind::Call(path, _) = &call_expr.kind { + if let hir::ExprKind::Path(qpath) = &path.kind { if let hir::QPath::Resolved(_, path) = &qpath { for error in errors { if let ty::Predicate::Trait(predicate) = error.obligation.predicate { @@ -3509,7 +3509,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let hir::GenericArg::Type(hir_ty) = &arg { if let hir::TyKind::Path( hir::QPath::TypeRelative(..), - ) = &hir_ty.node { + ) = &hir_ty.kind { // Avoid ICE with associated types. As this is best // effort only, it's ok to ignore the case. It // would trigger in `is_send::();` @@ -3722,7 +3722,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { QPath::TypeRelative(ref qself, ref segment) => { let ty = self.to_ty(qself); - let res = if let hir::TyKind::Path(QPath::Resolved(_, ref path)) = qself.node { + let res = if let hir::TyKind::Path(QPath::Resolved(_, ref path)) = qself.kind { path.res } else { Res::Err @@ -3860,7 +3860,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn check_stmt(&self, stmt: &'tcx hir::Stmt) { // Don't do all the complex logic below for `DeclItem`. - match stmt.node { + match stmt.kind { hir::StmtKind::Item(..) => return, hir::StmtKind::Local(..) | hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {} } @@ -3873,7 +3873,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.diverges.set(Diverges::Maybe); self.has_errors.set(false); - match stmt.node { + match stmt.kind { hir::StmtKind::Local(ref l) => { self.check_decl_local(&l); } @@ -3912,7 +3912,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// // ^^^^ point at this instead of the whole `if` expression /// ``` fn get_expr_coercion_span(&self, expr: &hir::Expr) -> syntax_pos::Span { - if let hir::ExprKind::Match(_, arms, _) = &expr.node { + if let hir::ExprKind::Match(_, arms, _) = &expr.kind { let arm_spans: Vec = arms.iter().filter_map(|arm| { self.in_progress_tables .and_then(|tables| tables.borrow().node_type_opt(arm.body.hir_id)) @@ -3920,7 +3920,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if arm_ty.is_never() { None } else { - Some(match &arm.body.node { + Some(match &arm.body.kind { // Point at the tail expression when possible. hir::ExprKind::Block(block, _) => block.expr .as_ref() @@ -4069,13 +4069,13 @@ 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 { - node: hir::ImplItemKind::Method(_, body_id), .. + kind: hir::ImplItemKind::Method(_, body_id), .. }) => { let body = self.tcx.hir().body(body_id); - if let ExprKind::Block(block, _) = &body.value.node { + if let ExprKind::Block(block, _) = &body.value.kind { return Some(block.span); } } @@ -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, @@ -4102,12 +4102,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Some((decl, ident, ident.name != sym::main)) } Node::TraitItem(&hir::TraitItem { - ident, node: hir::TraitItemKind::Method(hir::MethodSig { + ident, kind: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, ..), .. }) => Some((decl, ident, true)), Node::ImplItem(&hir::ImplItem { - ident, node: hir::ImplItemKind::Method(hir::MethodSig { + ident, kind: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, ..), .. }) => Some((decl, ident, false)), @@ -4192,27 +4192,27 @@ 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 { - node: hir::ImplItemKind::Method(_, body_id), + kind: hir::ImplItemKind::Method(_, body_id), .. })) | Some(Node::TraitItem(hir::TraitItem { - node: hir::TraitItemKind::Method(.., hir::TraitMethod::Provided(body_id)), + kind: hir::TraitItemKind::Method(.., hir::TraitMethod::Provided(body_id)), .. })) => { let body = hir.body(*body_id); sugg_call = body.params.iter() - .map(|param| match ¶m.pat.node { + .map(|param| match ¶m.pat.kind { hir::PatKind::Binding(_, _, ident, None) if ident.name != kw::SelfLower => ident.to_string(), _ => "_".to_string(), }).collect::>().join(", "); } Some(Node::Expr(hir::Expr { - node: ExprKind::Closure(_, _, body_id, closure_span, _), + kind: ExprKind::Closure(_, _, body_id, closure_span, _), span: full_closure_span, .. })) => { @@ -4223,7 +4223,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { msg = "call this closure"; let body = hir.body(*body_id); sugg_call = body.params.iter() - .map(|param| match ¶m.pat.node { + .map(|param| match ¶m.pat.kind { hir::PatKind::Binding(_, _, ident, None) if ident.name != kw::SelfLower => ident.to_string(), _ => "_".to_string(), @@ -4242,11 +4242,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } Some(Node::ForeignItem(hir::ForeignItem { - node: hir::ForeignItemKind::Fn(_, idents, _), + kind: hir::ForeignItemKind::Fn(_, idents, _), .. })) | Some(Node::TraitItem(hir::TraitItem { - node: hir::TraitItemKind::Method(.., hir::TraitMethod::Required(idents)), + kind: hir::TraitItemKind::Method(.., hir::TraitMethod::Required(idents)), .. })) => sugg_call = idents.iter() .map(|ident| if ident.name != kw::SelfLower { @@ -4388,7 +4388,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if expected.is_unit() { // `BlockTailExpression` only relevant if the tail expr would be // useful on its own. - match expression.node { + match expression.kind { ExprKind::Call(..) | ExprKind::MethodCall(..) | ExprKind::Loop(..) | @@ -4450,7 +4450,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (&hir::FunctionRetTy::Return(ref ty), _, _, _) => { // Only point to return type if the expected type is the return type, as if they // are not, the expectation must have been caused by something else. - debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.node); + debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.kind); let sp = ty.span; let ty = AstConv::ast_ty_to_ty(self, ty); debug!("suggest_missing_return_type: return type {:?}", ty); @@ -4560,7 +4560,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Be helpful when the user wrote `{... expr;}` and // taking the `;` off is enough to fix the error. let last_stmt = blk.stmts.last()?; - let last_expr = match last_stmt.node { + let last_expr = match last_stmt.kind { hir::StmtKind::Semi(ref e) => e, _ => return None, }; @@ -4893,7 +4893,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Node::Expr(expr) = self.tcx.hir().get( self.tcx.hir().get_parent_node(hir_id)) { - if let ExprKind::Call(ref callee, ..) = expr.node { + if let ExprKind::Call(ref callee, ..) = expr.kind { if callee.hir_id == hir_id { return } @@ -4968,7 +4968,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { while let hir::Node::Expr(parent_expr) = self.tcx.hir().get(self.tcx.hir().get_parent_node(expr_id)) { - match &parent_expr.node { + match &parent_expr.kind { hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => { if lhs.hir_id == expr_id { contained_in_place = true; diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index b20b5bb8dc3a2..53ee0777c7c1d 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -59,14 +59,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { debug!("check_pat(pat={:?},expected={:?},def_bm={:?})", pat, expected, def_bm); - let path_resolution = match &pat.node { + let path_resolution = match &pat.kind { PatKind::Path(qpath) => Some(self.resolve_ty_and_res_ufcs(qpath, pat.hir_id, pat.span)), _ => None, }; let is_nrp = self.is_non_ref_pat(pat, path_resolution.map(|(res, ..)| res)); let (expected, def_bm) = self.calc_default_binding_mode(pat, expected, def_bm, is_nrp); - let ty = match &pat.node { + let ty = match &pat.kind { PatKind::Wild => expected, PatKind::Lit(lt) => self.check_pat_lit(pat.span, lt, expected, discrim_span), PatKind::Range(begin, end, _) => { @@ -193,7 +193,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // ``` // // See issue #46688. - let def_bm = match pat.node { + let def_bm = match pat.kind { PatKind::Ref(..) => ty::BindByValue(hir::MutImmutable), _ => def_bm, }; @@ -204,7 +204,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Is the pattern a "non reference pattern"? /// When the pattern is a path pattern, `opt_path_res` must be `Some(res)`. fn is_non_ref_pat(&self, pat: &'tcx Pat, opt_path_res: Option) -> bool { - match pat.node { + match pat.kind { PatKind::Struct(..) | PatKind::TupleStruct(..) | PatKind::Tuple(..) | @@ -306,7 +306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Byte string patterns behave the same way as array patterns // They can denote both statically and dynamically-sized byte arrays. let mut pat_ty = ty; - if let hir::ExprKind::Lit(ref lt) = lt.node { + if let hir::ExprKind::Lit(ref lt) = lt.kind { if let ast::LitKind::ByteStr(_) = lt.node { let expected_ty = self.structurally_resolved_type(span, expected); if let ty::Ref(_, r_ty, _) = expected_ty.kind { @@ -472,7 +472,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Ty<'tcx>, ) { let tcx = self.tcx; - if let PatKind::Binding(..) = inner.node { + if let PatKind::Binding(..) = inner.kind { let binding_parent_id = tcx.hir().get_parent_node(pat.hir_id); let binding_parent = tcx.hir().get(binding_parent_id); debug!("inner {:?} pat {:?} parent {:?}", inner, pat, binding_parent); @@ -505,7 +505,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } pub fn check_dereferencable(&self, span: Span, expected: Ty<'tcx>, inner: &Pat) -> bool { - if let PatKind::Binding(..) = inner.node { + if let PatKind::Binding(..) = inner.kind { if let Some(mt) = self.shallow_resolve(expected).builtin_deref(true) { if let ty::Dynamic(..) = mt.ty.kind { // This is "x = SomeTrait" being reduced from @@ -617,7 +617,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { res.descr(), hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false))); let mut err = struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg); - match (res, &pat.node) { + match (res, &pat.kind) { (Res::Def(DefKind::Fn, _), _) | (Res::Def(DefKind::Method, _), _) => { err.span_label(pat.span, "`fn` calls are not allowed in patterns"); err.help("for more information, visit \ diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 23280542c2b19..90407780a302d 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -526,7 +526,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> { // arguments for its type parameters are well-formed, and all the regions // provided as arguments outlive the call. if is_method_call { - let origin = match expr.node { + let origin = match expr.kind { hir::ExprKind::MethodCall(..) => infer::ParameterOrigin::MethodCall, hir::ExprKind::Unary(op, _) if op == hir::UnDeref => { infer::ParameterOrigin::OverloadedDeref @@ -557,7 +557,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> { "regionck::visit_expr(e={:?}, repeating_scope={:?}) - visiting subexprs", expr, self.repeating_scope ); - match expr.node { + match expr.kind { hir::ExprKind::Path(_) => { let substs = self.tables.borrow().node_substs(expr.hir_id); let origin = infer::ParameterOrigin::Path; @@ -1097,7 +1097,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> { ignore_err!(self.with_mc(|mc| { mc.cat_pattern(discr_cmt, root_pat, |sub_cmt, sub_pat| { // `ref x` pattern - if let PatKind::Binding(..) = sub_pat.node { + if let PatKind::Binding(..) = sub_pat.kind { if let Some(&bm) = mc.tables.pat_binding_modes().get(sub_pat.hir_id) { if let ty::BindByReference(mutbl) = bm { self.link_region_from_node_type( diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index d57fec9947db1..71ea938a8039b 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -64,7 +64,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InferBorrowKindVisitor<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.node { + if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.kind { let body = self.fcx.tcx.hir().body(body_id); self.visit_body(body); self.fcx diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 5b0f327204645..f4ba9fc03d3d0 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -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: // @@ -128,7 +128,7 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: DefId) { check_item_type(tcx, item.hir_id, ty.span, false); } hir::ItemKind::ForeignMod(ref module) => for it in module.items.iter() { - if let hir::ForeignItemKind::Static(ref ty, ..) = it.node { + if let hir::ForeignItemKind::Static(ref ty, ..) = it.kind { check_item_type(tcx, it.hir_id, ty.span, true); } }, @@ -167,7 +167,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: DefId) { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); let trait_item = tcx.hir().expect_trait_item(hir_id); - let method_sig = match trait_item.node { + let method_sig = match trait_item.kind { hir::TraitItemKind::Method(ref sig, _) => Some(sig), _ => None }; @@ -178,7 +178,7 @@ pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: DefId) { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); let impl_item = tcx.hir().expect_impl_item(hir_id); - let method_sig = match impl_item.node { + let method_sig = match impl_item.kind { hir::ImplItemKind::Method(ref sig, _) => Some(sig), _ => None }; @@ -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!(), }, diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index f3ee64e9d1368..de78c1cdfaba3 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -134,7 +134,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // we observe that something like `a+b` is (known to be) // operating on scalars, we clear the overload. fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) { - match e.node { + match e.kind { hir::ExprKind::Unary(hir::UnNeg, ref inner) | hir::ExprKind::Unary(hir::UnNot, ref inner) => { let inner_ty = self.fcx.node_ty(inner.hir_id); @@ -159,7 +159,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { tables.type_dependent_defs_mut().remove(e.hir_id); tables.node_substs_mut().remove(e.hir_id); - match e.node { + match e.kind { hir::ExprKind::Binary(..) => { if !op.node.is_by_value() { let mut adjustments = tables.adjustments_mut(); @@ -186,7 +186,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // to use builtin indexing because the index type is known to be // usize-ish fn fix_index_builtin_expr(&mut self, e: &hir::Expr) { - if let hir::ExprKind::Index(ref base, ref index) = e.node { + if let hir::ExprKind::Index(ref base, ref index) = e.kind { let mut tables = self.fcx.tables.borrow_mut(); // All valid indexing looks like this; might encounter non-valid indexes at this point @@ -241,7 +241,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> { self.visit_node_id(e.span, e.hir_id); - match e.node { + match e.kind { hir::ExprKind::Closure(_, _, body, _, _) => { let body = self.fcx.tcx.hir().body(body); for param in &body.params { @@ -270,7 +270,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> { } fn visit_pat(&mut self, p: &'tcx hir::Pat) { - match p.node { + match p.kind { hir::PatKind::Binding(..) => { if let Some(&bm) = self.fcx.tables.borrow().pat_binding_modes().get(p.hir_id) { self.tables.pat_binding_modes_mut().insert(p.hir_id, bm); diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index ffc66ec16de13..7af1a342ff36e 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -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 { diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index 9054c2b80102a..64bd144dfa226 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -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) diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index d2651317da948..90cedb455e3dd 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -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 }; diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index 04b59a63e1d8a..0aae8fbe13178 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -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(..) | diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 8969bf894e0f6..667fa50a7cfa4 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -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(); diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index 07fbfddd96e43..b7cc6feee4453 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -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); } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 82d55e0df599b..3ac3ce2a02c2e 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -135,7 +135,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr) { - if let hir::ExprKind::Closure(..) = expr.node { + if let hir::ExprKind::Closure(..) = expr.kind { let def_id = self.tcx.hir().local_def_id(expr.hir_id); self.tcx.generics_of(def_id); self.tcx.type_of(def_id); @@ -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) @@ -312,7 +312,7 @@ fn type_param_predicates( } } - Node::ForeignItem(item) => match item.node { + Node::ForeignItem(item) => match item.kind { ForeignItemKind::Fn(_, _, ref generics) => generics, _ => return result, }, @@ -387,7 +387,7 @@ impl ItemCtxt<'tcx> { /// `ast_ty_to_ty`, because we want to avoid triggering an all-out /// conversion of the type to avoid inducing unnecessary cycles. fn is_param(tcx: TyCtxt<'_>, ast_ty: &hir::Ty, param_id: hir::HirId) -> bool { - if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.node { + if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.kind { match path.res { Res::SelfTy(Some(def_id), None) | Res::Def(DefKind::TyParam, def_id) => { def_id == tcx.hir().local_def_id(param_id) @@ -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(..) @@ -415,7 +415,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::ForeignItemKind::Fn(..) = item.node { + if let hir::ForeignItemKind::Fn(..) = item.kind { tcx.fn_sig(def_id); } } @@ -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); } } @@ -486,12 +486,12 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) { let def_id = tcx.hir().local_def_id(trait_item.hir_id); tcx.generics_of(def_id); - match trait_item.node { + match trait_item.kind { hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(_, Some(_)) | hir::TraitItemKind::Method(..) => { tcx.type_of(def_id); - if let hir::TraitItemKind::Method(..) = trait_item.node { + if let hir::TraitItemKind::Method(..) = trait_item.kind { tcx.fn_sig(def_id); } } @@ -507,7 +507,7 @@ fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::HirId) { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); - if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item(impl_item_id).node { + if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item(impl_item_id).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"), @@ -796,7 +796,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option { self.outer_index.shift_in(1); intravisit::walk_ty(self, ty); @@ -860,25 +860,25 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option match item.node { + Node::TraitItem(item) => match item.kind { hir::TraitItemKind::Method(ref sig, _) => { has_late_bound_regions(tcx, &item.generics, &sig.decl) } _ => None, }, - Node::ImplItem(item) => match item.node { + Node::ImplItem(item) => match item.kind { hir::ImplItemKind::Method(ref sig, _) => { has_late_bound_regions(tcx, &item.generics, &sig.decl) } _ => None, }, - Node::ForeignItem(item) => match item.node { + Node::ForeignItem(item) => match item.kind { hir::ForeignItemKind::Fn(ref fn_decl, _, ref generics) => { has_late_bound_regions(tcx, generics, fn_decl) } _ => 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) } @@ -915,10 +915,10 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { } } Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(..), + 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 } @@ -977,7 +977,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { } } - Node::ForeignItem(item) => match item.node { + Node::ForeignItem(item) => match item.kind { ForeignItemKind::Static(..) => &no_generics, ForeignItemKind::Fn(_, _, ref generics) => generics, ForeignItemKind::Type => &no_generics, @@ -1072,7 +1072,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { // cares about anything but the length is instantiation, // and we don't do that for closures. if let Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(.., gen), + kind: hir::ExprKind::Closure(.., gen), .. }) = node { @@ -1207,14 +1207,14 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option match item.node { + Node::TraitItem(item) => match item.kind { TraitItemKind::Method(..) => { let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } TraitItemKind::Const(ref ty, body_id) => { body_id.and_then(|body_id| { - if let hir::TyKind::Infer = ty.node { + if let hir::TyKind::Infer = ty.kind { Some(infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident)) } else { None @@ -1230,13 +1230,13 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option match item.node { + Node::ImplItem(item) => match item.kind { ImplItemKind::Method(..) => { let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } ImplItemKind::Const(ref ty, body_id) => { - if let hir::TyKind::Infer = ty.node { + if let hir::TyKind::Infer = ty.kind { infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident) } else { icx.to_ty(ty) @@ -1265,10 +1265,10 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option { - match item.node { + match item.kind { ItemKind::Static(ref ty, .., body_id) | ItemKind::Const(ref ty, body_id) => { - if let hir::TyKind::Infer = ty.node { + if let hir::TyKind::Infer = ty.kind { infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident) } else { icx.to_ty(ty) @@ -1325,13 +1325,13 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option match foreign_item.node { + Node::ForeignItem(foreign_item) => match foreign_item.kind { ForeignItemKind::Fn(..) => { let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) @@ -1355,7 +1355,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option icx.to_ty(&field.ty), Node::Expr(&hir::Expr { - node: hir::ExprKind::Closure(.., gen), + kind: hir::ExprKind::Closure(.., gen), .. }) => { if gen.is_some() { @@ -1373,15 +1373,15 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option { @@ -1399,22 +1399,22 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option { let path = match parent_node { Node::Ty(&hir::Ty { - node: hir::TyKind::Path(QPath::Resolved(_, ref path)), + kind: hir::TyKind::Path(QPath::Resolved(_, ref path)), .. }) | Node::Expr(&hir::Expr { - node: ExprKind::Path(QPath::Resolved(_, ref path)), + kind: ExprKind::Path(QPath::Resolved(_, ref path)), .. }) => { Some(&**path) } - Node::Expr(&hir::Expr { node: ExprKind::Struct(ref path, ..), .. }) => { + Node::Expr(&hir::Expr { kind: ExprKind::Struct(ref path, ..), .. }) => { if let QPath::Resolved(_, ref path) = **path { Some(&**path) } else { @@ -1769,7 +1769,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { pub fn get_infer_ret_ty(output: &'_ hir::FunctionRetTy) -> Option<&hir::Ty> { if let hir::FunctionRetTy::Return(ref ty) = output { - if let hir::TyKind::Infer = ty.node { + if let hir::TyKind::Infer = ty.kind { return Some(&**ty) } } @@ -1786,15 +1786,15 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { match tcx.hir().get(hir_id) { TraitItem(hir::TraitItem { - node: TraitItemKind::Method(MethodSig { header, decl }, TraitMethod::Provided(_)), + kind: TraitItemKind::Method(MethodSig { header, decl }, TraitMethod::Provided(_)), .. }) | ImplItem(hir::ImplItem { - node: ImplItemKind::Method(MethodSig { header, decl }, _), + kind: ImplItemKind::Method(MethodSig { header, decl }, _), .. }) | Item(hir::Item { - node: ItemKind::Fn(decl, header, _, _), + kind: ItemKind::Fn(decl, header, _, _), .. }) => match get_infer_ret_ty(&decl.output) { Some(ty) => { @@ -1816,14 +1816,14 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { }, TraitItem(hir::TraitItem { - node: TraitItemKind::Method(MethodSig { header, decl }, _), + kind: TraitItemKind::Method(MethodSig { header, decl }, _), .. }) => { AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl) }, ForeignItem(&hir::ForeignItem { - node: ForeignItemKind::Fn(ref fn_decl, _, _), + kind: ForeignItemKind::Fn(ref fn_decl, _, _), .. }) => { let abi = tcx.hir().get_foreign_abi(hir_id); @@ -1847,7 +1847,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { } Expr(&hir::Expr { - node: hir::ExprKind::Closure(..), + kind: hir::ExprKind::Closure(..), .. }) => { // Closure signatures are not like other function @@ -1878,7 +1878,7 @@ fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option> { 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"); @@ -2055,7 +2055,7 @@ fn explicit_predicates_of( let ast_generics = match node { Node::TraitItem(item) => &item.generics, - Node::ImplItem(item) => match item.node { + Node::ImplItem(item) => match item.kind { ImplItemKind::OpaqueTy(ref bounds) => { let substs = InternalSubsts::identity_for_item(tcx, def_id); let opaque_ty = tcx.mk_opaque(def_id, substs); @@ -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); @@ -2133,7 +2133,7 @@ fn explicit_predicates_of( } } - Node::ForeignItem(item) => match item.node { + Node::ForeignItem(item) => match item.kind { ForeignItemKind::Static(..) => NO_GENERICS, ForeignItemKind::Fn(_, _, ref generics) => generics, ForeignItemKind::Type => NO_GENERICS, @@ -2281,7 +2281,7 @@ fn explicit_predicates_of( if let Some((self_trait_ref, trait_items)) = is_trait { predicates.extend(trait_items.iter().flat_map(|trait_item_ref| { let trait_item = tcx.hir().trait_item(trait_item_ref.id); - let bounds = match trait_item.node { + let bounds = match trait_item.kind { hir::TraitItemKind::Type(ref bounds, _) => bounds, _ => return Vec::new().into_iter() }; @@ -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,10 +2417,10 @@ fn is_foreign_item(tcx: TyCtxt<'_>, def_id: DefId) -> bool { fn static_mutability(tcx: TyCtxt<'_>, def_id: DefId) -> Option { 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), .. + kind: hir::ForeignItemKind::Static(_, mutbl), .. })) => Some(mutbl), Some(_) => None, _ => bug!("static_mutability applied to non-local def-id {:?}", def_id), @@ -2653,7 +2653,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs { if attr.path != sym::inline { return ia; } - match attr.meta().map(|i| i.node) { + match attr.meta().map(|i| i.kind) { Some(MetaItemKind::Word) => { mark_used(attr); InlineAttr::Hint @@ -2694,7 +2694,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs { return ia; } let err = |sp, s| span_err!(tcx.sess.diagnostic(), sp, E0722, "{}", s); - match attr.meta().map(|i| i.node) { + match attr.meta().map(|i| i.kind) { Some(MetaItemKind::Word) => { err(attr.span, "expected one argument"); ia diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 854549bb66b33..ab660caa222ae 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -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, @@ -197,7 +197,7 @@ fn enforce_impl_items_are_distinct(tcx: TyCtxt<'_>, impl_item_refs: &[hir::ImplI let mut seen_value_items = FxHashMap::default(); for impl_item_ref in impl_item_refs { let impl_item = tcx.hir().impl_item(impl_item_ref.id); - let seen_items = match impl_item.node { + let seen_items = match impl_item.kind { hir::ImplItemKind::TyAlias(_) => &mut seen_type_items, _ => &mut seen_value_items, }; diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index dbff1e91617e5..00be1c84599a3 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -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, diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index 88091d0da0e49..433d04ffa64ff 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -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); diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index 59aac5c7ffd3f..cdb83eb328ac2 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -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); diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 0feaa2566279b..4431abdaf50a0 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -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); @@ -94,7 +94,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { - if let hir::ForeignItemKind::Fn(..) = foreign_item.node { + if let hir::ForeignItemKind::Fn(..) = foreign_item.kind { self.visit_node_helper(foreign_item.hir_id); } } @@ -105,13 +105,13 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { } fn visit_trait_item(&mut self, trait_item: &hir::TraitItem) { - if let hir::TraitItemKind::Method(..) = trait_item.node { + if let hir::TraitItemKind::Method(..) = trait_item.kind { self.visit_node_helper(trait_item.hir_id); } } fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) { - if let hir::ImplItemKind::Method(..) = impl_item.node { + if let hir::ImplItemKind::Method(..) = impl_item.kind { self.visit_node_helper(impl_item.hir_id); } } diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 343d7ea656fbb..745dbee5fd320 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -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(..) | @@ -58,19 +58,19 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] { _ => unsupported() }, - Node::TraitItem(item) => match item.node { + Node::TraitItem(item) => match item.kind { hir::TraitItemKind::Method(..) => {} _ => unsupported() }, - Node::ImplItem(item) => match item.node { + Node::ImplItem(item) => match item.kind { hir::ImplItemKind::Method(..) => {} _ => unsupported() }, - Node::ForeignItem(item) => match item.node { + Node::ForeignItem(item) => match item.kind { hir::ForeignItemKind::Fn(..) => {} _ => unsupported() diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index e10837e52ad04..863a0b267fddd 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -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); @@ -157,7 +157,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { hir::ItemKind::ForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { - if let hir::ForeignItemKind::Fn(..) = foreign_item.node { + if let hir::ForeignItemKind::Fn(..) = foreign_item.kind { self.add_inferreds_for_item(foreign_item.hir_id); } } @@ -168,13 +168,13 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { } fn visit_trait_item(&mut self, trait_item: &hir::TraitItem) { - if let hir::TraitItemKind::Method(..) = trait_item.node { + if let hir::TraitItemKind::Method(..) = trait_item.kind { self.add_inferreds_for_item(trait_item.hir_id); } } fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) { - if let hir::ImplItemKind::Method(..) = impl_item.node { + if let hir::ImplItemKind::Method(..) = impl_item.kind { self.add_inferreds_for_item(impl_item.hir_id); } } diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index c3092cea9833c..da3b52afadffb 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -68,9 +68,9 @@ impl Cfg { span: cfg.span }), }; - match cfg.node { + match cfg.kind { MetaItemKind::Word => Ok(Cfg::Cfg(name, None)), - MetaItemKind::NameValue(ref lit) => match lit.node { + MetaItemKind::NameValue(ref lit) => match lit.kind { LitKind::Str(value, _) => Ok(Cfg::Cfg(name, Some(value))), _ => Err(InvalidCfgError { // FIXME: if the main #[cfg] syntax decided to support non-string literals, diff --git a/src/librustdoc/clean/cfg/tests.rs b/src/librustdoc/clean/cfg/tests.rs index ec5d86b2c611d..580320a735bc0 100644 --- a/src/librustdoc/clean/cfg/tests.rs +++ b/src/librustdoc/clean/cfg/tests.rs @@ -17,7 +17,7 @@ fn name_value_cfg(name: &str, value: &str) -> Cfg { fn dummy_meta_item_word(name: &str) -> MetaItem { MetaItem { path: Path::from_ident(Ident::from_str(name)), - node: MetaItemKind::Word, + kind: MetaItemKind::Word, span: DUMMY_SP, } } @@ -26,7 +26,7 @@ macro_rules! dummy_meta_item_list { ($name:ident, [$($list:ident),* $(,)?]) => { MetaItem { path: Path::from_ident(Ident::from_str(stringify!($name))), - node: MetaItemKind::List(vec![ + kind: MetaItemKind::List(vec![ $( NestedMetaItem::MetaItem( dummy_meta_item_word(stringify!($list)), @@ -40,7 +40,7 @@ macro_rules! dummy_meta_item_list { ($name:ident, [$($list:expr),* $(,)?]) => { MetaItem { path: Path::from_ident(Ident::from_str(stringify!($name))), - node: MetaItemKind::List(vec![ + kind: MetaItemKind::List(vec![ $( NestedMetaItem::MetaItem($list), )* diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 479c8c3728305..532c5f67bf3ba 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -333,7 +333,7 @@ pub fn build_impl(cx: &DocContext<'_>, did: DefId, attrs: Option>, } 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>, 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 = if let ast::ItemKind::MacroDef(ref def) = def.node { + let matchers: hir::HirVec = 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 { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index aad1c80c3dc72..ce21447105815 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -275,7 +275,7 @@ impl Clean 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 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, @@ -778,11 +778,11 @@ impl Attributes { fn extract_cfg(mi: &ast::MetaItem) -> Option<&ast::MetaItem> { use syntax::ast::NestedMetaItem::MetaItem; - if let ast::MetaItemKind::List(ref nmis) = mi.node { + if let ast::MetaItemKind::List(ref nmis) = mi.kind { if nmis.len() == 1 { if let MetaItem(ref cfg_mi) = nmis[0] { if cfg_mi.check_name(sym::cfg) { - if let ast::MetaItemKind::List(ref cfg_nmis) = cfg_mi.node { + if let ast::MetaItemKind::List(ref cfg_nmis) = cfg_mi.kind { if cfg_nmis.len() == 1 { if let MetaItem(ref content_mi) = cfg_nmis[0] { return Some(content_mi); @@ -2280,7 +2280,7 @@ impl Clean for hir::PolyTraitRef { impl Clean for hir::TraitItem { fn clean(&self, cx: &DocContext<'_>) -> Item { - let inner = match self.node { + let inner = match self.kind { hir::TraitItemKind::Const(ref ty, default) => { AssocConstItem(ty.clean(cx), default.map(|e| print_const_expr(cx, e))) @@ -2321,7 +2321,7 @@ impl Clean for hir::TraitItem { impl Clean for hir::ImplItem { fn clean(&self, cx: &DocContext<'_>) -> Item { - let inner = match self.node { + let inner = match self.kind { hir::ImplItemKind::Const(ref ty, expr) => { AssocConstItem(ty.clean(cx), Some(print_const_expr(cx, expr))) @@ -2835,7 +2835,7 @@ impl Clean for hir::Ty { fn clean(&self, cx: &DocContext<'_>) -> Type { use rustc::hir::*; - match self.node { + match self.kind { TyKind::Never => Never, TyKind::Ptr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)), TyKind::Rptr(ref l, ref m) => { @@ -2868,7 +2868,7 @@ impl Clean 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 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); } } }; @@ -3031,7 +3031,7 @@ impl Clean for hir::Ty { } TyKind::BareFn(ref barefn) => BareFunction(box barefn.clean(cx)), TyKind::Infer | TyKind::Err => Infer, - TyKind::Typeof(..) => panic!("unimplemented type {:?}", self.node), + TyKind::Typeof(..) => panic!("unimplemented type {:?}", self.kind), TyKind::CVarArgs(_) => CVarArgs, } } @@ -4182,7 +4182,7 @@ fn name_from_pat(p: &hir::Pat) -> String { use rustc::hir::*; debug!("trying to get a name from pattern: {:?}", p); - match p.node { + match p.kind { PatKind::Wild => "_".to_string(), PatKind::Binding(_, _, ident, _) => ident.to_string(), PatKind::TupleStruct(ref p, ..) | PatKind::Path(ref p) => qpath_to_string(p), diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 424239c998237..6576165b6ce74 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -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() diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index ee330cb32111e..b6a90e1fb988b 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -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); @@ -561,7 +561,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { om.foreigns.push(ForeignItem { id: item.hir_id, name: renamed.unwrap_or(item.ident).name, - kind: &item.node, + kind: &item.kind, vis: &item.vis, attrs: &item.attrs, whence: item.span diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b634dcca7fca2..a7f035dc9ecc7 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -472,7 +472,7 @@ pub enum NestedMetaItem { #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct MetaItem { pub path: Path, - pub node: MetaItemKind, + pub kind: MetaItemKind, pub span: Span, } @@ -511,7 +511,7 @@ pub struct Block { #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Pat { pub id: NodeId, - pub node: PatKind, + pub kind: PatKind, pub span: Span, } @@ -525,7 +525,7 @@ impl Pat { /// Attempt reparsing the pattern as a type. /// This is intended for use by diagnostics. pub(super) fn to_ty(&self) -> Option> { - let node = match &self.node { + let kind = match &self.kind { // In a type expression `_` is an inference variable. PatKind::Wild => TyKind::Infer, // An IDENT pattern with no binding mode would be valid as path to a type. E.g. `u32`. @@ -555,7 +555,7 @@ impl Pat { }; Some(P(Ty { - node, + kind, id: self.id, span: self.span, })) @@ -569,7 +569,7 @@ impl Pat { return; } - match &self.node { + match &self.kind { PatKind::Ident(_, _, Some(p)) => p.walk(it), PatKind::Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk(it)), PatKind::TupleStruct(_, s) @@ -591,7 +591,7 @@ impl Pat { /// Is this a `..` pattern? pub fn is_rest(&self) -> bool { - match self.node { + match self.kind { PatKind::Rest => true, _ => false, } @@ -835,31 +835,31 @@ impl UnOp { #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Stmt { pub id: NodeId, - pub node: StmtKind, + pub kind: StmtKind, pub span: Span, } impl Stmt { pub fn add_trailing_semicolon(mut self) -> Self { - self.node = match self.node { + self.kind = match self.kind { StmtKind::Expr(expr) => StmtKind::Semi(expr), StmtKind::Mac(mac) => { StmtKind::Mac(mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs))) } - node => node, + kind => kind, }; self } pub fn is_item(&self) -> bool { - match self.node { + match self.kind { StmtKind::Item(_) => true, _ => false, } } pub fn is_expr(&self) -> bool { - match self.node { + match self.kind { StmtKind::Expr(_) => true, _ => false, } @@ -977,7 +977,7 @@ pub struct AnonConst { #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Expr { pub id: NodeId, - pub node: ExprKind, + pub kind: ExprKind, pub span: Span, pub attrs: ThinVec, } @@ -990,12 +990,12 @@ impl Expr { /// Returns `true` if this expression would be valid somewhere that expects a value; /// for example, an `if` condition. pub fn returns(&self) -> bool { - if let ExprKind::Block(ref block, _) = self.node { - match block.stmts.last().map(|last_stmt| &last_stmt.node) { + if let ExprKind::Block(ref block, _) = self.kind { + match block.stmts.last().map(|last_stmt| &last_stmt.kind) { // Implicit return Some(&StmtKind::Expr(_)) => true, Some(&StmtKind::Semi(ref expr)) => { - if let ExprKind::Ret(_) = expr.node { + if let ExprKind::Ret(_) = expr.kind { // Last statement is explicit return. true } else { @@ -1012,7 +1012,7 @@ impl Expr { } fn to_bound(&self) -> Option { - match &self.node { + match &self.kind { ExprKind::Path(None, path) => Some(GenericBound::Trait( PolyTraitRef::new(Vec::new(), path.clone(), self.span), TraitBoundModifier::None, @@ -1022,7 +1022,7 @@ impl Expr { } pub(super) fn to_ty(&self) -> Option> { - let node = match &self.node { + let kind = match &self.kind { ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()), ExprKind::Mac(mac) => TyKind::Mac(mac.clone()), ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?, @@ -1051,14 +1051,14 @@ impl Expr { }; Some(P(Ty { - node, + kind, id: self.id, span: self.span, })) } pub fn precedence(&self) -> ExprPrecedence { - match self.node { + match self.kind { ExprKind::Box(_) => ExprPrecedence::Box, ExprKind::Array(_) => ExprPrecedence::Array, ExprKind::Call(..) => ExprPrecedence::Call, @@ -1361,7 +1361,7 @@ pub struct Lit { /// The "semantic" representation of the literal lowered from the original tokens. /// Strings are unescaped, hexadecimal forms are eliminated, etc. /// FIXME: Remove this and only create the semantic representation during lowering to HIR. - pub node: LitKind, + pub kind: LitKind, pub span: Span, } @@ -1474,7 +1474,7 @@ pub struct TraitItem { pub ident: Ident, pub attrs: Vec, pub generics: Generics, - pub node: TraitItemKind, + pub kind: TraitItemKind, pub span: Span, /// See `Item::tokens` for what this is. pub tokens: Option, @@ -1497,7 +1497,7 @@ pub struct ImplItem { pub defaultness: Defaultness, pub attrs: Vec, pub generics: Generics, - pub node: ImplItemKind, + pub kind: ImplItemKind, pub span: Span, /// See `Item::tokens` for what this is. pub tokens: Option, @@ -1664,7 +1664,7 @@ pub enum AssocTyConstraintKind { #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Ty { pub id: NodeId, - pub node: TyKind, + pub kind: TyKind, pub span: Span, } @@ -1821,11 +1821,11 @@ pub type ExplicitSelf = Spanned; impl Param { pub fn to_self(&self) -> Option { - if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.node { + if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.kind { if ident.name == kw::SelfLower { - return match self.ty.node { + return match self.ty.kind { TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))), - TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.node.is_implicit_self() => { + TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.kind.is_implicit_self() => { Some(respan(self.pat.span, SelfKind::Region(lt, mutbl))) } _ => Some(respan( @@ -1839,7 +1839,7 @@ impl Param { } pub fn is_self(&self) -> bool { - if let PatKind::Ident(_, ident, _) = self.pat.node { + if let PatKind::Ident(_, ident, _) = self.pat.kind { ident.name == kw::SelfLower } else { false @@ -1850,14 +1850,14 @@ impl Param { let span = eself.span.to(eself_ident.span); let infer_ty = P(Ty { id: DUMMY_NODE_ID, - node: TyKind::ImplicitSelf, + kind: TyKind::ImplicitSelf, span, }); let param = |mutbl, ty| Param { attrs, pat: P(Pat { id: DUMMY_NODE_ID, - node: PatKind::Ident(BindingMode::ByValue(mutbl), eself_ident, None), + kind: PatKind::Ident(BindingMode::ByValue(mutbl), eself_ident, None), span, }), span, @@ -1872,7 +1872,7 @@ impl Param { Mutability::Immutable, P(Ty { id: DUMMY_NODE_ID, - node: TyKind::Rptr( + kind: TyKind::Rptr( lt, MutTy { ty: infer_ty, @@ -2269,7 +2269,7 @@ pub struct Item { pub ident: Ident, pub attrs: Vec, pub id: NodeId, - pub node: ItemKind, + pub kind: ItemKind, pub vis: Visibility, pub span: Span, @@ -2421,7 +2421,7 @@ impl ItemKind { pub struct ForeignItem { pub ident: Ident, pub attrs: Vec, - pub node: ForeignItemKind, + pub kind: ForeignItemKind, pub id: NodeId, pub span: Span, pub vis: Visibility, diff --git a/src/libsyntax/attr/builtin.rs b/src/libsyntax/attr/builtin.rs index b5037b75f79e7..2a8e6b2cc9510 100644 --- a/src/libsyntax/attr/builtin.rs +++ b/src/libsyntax/attr/builtin.rs @@ -36,7 +36,7 @@ impl AttributeTemplate { match meta_item_kind { ast::MetaItemKind::Word => self.word, ast::MetaItemKind::List(..) => self.list.is_some(), - ast::MetaItemKind::NameValue(lit) if lit.node.is_str() => self.name_value_str.is_some(), + ast::MetaItemKind::NameValue(lit) if lit.kind.is_str() => self.name_value_str.is_some(), ast::MetaItemKind::NameValue(..) => false, } } @@ -106,7 +106,7 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op attrs.iter().fold(None, |ia, attr| { if attr.check_name(sym::unwind) { if let Some(meta) = attr.meta() { - if let MetaItemKind::List(items) = meta.node { + if let MetaItemKind::List(items) = meta.kind { if items.len() == 1 { if items[0].check_name(sym::allowed) { return Some(UnwindAttr::Allowed); @@ -239,7 +239,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess, allow_const_fn_ptr = true; } // attributes with data - else if let Some(MetaItem { node: MetaItemKind::List(ref metas), .. }) = meta { + else if let Some(MetaItem { kind: MetaItemKind::List(ref metas), .. }) = meta { let meta = meta.as_ref().unwrap(); let get = |meta: &MetaItem, item: &mut Option| { if item.is_some() { @@ -534,17 +534,17 @@ pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Feat if cfg.path.segments.len() != 1 { return error(cfg.path.span, "`cfg` predicate key must be an identifier"); } - match &cfg.node { + match &cfg.kind { MetaItemKind::List(..) => { error(cfg.span, "unexpected parentheses after `cfg` predicate key") } - MetaItemKind::NameValue(lit) if !lit.node.is_str() => { + MetaItemKind::NameValue(lit) if !lit.kind.is_str() => { handle_errors( sess, lit.span, AttrError::UnsupportedLiteral( "literal in `cfg` predicate value must be a string", - lit.node.is_bytestr() + lit.kind.is_bytestr() ), ); true @@ -563,7 +563,7 @@ pub fn eval_condition(cfg: &ast::MetaItem, sess: &ParseSess, eval: &mut F) -> bool where F: FnMut(&ast::MetaItem) -> bool { - match cfg.node { + match cfg.kind { ast::MetaItemKind::List(ref mis) => { for mi in mis.iter() { if !mi.is_meta_item() { @@ -642,7 +642,7 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess, } let meta = attr.meta().unwrap(); - depr = match &meta.node { + depr = match &meta.kind { MetaItemKind::Word => Some(Deprecation { since: None, note: None }), MetaItemKind::NameValue(..) => { meta.value_str().map(|note| { @@ -668,7 +668,7 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess, AttrError::UnsupportedLiteral( "literal in `deprecated` \ value must be a string", - lit.node.is_bytestr() + lit.kind.is_bytestr() ), ); } else { @@ -811,14 +811,14 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec { let mut literal_error = None; if name == sym::align { recognised = true; - match parse_alignment(&value.node) { + match parse_alignment(&value.kind) { Ok(literal) => acc.push(ReprAlign(literal)), Err(message) => literal_error = Some(message) }; } else if name == sym::packed { recognised = true; - match parse_alignment(&value.node) { + match parse_alignment(&value.kind) { Ok(literal) => acc.push(ReprPacked(literal)), Err(message) => literal_error = Some(message) }; @@ -830,11 +830,11 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec { } else { if let Some(meta_item) = item.meta_item() { if meta_item.check_name(sym::align) { - if let MetaItemKind::NameValue(ref value) = meta_item.node { + if let MetaItemKind::NameValue(ref value) = meta_item.kind { recognised = true; let mut err = struct_span_err!(diagnostic, item.span(), E0693, "incorrect `repr(align)` attribute format"); - match value.node { + match value.kind { ast::LitKind::Int(int, ast::LitIntType::Unsuffixed) => { err.span_suggestion( item.span(), @@ -941,7 +941,7 @@ crate fn check_builtin_attribute( name == sym::test || name == sym::bench; match attr.parse_meta(sess) { - Ok(meta) => if !should_skip(name) && !template.compatible(&meta.node) { + Ok(meta) => if !should_skip(name) && !template.compatible(&meta.kind) { let error_msg = format!("malformed `{}` attribute input", name); let mut msg = "attribute must be of the form ".to_owned(); let mut suggestions = vec![]; diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 9d06b926f972e..122cb7fb12b24 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -174,7 +174,7 @@ impl Attribute { pub fn meta_item_list(&self) -> Option> { match self.meta() { - Some(MetaItem { node: MetaItemKind::List(list), .. }) => Some(list), + Some(MetaItem { kind: MetaItemKind::List(list), .. }) => Some(list), _ => None } } @@ -210,16 +210,16 @@ impl MetaItem { // #[attribute(name = "value")] // ^^^^^^^^^^^^^^ pub fn name_value_literal(&self) -> Option<&Lit> { - match &self.node { + match &self.kind { MetaItemKind::NameValue(v) => Some(v), _ => None, } } pub fn value_str(&self) -> Option { - match self.node { + match self.kind { MetaItemKind::NameValue(ref v) => { - match v.node { + match v.kind { LitKind::Str(ref s, _) => Some(*s), _ => None, } @@ -229,14 +229,14 @@ impl MetaItem { } pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> { - match self.node { + match self.kind { MetaItemKind::List(ref l) => Some(&l[..]), _ => None } } pub fn is_word(&self) -> bool { - match self.node { + match self.kind { MetaItemKind::Word => true, _ => false, } @@ -261,11 +261,11 @@ impl Attribute { let mut tokens = self.tokens.trees().peekable(); Some(MetaItem { path: self.path.clone(), - node: if let Some(node) = MetaItemKind::from_tokens(&mut tokens) { + kind: if let Some(kind) = MetaItemKind::from_tokens(&mut tokens) { if tokens.peek().is_some() { return None; } - node + kind } else { return None; }, @@ -314,7 +314,7 @@ impl Attribute { pub fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> { Ok(MetaItem { path: self.path.clone(), - node: self.parse(sess, |parser| parser.parse_meta_item_kind())?, + kind: self.parse(sess, |parser| parser.parse_meta_item_kind())?, span: self.span, }) } @@ -336,7 +336,7 @@ impl Attribute { id: self.id, style: self.style, path: meta.path, - tokens: meta.node.tokens(meta.span), + tokens: meta.kind.tokens(meta.span), is_sugared_doc: true, span: self.span, }) @@ -356,15 +356,15 @@ pub fn mk_name_value_item_str(ident: Ident, str: Symbol, str_span: Span) -> Meta pub fn mk_name_value_item(ident: Ident, lit_kind: LitKind, lit_span: Span) -> MetaItem { let lit = Lit::from_lit_kind(lit_kind, lit_span); let span = ident.span.to(lit_span); - MetaItem { path: Path::from_ident(ident), span, node: MetaItemKind::NameValue(lit) } + MetaItem { path: Path::from_ident(ident), span, kind: MetaItemKind::NameValue(lit) } } pub fn mk_list_item(ident: Ident, items: Vec) -> MetaItem { - MetaItem { path: Path::from_ident(ident), span: ident.span, node: MetaItemKind::List(items) } + MetaItem { path: Path::from_ident(ident), span: ident.span, kind: MetaItemKind::List(items) } } pub fn mk_word_item(ident: Ident) -> MetaItem { - MetaItem { path: Path::from_ident(ident), span: ident.span, node: MetaItemKind::Word } + MetaItem { path: Path::from_ident(ident), span: ident.span, kind: MetaItemKind::Word } } pub fn mk_nested_word_item(ident: Ident) -> NestedMetaItem { @@ -395,12 +395,12 @@ pub fn mk_attr(style: AttrStyle, path: Path, tokens: TokenStream, span: Span) -> /// Returns an inner attribute with the given value and span. pub fn mk_attr_inner(item: MetaItem) -> Attribute { - mk_attr(AttrStyle::Inner, item.path, item.node.tokens(item.span), item.span) + mk_attr(AttrStyle::Inner, item.path, item.kind.tokens(item.span), item.span) } /// Returns an outer attribute with the given value and span. pub fn mk_attr_outer(item: MetaItem) -> Attribute { - mk_attr(AttrStyle::Outer, item.path, item.node.tokens(item.span), item.span) + mk_attr(AttrStyle::Outer, item.path, item.kind.tokens(item.span), item.span) } pub fn mk_sugared_doc_attr(text: Symbol, span: Span) -> Attribute { @@ -483,7 +483,7 @@ impl MetaItem { idents.push(TokenTree::Token(Token::from_ast_ident(segment.ident)).into()); last_pos = segment.ident.span.hi(); } - self.node.tokens(self.span).append_to_tree_and_joint_vec(&mut idents); + self.kind.tokens(self.span).append_to_tree_and_joint_vec(&mut idents); TokenStream::new(idents) } @@ -531,14 +531,14 @@ impl MetaItem { _ => return None, }; let list_closing_paren_pos = tokens.peek().map(|tt| tt.span().hi()); - let node = MetaItemKind::from_tokens(tokens)?; - let hi = match node { + let kind = MetaItemKind::from_tokens(tokens)?; + let hi = match kind { MetaItemKind::NameValue(ref lit) => lit.span.hi(), MetaItemKind::List(..) => list_closing_paren_pos.unwrap_or(path.span.hi()), _ => path.span.hi(), }; let span = path.span.with_hi(hi); - Some(MetaItem { path, node, span }) + Some(MetaItem { path, kind, span }) } } @@ -702,11 +702,11 @@ impl HasAttrs for StmtKind { impl HasAttrs for Stmt { fn attrs(&self) -> &[ast::Attribute] { - self.node.attrs() + self.kind.attrs() } fn visit_attrs)>(&mut self, f: F) { - self.node.visit_attrs(f); + self.kind.visit_attrs(f); } } diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 7eeea4e7bdfe1..990358c674ff7 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -298,7 +298,7 @@ impl<'a> StripUnconfigured<'a> { } pub fn configure_pat(&mut self, pat: &mut P) { - if let ast::PatKind::Struct(_path, fields, _etc) = &mut pat.node { + if let ast::PatKind::Struct(_path, fields, _etc) = &mut pat.kind { fields.flat_map_in_place(|field| self.configure(field)); } } @@ -321,13 +321,13 @@ impl<'a> MutVisitor for StripUnconfigured<'a> { fn visit_expr(&mut self, expr: &mut P) { self.configure_expr(expr); - self.configure_expr_kind(&mut expr.node); + self.configure_expr_kind(&mut expr.kind); noop_visit_expr(expr, self); } fn filter_map_expr(&mut self, expr: P) -> Option> { let mut expr = configure!(self, expr); - self.configure_expr_kind(&mut expr.node); + self.configure_expr_kind(&mut expr.kind); noop_visit_expr(&mut expr, self); Some(expr) } diff --git a/src/libsyntax/entry.rs b/src/libsyntax/entry.rs index 0b6cf30bd27d2..34b5b1e5b5c84 100644 --- a/src/libsyntax/entry.rs +++ b/src/libsyntax/entry.rs @@ -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 diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index aa76667c2e901..54cfb80573e5c 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -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, @@ -363,7 +363,7 @@ macro_rules! make_stmts_default { $me.make_expr().map(|e| smallvec![ast::Stmt { id: ast::DUMMY_NODE_ID, span: e.span, - node: ast::StmtKind::Expr(e), + kind: ast::StmtKind::Expr(e), }]) } } @@ -507,11 +507,11 @@ impl MacResult for MacEager { return Some(p); } if let Some(e) = self.expr { - if let ast::ExprKind::Lit(_) = e.node { + if let ast::ExprKind::Lit(_) = e.kind { return Some(P(ast::Pat { id: ast::DUMMY_NODE_ID, span: e.span, - node: PatKind::Lit(e), + kind: PatKind::Lit(e), })); } } @@ -549,7 +549,7 @@ impl DummyResult { pub fn raw_expr(sp: Span, is_error: bool) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(Vec::new()) }, + kind: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(Vec::new()) }, span: sp, attrs: ThinVec::new(), }) @@ -559,7 +559,7 @@ impl DummyResult { pub fn raw_pat(sp: Span) -> ast::Pat { ast::Pat { id: ast::DUMMY_NODE_ID, - node: PatKind::Wild, + kind: PatKind::Wild, span: sp, } } @@ -568,7 +568,7 @@ impl DummyResult { pub fn raw_ty(sp: Span, is_error: bool) -> P { P(ast::Ty { id: ast::DUMMY_NODE_ID, - node: if is_error { ast::TyKind::Err } else { ast::TyKind::Tup(Vec::new()) }, + kind: if is_error { ast::TyKind::Err } else { ast::TyKind::Tup(Vec::new()) }, span: sp }) } @@ -602,7 +602,7 @@ impl MacResult for DummyResult { fn make_stmts(self: Box) -> Option> { Some(smallvec![ast::Stmt { id: ast::DUMMY_NODE_ID, - node: ast::StmtKind::Expr(DummyResult::raw_expr(self.span, self.is_error)), + kind: ast::StmtKind::Expr(DummyResult::raw_expr(self.span, self.is_error)), span: self.span, }]) } @@ -1098,8 +1098,8 @@ pub fn expr_to_spanned_string<'a>( // We want to be able to handle e.g., `concat!("foo", "bar")`. let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr(); - Err(match expr.node { - ast::ExprKind::Lit(ref l) => match l.node { + Err(match expr.kind { + ast::ExprKind::Lit(ref l) => match l.kind { ast::LitKind::Str(s, style) => return Ok((s, style, expr.span)), ast::LitKind::Err(_) => None, _ => Some(cx.struct_span_err(l.span, err_msg)) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index f903b66e2961d..6b93d045588b9 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -54,11 +54,11 @@ impl<'a> ExtCtxt<'a> { } } - pub fn ty(&self, span: Span, ty: ast::TyKind) -> P { + pub fn ty(&self, span: Span, kind: ast::TyKind) -> P { P(ast::Ty { id: ast::DUMMY_NODE_ID, span, - node: ty + kind, }) } @@ -73,12 +73,12 @@ impl<'a> ExtCtxt<'a> { self.ty_path(self.path_ident(span, ident)) } - pub fn anon_const(&self, span: Span, expr: ast::ExprKind) -> ast::AnonConst { + pub fn anon_const(&self, span: Span, kind: ast::ExprKind) -> ast::AnonConst { ast::AnonConst { id: ast::DUMMY_NODE_ID, value: P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: expr, + kind, span, attrs: ThinVec::new(), }) @@ -171,7 +171,7 @@ impl<'a> ExtCtxt<'a> { ast::Stmt { id: ast::DUMMY_NODE_ID, span: expr.span, - node: ast::StmtKind::Expr(expr), + kind: ast::StmtKind::Expr(expr), } } @@ -193,7 +193,7 @@ impl<'a> ExtCtxt<'a> { }); ast::Stmt { id: ast::DUMMY_NODE_ID, - node: ast::StmtKind::Local(local), + kind: ast::StmtKind::Local(local), span: sp, } } @@ -210,7 +210,7 @@ impl<'a> ExtCtxt<'a> { }); ast::Stmt { id: ast::DUMMY_NODE_ID, - node: ast::StmtKind::Local(local), + kind: ast::StmtKind::Local(local), span, } } @@ -218,7 +218,7 @@ impl<'a> ExtCtxt<'a> { pub fn stmt_item(&self, sp: Span, item: P) -> ast::Stmt { ast::Stmt { id: ast::DUMMY_NODE_ID, - node: ast::StmtKind::Item(item), + kind: ast::StmtKind::Item(item), span: sp, } } @@ -227,7 +227,7 @@ impl<'a> ExtCtxt<'a> { self.block(expr.span, vec![ast::Stmt { id: ast::DUMMY_NODE_ID, span: expr.span, - node: ast::StmtKind::Expr(expr), + kind: ast::StmtKind::Expr(expr), }]) } pub fn block(&self, span: Span, stmts: Vec) -> P { @@ -239,10 +239,10 @@ impl<'a> ExtCtxt<'a> { }) } - pub fn expr(&self, span: Span, node: ast::ExprKind) -> P { + pub fn expr(&self, span: Span, kind: ast::ExprKind) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node, + kind, span, attrs: ThinVec::new(), }) @@ -411,8 +411,8 @@ impl<'a> ExtCtxt<'a> { } - pub fn pat(&self, span: Span, pat: PatKind) -> P { - P(ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span }) + pub fn pat(&self, span: Span, kind: PatKind) -> P { + P(ast::Pat { id: ast::DUMMY_NODE_ID, kind, span }) } pub fn pat_wild(&self, span: Span) -> P { self.pat(span, PatKind::Wild) @@ -567,14 +567,14 @@ impl<'a> ExtCtxt<'a> { } pub fn item(&self, span: Span, name: Ident, - attrs: Vec, node: ast::ItemKind) -> P { + attrs: Vec, kind: ast::ItemKind) -> P { // 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, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index c8078d2bb712e..02e7c6775a49d 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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; }, @@ -659,7 +659,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { if !item.derive_allowed() { return fragment_kind.dummy(span); } - let meta = ast::MetaItem { node: ast::MetaItemKind::Word, span, path }; + let meta = ast::MetaItem { kind: ast::MetaItemKind::Word, span, path }; let items = expander.expand(self.cx, span, &meta, item); fragment_kind.expect_from_annotatables(items) } @@ -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, @@ -1035,7 +1035,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { fn visit_expr(&mut self, expr: &mut P) { self.cfg.configure_expr(expr); visit_clobber(expr.deref_mut(), |mut expr| { - self.cfg.configure_expr_kind(&mut expr.node); + self.cfg.configure_expr_kind(&mut expr.kind); // ignore derives so they remain unused let (attr, after_derive) = self.classify_nonitem(&mut expr); @@ -1052,7 +1052,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { .into_inner() } - if let ast::ExprKind::Mac(mac) = expr.node { + if let ast::ExprKind::Mac(mac) = expr.kind { self.check_attributes(&expr.attrs); self.collect_bang(mac, expr.span, AstFragmentKind::Expr) .make_expr() @@ -1145,7 +1145,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { fn filter_map_expr(&mut self, expr: P) -> Option> { let expr = configure!(self, expr); expr.filter_map(|mut expr| { - self.cfg.configure_expr_kind(&mut expr.node); + self.cfg.configure_expr_kind(&mut expr.kind); // Ignore derives so they remain unused. let (attr, after_derive) = self.classify_nonitem(&mut expr); @@ -1159,7 +1159,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { .map(|expr| expr.into_inner()) } - if let ast::ExprKind::Mac(mac) = expr.node { + if let ast::ExprKind::Mac(mac) = expr.kind { self.check_attributes(&expr.attrs); self.collect_bang(mac, expr.span, AstFragmentKind::OptExpr) .make_opt_expr() @@ -1172,13 +1172,13 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { fn visit_pat(&mut self, pat: &mut P) { self.cfg.configure_pat(pat); - match pat.node { + match pat.kind { PatKind::Mac(_) => {} _ => return noop_visit_pat(pat, self), } visit_clobber(pat, |mut pat| { - match mem::replace(&mut pat.node, PatKind::Wild) { + match mem::replace(&mut pat.kind, PatKind::Wild) { PatKind::Mac(mac) => self.collect_bang(mac, pat.span, AstFragmentKind::Pat).make_pat(), _ => unreachable!(), @@ -1206,7 +1206,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } } - if let StmtKind::Mac(mac) = stmt.node { + if let StmtKind::Mac(mac) = stmt.kind { let (mac, style, attrs) = mac.into_inner(); self.check_attributes(&attrs); let mut placeholder = self.collect_bang(mac, stmt.span, AstFragmentKind::Stmts) @@ -1224,9 +1224,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } // The placeholder expander gives ids to statements, so we avoid folding the id here. - let ast::Stmt { id, node, span } = stmt; - noop_flat_map_stmt_kind(node, self).into_iter().map(|node| { - ast::Stmt { id, node, span } + let ast::Stmt { id, kind, span } = stmt; + noop_flat_map_stmt_kind(kind, self).into_iter().map(|kind| { + ast::Stmt { id, kind, span } }).collect() } @@ -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(), @@ -1318,7 +1318,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { AstFragmentKind::TraitItems, after_derive).make_trait_items() } - match item.node { + match item.kind { ast::TraitItemKind::Macro(mac) => { let ast::TraitItem { attrs, span, .. } = item; self.check_attributes(&attrs); @@ -1337,7 +1337,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { AstFragmentKind::ImplItems, after_derive).make_impl_items(); } - match item.node { + match item.kind { ast::ImplItemKind::Macro(mac) => { let ast::ImplItem { attrs, span, .. } = item; self.check_attributes(&attrs); @@ -1348,13 +1348,13 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } fn visit_ty(&mut self, ty: &mut P) { - match ty.node { + match ty.kind { ast::TyKind::Mac(_) => {} _ => return noop_visit_ty(ty, self), }; visit_clobber(ty, |mut ty| { - match mem::replace(&mut ty.node, ast::TyKind::Err) { + match mem::replace(&mut ty.kind, ast::TyKind::Err) { ast::TyKind::Mac(mac) => self.collect_bang(mac, ty.span, AstFragmentKind::Ty).make_ty(), _ => unreachable!(), @@ -1378,7 +1378,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { .make_foreign_items(); } - if let ast::ForeignItemKind::Macro(mac) = foreign_item.node { + if let ast::ForeignItemKind::Macro(mac) = foreign_item.kind { self.check_attributes(&foreign_item.attrs); return self.collect_bang(mac, foreign_item.span, AstFragmentKind::ForeignItems) .make_foreign_items(); @@ -1504,7 +1504,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { // Check if the user erroneously used `doc(include(...))` syntax. let literal = it.meta_item_list().and_then(|list| { if list.len() == 1 { - list[0].literal().map(|literal| &literal.node) + list[0].literal().map(|literal| &literal.kind) } else { None } @@ -1534,7 +1534,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { id: at.id, style: at.style, path: meta.path, - tokens: meta.node.tokens(meta.span), + tokens: meta.kind.tokens(meta.span), is_sugared_doc: false, }; } else { diff --git a/src/libsyntax/ext/mbe/macro_rules.rs b/src/libsyntax/ext/mbe/macro_rules.rs index c24f6a666039f..aec4a68314120 100644 --- a/src/libsyntax/ext/mbe/macro_rules.rs +++ b/src/libsyntax/ext/mbe/macro_rules.rs @@ -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!(), }; diff --git a/src/libsyntax/ext/placeholders.rs b/src/libsyntax/ext/placeholders.rs index 52a0f95bce7ff..8eecef1020d0a 100644 --- a/src/libsyntax/ext/placeholders.rs +++ b/src/libsyntax/ext/placeholders.rs @@ -30,16 +30,16 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment { let expr_placeholder = || P(ast::Expr { id, span, attrs: ThinVec::new(), - node: ast::ExprKind::Mac(mac_placeholder()), + kind: ast::ExprKind::Mac(mac_placeholder()), }); let ty = P(ast::Ty { id, - node: ast::TyKind::Mac(mac_placeholder()), + kind: ast::TyKind::Mac(mac_placeholder()), span, }); let pat = P(ast::Pat { id, - node: ast::PatKind::Mac(mac_placeholder()), + kind: ast::PatKind::Mac(mac_placeholder()), span, }); @@ -48,34 +48,34 @@ 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 { id, span, ident, attrs, generics, - node: ast::TraitItemKind::Macro(mac_placeholder()), + kind: ast::TraitItemKind::Macro(mac_placeholder()), tokens: None, }]), AstFragmentKind::ImplItems => AstFragment::ImplItems(smallvec![ast::ImplItem { id, span, ident, vis, attrs, generics, - node: ast::ImplItemKind::Macro(mac_placeholder()), + kind: ast::ImplItemKind::Macro(mac_placeholder()), defaultness: ast::Defaultness::Final, tokens: None, }]), AstFragmentKind::ForeignItems => AstFragment::ForeignItems(smallvec![ast::ForeignItem { id, span, ident, vis, attrs, - node: ast::ForeignItemKind::Macro(mac_placeholder()), + kind: ast::ForeignItemKind::Macro(mac_placeholder()), }]), AstFragmentKind::Pat => AstFragment::Pat(P(ast::Pat { - id, span, node: ast::PatKind::Mac(mac_placeholder()), + id, span, kind: ast::PatKind::Mac(mac_placeholder()), })), AstFragmentKind::Ty => AstFragment::Ty(P(ast::Ty { - id, span, node: ast::TyKind::Mac(mac_placeholder()), + id, span, kind: ast::TyKind::Mac(mac_placeholder()), })), AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{ let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ThinVec::new())); - ast::Stmt { id, span, node: ast::StmtKind::Mac(mac) } + ast::Stmt { id, span, kind: ast::StmtKind::Mac(mac) } }]), AstFragmentKind::Arms => AstFragment::Arms(smallvec![ ast::Arm { @@ -251,7 +251,7 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { } fn flat_map_item(&mut self, item: P) -> SmallVec<[P; 1]> { - match item.node { + match item.kind { ast::ItemKind::Mac(_) => return self.remove(item.id).make_items(), ast::ItemKind::MacroDef(_) => return smallvec![item], _ => {} @@ -261,42 +261,42 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { } fn flat_map_trait_item(&mut self, item: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> { - match item.node { + match item.kind { ast::TraitItemKind::Macro(_) => self.remove(item.id).make_trait_items(), _ => noop_flat_map_trait_item(item, self), } } fn flat_map_impl_item(&mut self, item: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> { - match item.node { + match item.kind { ast::ImplItemKind::Macro(_) => self.remove(item.id).make_impl_items(), _ => noop_flat_map_impl_item(item, self), } } fn flat_map_foreign_item(&mut self, item: ast::ForeignItem) -> SmallVec<[ast::ForeignItem; 1]> { - match item.node { + match item.kind { ast::ForeignItemKind::Macro(_) => self.remove(item.id).make_foreign_items(), _ => noop_flat_map_foreign_item(item, self), } } fn visit_expr(&mut self, expr: &mut P) { - match expr.node { + match expr.kind { ast::ExprKind::Mac(_) => *expr = self.remove(expr.id).make_expr(), _ => noop_visit_expr(expr, self), } } fn filter_map_expr(&mut self, expr: P) -> Option> { - match expr.node { + match expr.kind { ast::ExprKind::Mac(_) => self.remove(expr.id).make_opt_expr(), _ => noop_filter_map_expr(expr, self), } } fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> { - let (style, mut stmts) = match stmt.node { + let (style, mut stmts) = match stmt.kind { ast::StmtKind::Mac(mac) => (mac.1, self.remove(stmt.id).make_stmts()), _ => return noop_flat_map_stmt(stmt, self), }; @@ -311,14 +311,14 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { } fn visit_pat(&mut self, pat: &mut P) { - match pat.node { + match pat.kind { ast::PatKind::Mac(_) => *pat = self.remove(pat.id).make_pat(), _ => noop_visit_pat(pat, self), } } fn visit_ty(&mut self, ty: &mut P) { - match ty.node { + match ty.kind { ast::TyKind::Mac(_) => *ty = self.remove(ty.id).make_ty(), _ => noop_visit_ty(ty, self), } @@ -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, }); diff --git a/src/libsyntax/ext/proc_macro.rs b/src/libsyntax/ext/proc_macro.rs index 47b17ced8163e..e17bbf79fd5e0 100644 --- a/src/libsyntax/ext/proc_macro.rs +++ b/src/libsyntax/ext/proc_macro.rs @@ -107,7 +107,7 @@ impl MultiItemModifier for ProcMacroDerive { return Vec::new() } }; - match item.node { + match item.kind { ItemKind::Struct(..) | ItemKind::Enum(..) | ItemKind::Union(..) => {}, diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index b50ca1ad1cf2b..622b48ab9281e 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -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); } @@ -408,7 +408,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_foreign_item(&mut self, i: &'a ast::ForeignItem) { - match i.node { + match i.kind { ast::ForeignItemKind::Fn(..) | ast::ForeignItemKind::Static(..) => { let link_name = attr::first_attr_value_str_by_name(&i.attrs, sym::link_name); @@ -432,7 +432,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_ty(&mut self, ty: &'a ast::Ty) { - match ty.node { + match ty.kind { ast::TyKind::BareFn(ref bare_fn_ty) => { self.check_abi(bare_fn_ty.abi, ty.span); } @@ -447,7 +447,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FunctionRetTy) { if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty { - if let ast::TyKind::Never = output_ty.node { + if let ast::TyKind::Never = output_ty.kind { // Do nothing. } else { self.visit_ty(output_ty) @@ -456,7 +456,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_expr(&mut self, e: &'a ast::Expr) { - match e.node { + match e.kind { ast::ExprKind::Box(_) => { gate_feature_post!(&self, box_syntax, e.span, EXPLAIN_BOX_SYNTAX); } @@ -487,11 +487,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_pat(&mut self, pattern: &'a ast::Pat) { - match &pattern.node { + match &pattern.kind { PatKind::Slice(pats) => { for pat in &*pats { let span = pat.span; - let inner_pat = match &pat.node { + let inner_pat = match &pat.kind { PatKind::Ident(.., Some(pat)) => pat, _ => pat, }; @@ -559,7 +559,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) { - match ti.node { + match ti.kind { ast::TraitItemKind::Method(ref sig, ref block) => { if block.is_none() { self.check_abi(sig.header.abi, ti.span); @@ -600,7 +600,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { "specialization is unstable"); } - match ii.node { + match ii.kind { ast::ImplItemKind::Method(..) => {} ast::ImplItemKind::OpaqueTy(..) => { gate_feature_post!( diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 5a37222ee5590..43b5df38e143c 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -432,9 +432,9 @@ pub fn noop_visit_ty_constraint( } pub fn noop_visit_ty(ty: &mut P, vis: &mut T) { - let Ty { id, node, span } = ty.deref_mut(); + let Ty { id, kind, span } = ty.deref_mut(); vis.visit_id(id); - match node { + match kind { TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err | TyKind::Never | TyKind::CVarArgs => {} TyKind::Slice(ty) => vis.visit_ty(ty), @@ -576,8 +576,8 @@ pub fn noop_visit_meta_list_item(li: &mut NestedMetaItem, vis: &m } pub fn noop_visit_meta_item(mi: &mut MetaItem, vis: &mut T) { - let MetaItem { path: _, node, span } = mi; - match node { + let MetaItem { path: _, kind, span } = mi; + match kind { MetaItemKind::Word => {} MetaItemKind::List(mis) => visit_vec(mis, |mi| vis.visit_meta_list_item(mi)), MetaItemKind::NameValue(_s) => {} @@ -921,12 +921,12 @@ pub fn noop_visit_item_kind(kind: &mut ItemKind, vis: &mut T) { pub fn noop_flat_map_trait_item(mut item: TraitItem, vis: &mut T) -> SmallVec<[TraitItem; 1]> { - let TraitItem { id, ident, attrs, generics, node, span, tokens: _ } = &mut item; + let TraitItem { id, ident, attrs, generics, kind, span, tokens: _ } = &mut item; vis.visit_id(id); vis.visit_ident(ident); visit_attrs(attrs, vis); vis.visit_generics(generics); - match node { + match kind { TraitItemKind::Const(ty, default) => { vis.visit_ty(ty); visit_opt(default, |default| vis.visit_expr(default)); @@ -951,14 +951,14 @@ pub fn noop_flat_map_trait_item(mut item: TraitItem, vis: &mut T) pub fn noop_flat_map_impl_item(mut item: ImplItem, visitor: &mut T) -> SmallVec<[ImplItem; 1]> { - let ImplItem { id, ident, vis, defaultness: _, attrs, generics, node, span, tokens: _ } = + let ImplItem { id, ident, vis, defaultness: _, attrs, generics, kind, span, tokens: _ } = &mut item; visitor.visit_id(id); visitor.visit_ident(ident); visitor.visit_vis(vis); visit_attrs(attrs, visitor); visitor.visit_generics(generics); - match node { + match kind { ImplItemKind::Const(ty, expr) => { visitor.visit_ty(ty); visitor.visit_expr(expr); @@ -994,7 +994,7 @@ pub fn noop_visit_crate(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(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(krate: &mut Crate, vis: &mut T) { // Mutates one item into possibly many items. pub fn noop_flat_map_item(mut item: P, visitor: &mut T) -> SmallVec<[P; 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); @@ -1035,10 +1035,10 @@ pub fn noop_flat_map_item(mut item: P, visitor: &mut T) pub fn noop_flat_map_foreign_item(mut item: ForeignItem, visitor: &mut T) -> SmallVec<[ForeignItem; 1]> { - let ForeignItem { ident, attrs, node, id, span, vis } = &mut item; + let ForeignItem { ident, attrs, kind, id, span, vis } = &mut item; visitor.visit_ident(ident); visit_attrs(attrs, visitor); - match node { + match kind { ForeignItemKind::Fn(fdec, generics) => { visitor.visit_fn_decl(fdec); visitor.visit_generics(generics); @@ -1055,9 +1055,9 @@ pub fn noop_flat_map_foreign_item(mut item: ForeignItem, visitor: } pub fn noop_visit_pat(pat: &mut P, vis: &mut T) { - let Pat { id, node, span } = pat.deref_mut(); + let Pat { id, kind, span } = pat.deref_mut(); vis.visit_id(id); - match node { + match kind { PatKind::Wild | PatKind::Rest => {} PatKind::Ident(_binding_mode, ident, sub) => { vis.visit_ident(ident); @@ -1097,8 +1097,8 @@ pub fn noop_visit_anon_const(AnonConst { id, value }: &mut AnonCo vis.visit_expr(value); } -pub fn noop_visit_expr(Expr { node, id, span, attrs }: &mut Expr, vis: &mut T) { - match node { +pub fn noop_visit_expr(Expr { kind, id, span, attrs }: &mut Expr, vis: &mut T) { + match kind { ExprKind::Box(expr) => vis.visit_expr(expr), ExprKind::Array(exprs) => visit_exprs(exprs, vis), ExprKind::Repeat(expr, count) => { @@ -1247,19 +1247,19 @@ pub fn noop_filter_map_expr(mut e: P, vis: &mut T) -> Optio Some({ vis.visit_expr(&mut e); e }) } -pub fn noop_flat_map_stmt(Stmt { node, mut span, mut id }: Stmt, vis: &mut T) +pub fn noop_flat_map_stmt(Stmt { kind, mut span, mut id }: Stmt, vis: &mut T) -> SmallVec<[Stmt; 1]> { vis.visit_id(&mut id); vis.visit_span(&mut span); - noop_flat_map_stmt_kind(node, vis).into_iter().map(|node| { - Stmt { id, node, span } + noop_flat_map_stmt_kind(kind, vis).into_iter().map(|kind| { + Stmt { id, kind, span } }).collect() } -pub fn noop_flat_map_stmt_kind(node: StmtKind, vis: &mut T) +pub fn noop_flat_map_stmt_kind(kind: StmtKind, vis: &mut T) -> SmallVec<[StmtKind; 1]> { - match node { + match kind { StmtKind::Local(mut local) => smallvec![StmtKind::Local({ vis.visit_local(&mut local); local })], StmtKind::Item(item) => vis.flat_map_item(item).into_iter().map(StmtKind::Item).collect(), diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index cf6151d17b1bd..44688bd36b5fb 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -179,7 +179,7 @@ impl<'a> Parser<'a> { }; Ok(if let Some(meta) = meta { self.bump(); - (meta.path, meta.node.tokens(meta.span)) + (meta.path, meta.kind.tokens(meta.span)) } else { let path = self.parse_path(PathStyle::Mod)?; let tokens = if self.check(&token::OpenDelim(DelimToken::Paren)) || @@ -249,7 +249,7 @@ impl<'a> Parser<'a> { let lit = self.parse_lit()?; debug!("checking if {:?} is unusuffixed", lit); - if !lit.node.is_unsuffixed() { + if !lit.kind.is_unsuffixed() { let msg = "suffixed literals are not allowed in attributes"; self.diagnostic().struct_span_err(lit.span, msg) .help("instead of using a suffixed literal \ @@ -281,9 +281,9 @@ impl<'a> Parser<'a> { let lo = self.token.span; let path = self.parse_path(PathStyle::Mod)?; - let node = self.parse_meta_item_kind()?; + let kind = self.parse_meta_item_kind()?; let span = lo.to(self.prev_span); - Ok(ast::MetaItem { path, node, span }) + Ok(ast::MetaItem { path, kind, span }) } crate fn parse_meta_item_kind(&mut self) -> PResult<'a, ast::MetaItemKind> { diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 6ebfab3a133ef..4456068875019 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -12,7 +12,7 @@ use crate::ast; /// |x| 5 /// isn't parsed as (if true {...} else {...} | x) | 5 pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool { - match e.node { + match e.kind { ast::ExprKind::If(..) | ast::ExprKind::Match(..) | ast::ExprKind::Block(..) | diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index 59de5f1412358..ec5d00e0952d7 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -21,11 +21,11 @@ use std::mem; crate fn dummy_arg(ident: Ident) -> Param { let pat = P(Pat { id: ast::DUMMY_NODE_ID, - node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None), + kind: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None), span: ident.span, }); let ty = Ty { - node: TyKind::Err, + kind: TyKind::Err, span: ident.span, id: ast::DUMMY_NODE_ID }; @@ -135,7 +135,7 @@ impl RecoverQPath for Ty { fn recovered(qself: Option, path: ast::Path) -> Self { Self { span: path.span, - node: TyKind::Path(qself, path), + kind: TyKind::Path(qself, path), id: ast::DUMMY_NODE_ID, } } @@ -148,7 +148,7 @@ impl RecoverQPath for Pat { fn recovered(qself: Option, path: ast::Path) -> Self { Self { span: path.span, - node: PatKind::Path(qself, path), + kind: PatKind::Path(qself, path), id: ast::DUMMY_NODE_ID, } } @@ -161,7 +161,7 @@ impl RecoverQPath for Expr { fn recovered(qself: Option, path: ast::Path) -> Self { Self { span: path.span, - node: ExprKind::Path(qself, path), + kind: ExprKind::Path(qself, path), attrs: ThinVec::new(), id: ast::DUMMY_NODE_ID, } @@ -549,7 +549,7 @@ impl<'a> Parser<'a> { debug_assert!(outer_op.is_comparison(), "check_no_chained_comparison: {:?} is not comparison", outer_op); - match lhs.node { + match lhs.kind { ExprKind::Binary(op, _, _) if op.node.is_comparison() => { // Respan to include both operators. let op_span = op.span.to(self.token.span); @@ -663,7 +663,7 @@ impl<'a> Parser<'a> { pprust::ty_to_string(ty) ); - match ty.node { + match ty.kind { TyKind::Rptr(ref lifetime, ref mut_ty) => { let sum_with_parens = pprust::to_string(|s| { s.s.word("&"); @@ -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"), @@ -915,7 +915,7 @@ impl<'a> Parser<'a> { .unwrap_or_else(|_| pprust::expr_to_string(&expr)); let suggestion = format!("{}.await{}", expr_str, if is_question { "?" } else { "" }); let sp = lo.to(hi); - let app = match expr.node { + let app = match expr.kind { ExprKind::Try(_) => Applicability::MaybeIncorrect, // `await ?` _ => Applicability::MachineApplicable, }; @@ -978,7 +978,7 @@ impl<'a> Parser<'a> { .emit(); // Unwrap `(pat)` into `pat` to avoid the `unused_parens` lint. - pat.and_then(|pat| match pat.node { + pat.and_then(|pat| match pat.kind { PatKind::Paren(pat) => pat, _ => P(pat), }) @@ -1237,7 +1237,7 @@ impl<'a> Parser<'a> { Applicability::HasPlaceholders, ); return Some(ident); - } else if let PatKind::Ident(_, ident, _) = pat.node { + } else if let PatKind::Ident(_, ident, _) = pat.kind { if require_name && ( is_trait_item || self.token == token::Comma || @@ -1283,7 +1283,7 @@ impl<'a> Parser<'a> { // Pretend the pattern is `_`, to avoid duplicate errors from AST validation. let pat = P(Pat { - node: PatKind::Wild, + kind: PatKind::Wild, span: pat.span, id: ast::DUMMY_NODE_ID }); @@ -1296,7 +1296,7 @@ impl<'a> Parser<'a> { is_trait_item: bool, ) -> PResult<'a, ast::Param> { let sp = param.pat.span; - param.ty.node = TyKind::Err; + param.ty.kind = TyKind::Err; let mut err = self.struct_span_err(sp, "unexpected `self` parameter in function"); if is_trait_item { err.span_label(sp, "must be the first associated function parameter"); @@ -1360,7 +1360,7 @@ impl<'a> Parser<'a> { let mut seen_inputs = FxHashSet::default(); for input in fn_inputs.iter_mut() { let opt_ident = if let (PatKind::Ident(_, ident, _), TyKind::Err) = ( - &input.pat.node, &input.ty.node, + &input.pat.kind, &input.ty.kind, ) { Some(*ident) } else { @@ -1368,7 +1368,7 @@ impl<'a> Parser<'a> { }; if let Some(ident) = opt_ident { if seen_inputs.contains(&ident) { - input.pat.node = PatKind::Wild; + input.pat.kind = PatKind::Wild; } seen_inputs.insert(ident); } diff --git a/src/libsyntax/parse/literal.rs b/src/libsyntax/parse/literal.rs index 36233de3cfb57..fcd5b2782fd61 100644 --- a/src/libsyntax/parse/literal.rs +++ b/src/libsyntax/parse/literal.rs @@ -255,7 +255,7 @@ impl LitKind { impl Lit { /// Converts literal token into an AST literal. fn from_lit_token(token: token::Lit, span: Span) -> Result { - Ok(Lit { token, node: LitKind::from_lit_token(token)?, span }) + Ok(Lit { token, kind: LitKind::from_lit_token(token)?, span }) } /// Converts arbitrary token into an AST literal. @@ -267,7 +267,7 @@ impl Lit { lit, token::Interpolated(ref nt) => { if let token::NtExpr(expr) | token::NtLiteral(expr) = &**nt { - if let ast::ExprKind::Lit(lit) = &expr.node { + if let ast::ExprKind::Lit(lit) = &expr.kind { return Ok(lit.clone()); } } @@ -282,8 +282,8 @@ impl Lit { /// Attempts to recover an AST literal from semantic literal. /// This function is used when the original token doesn't exist (e.g. the literal is created /// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing). - pub fn from_lit_kind(node: LitKind, span: Span) -> Lit { - Lit { token: node.to_lit_token(), node, span } + pub fn from_lit_kind(kind: LitKind, span: Span) -> Lit { + Lit { token: kind.to_lit_token(), kind, span } } /// Losslessly convert an AST literal into a token stream. diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b2b6504919e96..cc582819b6b61 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1212,7 +1212,7 @@ impl<'a> Parser<'a> { do_not_enforce_named_arguments_for_c_variadic ) { Ok(param) => { - if let TyKind::CVarArgs = param.ty.node { + if let TyKind::CVarArgs = param.ty.kind { c_variadic = true; if p.token != token::CloseDelim(token::Paren) { let span = p.token.span; diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index d0c865a7b8e83..c776704b285aa 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -210,7 +210,7 @@ impl<'a> Parser<'a> { // it refers to. Interpolated identifiers are unwrapped early and never show up here // as `PrevTokenKind::Interpolated` so if LHS is a single identifier we always process // it as "interpolated", it doesn't change the answer for non-interpolated idents. - let lhs_span = match (self.prev_token_kind, &lhs.node) { + let lhs_span = match (self.prev_token_kind, &lhs.kind) { (PrevTokenKind::Interpolated, _) => self.prev_span, (PrevTokenKind::Ident, &ExprKind::Path(None, ref path)) if path.segments.len() == 1 => self.prev_span, @@ -245,7 +245,7 @@ impl<'a> Parser<'a> { lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Cast)?; continue } else if op == AssocOp::Colon { - let maybe_path = self.could_ascription_be_path(&lhs.node); + let maybe_path = self.could_ascription_be_path(&lhs.kind); self.last_type_ascription = Some((self.prev_span, maybe_path)); lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Type)?; @@ -555,7 +555,7 @@ impl<'a> Parser<'a> { let span_after_type = parser_snapshot_after_type.token.span; let expr = mk_expr(self, P(Ty { span: path.span, - node: TyKind::Path(None, path), + kind: TyKind::Path(None, path), id: DUMMY_NODE_ID, })); @@ -614,7 +614,7 @@ impl<'a> Parser<'a> { expr.map(|mut expr| { attrs.extend::>(expr.attrs.into()); expr.attrs = attrs; - match expr.node { + match expr.kind { ExprKind::If(..) if !expr.attrs.is_empty() => { // Just point to the first attribute in there... let span = expr.attrs[0].span; @@ -1190,7 +1190,7 @@ impl<'a> Parser<'a> { } else { P(Ty { id: DUMMY_NODE_ID, - node: TyKind::Infer, + kind: TyKind::Infer, span: self.prev_span, }) }; @@ -1242,7 +1242,7 @@ impl<'a> Parser<'a> { fn parse_cond_expr(&mut self) -> PResult<'a, P> { let cond = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?; - if let ExprKind::Let(..) = cond.node { + if let ExprKind::Let(..) = cond.kind { // Remove the last feature gating of a `let` expression since it's stable. let last = self.sess.gated_spans.let_chains.borrow_mut().pop(); debug_assert_eq!(cond.span, last.unwrap()); @@ -1779,7 +1779,7 @@ impl<'a> Parser<'a> { Ok(await_expr) } - crate fn mk_expr(&self, span: Span, node: ExprKind, attrs: ThinVec) -> P { - P(Expr { node, span, attrs, id: DUMMY_NODE_ID }) + crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: ThinVec) -> P { + P(Expr { kind, span, attrs, id: DUMMY_NODE_ID }) } } diff --git a/src/libsyntax/parse/parser/item.rs b/src/libsyntax/parse/parser/item.rs index 0d073f0cc97b1..370030d02c717 100644 --- a/src/libsyntax/parse/parser/item.rs +++ b/src/libsyntax/parse/parser/item.rs @@ -678,7 +678,7 @@ impl<'a> Parser<'a> { self.look_ahead(1, |t| t != &token::Lt) { let span = self.prev_span.between(self.token.span); self.struct_span_err(span, "missing trait in a trait impl").emit(); - P(Ty { node: TyKind::Path(None, err_path(span)), span, id: DUMMY_NODE_ID }) + P(Ty { kind: TyKind::Path(None, err_path(span)), span, id: DUMMY_NODE_ID }) } else { self.parse_ty()? }; @@ -715,7 +715,7 @@ impl<'a> Parser<'a> { } let ty_first = ty_first.into_inner(); - let path = match ty_first.node { + let path = match ty_first.kind { // This notably includes paths passed through `ty` macro fragments (#46438). TyKind::Path(None, path) => path, _ => { @@ -783,7 +783,7 @@ impl<'a> Parser<'a> { let lo = self.token.span; let vis = self.parse_visibility(false)?; let defaultness = self.parse_defaultness(); - let (name, node, generics) = if let Some(type_) = self.eat_type() { + let (name, kind, generics) = if let Some(type_) = self.eat_type() { let (name, alias, generics) = type_?; let kind = match alias { AliasKind::Weak(typ) => ast::ImplItemKind::TyAlias(typ), @@ -802,9 +802,9 @@ impl<'a> Parser<'a> { self.expect(&token::Semi)?; (name, ast::ImplItemKind::Const(typ, expr), Generics::default()) } else { - let (name, inner_attrs, generics, node) = self.parse_impl_method(&vis, at_end)?; + let (name, inner_attrs, generics, kind) = self.parse_impl_method(&vis, at_end)?; attrs.extend(inner_attrs); - (name, node, generics) + (name, kind, generics) }; Ok(ImplItem { @@ -815,7 +815,7 @@ impl<'a> Parser<'a> { defaultness, attrs, generics, - node, + kind, tokens: None, }) } @@ -1009,7 +1009,7 @@ impl<'a> Parser<'a> { mut attrs: Vec) -> PResult<'a, TraitItem> { let lo = self.token.span; self.eat_bad_pub(); - let (name, node, generics) = if self.eat_keyword(kw::Type) { + let (name, kind, generics) = if self.eat_keyword(kw::Type) { self.parse_trait_item_assoc_ty()? } else if self.is_const_item() { self.expect_keyword(kw::Const)?; @@ -1094,7 +1094,7 @@ impl<'a> Parser<'a> { ident: name, attrs, generics, - node, + kind, span: lo.to(self.prev_span), tokens: None, }) @@ -1383,7 +1383,7 @@ impl<'a> Parser<'a> { id: DUMMY_NODE_ID, attrs, vis: visibility, - node: ForeignItemKind::Macro(mac), + kind: ForeignItemKind::Macro(mac), } ) } @@ -1415,7 +1415,7 @@ impl<'a> Parser<'a> { Ok(ast::ForeignItem { ident, attrs, - node: ForeignItemKind::Fn(decl, generics), + kind: ForeignItemKind::Fn(decl, generics), id: DUMMY_NODE_ID, span: lo.to(hi), vis, @@ -1435,7 +1435,7 @@ impl<'a> Parser<'a> { Ok(ForeignItem { ident, attrs, - node: ForeignItemKind::Static(ty, mutbl), + kind: ForeignItemKind::Static(ty, mutbl), id: DUMMY_NODE_ID, span: lo.to(hi), vis, @@ -1453,7 +1453,7 @@ impl<'a> Parser<'a> { Ok(ast::ForeignItem { ident, attrs, - node: ForeignItemKind::Ty, + kind: ForeignItemKind::Ty, id: DUMMY_NODE_ID, span: lo.to(hi), vis @@ -1526,7 +1526,7 @@ impl<'a> Parser<'a> { // The user intended that the type be inferred, // so treat this as if the user wrote e.g. `const A: _ = expr;`. P(Ty { - node: TyKind::Infer, + kind: TyKind::Infer, span: id.span, id: ast::DUMMY_NODE_ID, }) @@ -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) -> P { P(Item { ident, attrs, id: DUMMY_NODE_ID, - node, + kind, vis, span, tokens: None, diff --git a/src/libsyntax/parse/parser/pat.rs b/src/libsyntax/parse/parser/pat.rs index 3c624959eadb1..de72f1c4d4906 100644 --- a/src/libsyntax/parse/parser/pat.rs +++ b/src/libsyntax/parse/parser/pat.rs @@ -66,7 +66,7 @@ impl<'a> Parser<'a> { self.recover_leading_vert("not allowed in a parameter pattern"); let pat = self.parse_pat_with_or(PARAM_EXPECTED, GateOr::No, RecoverComma::No)?; - if let PatKind::Or(..) = &pat.node { + if let PatKind::Or(..) = &pat.kind { self.ban_illegal_fn_param_or_pat(&pat); } @@ -324,7 +324,7 @@ impl<'a> Parser<'a> { /// Ban a range pattern if it has an ambiguous interpretation. fn ban_pat_range_if_ambiguous(&self, pat: &Pat) -> PResult<'a, ()> { - match pat.node { + match pat.kind { PatKind::Range( .., Spanned { node: RangeEnd::Included(RangeSyntax::DotDotDot), .. } ) => return Ok(()), @@ -399,12 +399,12 @@ impl<'a> Parser<'a> { // Unwrap; If we don't have `mut $ident`, error. let pat = pat.into_inner(); - match &pat.node { + match &pat.kind { PatKind::Ident(..) => {} _ => self.ban_mut_general_pat(mut_span, &pat, changed_any_binding), } - Ok(pat.node) + Ok(pat.kind) } /// Recover on `mut ref? ident @ pat` and suggest @@ -430,7 +430,7 @@ impl<'a> Parser<'a> { impl MutVisitor for AddMut { fn visit_pat(&mut self, pat: &mut P) { if let PatKind::Ident(BindingMode::ByValue(ref mut m @ Mutability::Immutable), ..) - = pat.node + = pat.kind { *m = Mutability::Mutable; self.0 = true; @@ -890,7 +890,7 @@ impl<'a> Parser<'a> { self.mk_pat(span, PatKind::Ident(bm, ident, None)) } - fn mk_pat(&self, span: Span, node: PatKind) -> P { - P(Pat { node, span, id: ast::DUMMY_NODE_ID }) + fn mk_pat(&self, span: Span, kind: PatKind) -> P { + P(Pat { kind, span, id: ast::DUMMY_NODE_ID }) } } diff --git a/src/libsyntax/parse/parser/path.rs b/src/libsyntax/parse/parser/path.rs index 87839f8c70ee8..463ae9124ca23 100644 --- a/src/libsyntax/parse/parser/path.rs +++ b/src/libsyntax/parse/parser/path.rs @@ -114,7 +114,7 @@ impl<'a> Parser<'a> { pub fn parse_path_allowing_meta(&mut self, style: PathStyle) -> PResult<'a, Path> { let meta_ident = match self.token.kind { token::Interpolated(ref nt) => match **nt { - token::NtMeta(ref meta) => match meta.node { + token::NtMeta(ref meta) => match meta.kind { ast::MetaItemKind::Word => Some(meta.path.clone()), _ => None, }, diff --git a/src/libsyntax/parse/parser/stmt.rs b/src/libsyntax/parse/parser/stmt.rs index 02da56f6e35a7..855b03ddd6f6b 100644 --- a/src/libsyntax/parse/parser/stmt.rs +++ b/src/libsyntax/parse/parser/stmt.rs @@ -44,7 +44,7 @@ impl<'a> Parser<'a> { Ok(Some(if self.eat_keyword(kw::Let) { Stmt { id: DUMMY_NODE_ID, - node: StmtKind::Local(self.parse_local(attrs.into())?), + kind: StmtKind::Local(self.parse_local(attrs.into())?), span: lo.to(self.prev_span), } } else if let Some(macro_def) = self.eat_macro_def( @@ -54,7 +54,7 @@ impl<'a> Parser<'a> { )? { Stmt { id: DUMMY_NODE_ID, - node: StmtKind::Item(macro_def), + kind: StmtKind::Item(macro_def), span: lo.to(self.prev_span), } // Starts like a simple path, being careful to avoid contextual keywords @@ -86,7 +86,7 @@ impl<'a> Parser<'a> { return Ok(Some(Stmt { id: DUMMY_NODE_ID, - node: StmtKind::Expr(expr), + kind: StmtKind::Expr(expr), span: lo.to(self.prev_span), })); } @@ -107,7 +107,7 @@ impl<'a> Parser<'a> { span: lo.to(hi), prior_type_ascription: self.last_type_ascription, }; - let node = if delim == MacDelimiter::Brace || + let kind = if delim == MacDelimiter::Brace || self.token == token::Semi || self.token == token::Eof { StmtKind::Mac(P((mac, style, attrs.into()))) } @@ -137,7 +137,7 @@ impl<'a> Parser<'a> { Stmt { id: DUMMY_NODE_ID, span: lo.to(hi), - node, + kind, } } else { // FIXME: Bad copy of attrs @@ -150,7 +150,7 @@ impl<'a> Parser<'a> { Some(i) => Stmt { id: DUMMY_NODE_ID, span: lo.to(i.span), - node: StmtKind::Item(i), + kind: StmtKind::Item(i), }, None => { let unused_attrs = |attrs: &[Attribute], s: &mut Self| { @@ -180,7 +180,7 @@ impl<'a> Parser<'a> { return Ok(Some(Stmt { id: DUMMY_NODE_ID, span: lo.to(last_semi), - node: StmtKind::Semi(self.mk_expr(lo.to(last_semi), + kind: StmtKind::Semi(self.mk_expr(lo.to(last_semi), ExprKind::Tup(Vec::new()), ThinVec::new() )), @@ -198,7 +198,7 @@ impl<'a> Parser<'a> { Stmt { id: DUMMY_NODE_ID, span: lo.to(e.span), - node: StmtKind::Expr(e), + kind: StmtKind::Expr(e), } } } @@ -400,7 +400,7 @@ impl<'a> Parser<'a> { self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore); Some(Stmt { id: DUMMY_NODE_ID, - node: StmtKind::Expr(DummyResult::raw_expr(self.token.span, true)), + kind: StmtKind::Expr(DummyResult::raw_expr(self.token.span, true)), span: self.token.span, }) } @@ -431,7 +431,7 @@ impl<'a> Parser<'a> { None => return Ok(None), }; - match stmt.node { + match stmt.kind { StmtKind::Expr(ref expr) if self.token != token::Eof => { // expression without semicolon if classify::expr_requires_semi_to_be_stmt(expr) { @@ -443,7 +443,7 @@ impl<'a> Parser<'a> { self.recover_stmt(); // Don't complain about type errors in body tail after parse error (#57383). let sp = expr.span.to(self.prev_span); - stmt.node = StmtKind::Expr(DummyResult::raw_expr(sp, true)); + stmt.kind = StmtKind::Expr(DummyResult::raw_expr(sp, true)); } } } diff --git a/src/libsyntax/parse/parser/ty.rs b/src/libsyntax/parse/parser/ty.rs index 5697edd8e4867..b4c006ca2b119 100644 --- a/src/libsyntax/parse/parser/ty.rs +++ b/src/libsyntax/parse/parser/ty.rs @@ -55,7 +55,7 @@ impl<'a> Parser<'a> { let lo = self.token.span; let mut impl_dyn_multi = false; - let node = if self.eat(&token::OpenDelim(token::Paren)) { + let kind = if self.eat(&token::OpenDelim(token::Paren)) { // `(TYPE)` is a parenthesized type. // `(TYPE,)` is a tuple with a single field of type TYPE. let mut ts = vec![]; @@ -75,7 +75,7 @@ impl<'a> Parser<'a> { if ts.len() == 1 && !last_comma { let ty = ts.into_iter().nth(0).unwrap().into_inner(); let maybe_bounds = allow_plus && self.token.is_like_plus(); - match ty.node { + match ty.kind { // `(TY_BOUND_NOPAREN) + BOUND + ...`. TyKind::Path(None, ref path) if maybe_bounds => { self.parse_remaining_bounds(Vec::new(), path.clone(), lo, true)? @@ -211,7 +211,7 @@ impl<'a> Parser<'a> { }; let span = lo.to(self.prev_span); - let ty = P(Ty { node, span, id: ast::DUMMY_NODE_ID }); + let ty = P(Ty { kind, span, id: ast::DUMMY_NODE_ID }); // Try to recover from use of `+` with incorrect priority. self.maybe_report_ambiguous_plus(allow_plus, impl_dyn_multi, &ty); diff --git a/src/libsyntax/parse/tests.rs b/src/libsyntax/parse/tests.rs index 5cb59b3f82790..3bdb9227b4edd 100644 --- a/src/libsyntax/parse/tests.rs +++ b/src/libsyntax/parse/tests.rs @@ -171,7 +171,7 @@ fn get_spans_of_pat_idents(src: &str) -> Vec { } impl<'a> crate::visit::Visitor<'a> for PatIdentVisitor { fn visit_pat(&mut self, p: &'a ast::Pat) { - match p.node { + match p.kind { PatKind::Ident(_ , ref ident, _) => { self.spans.push(ident.span.clone()); } @@ -272,7 +272,7 @@ fn ttdelim_span() { let expr = parse_expr_from_source_str(PathBuf::from("foo").into(), "foo!( fn main() { body } )".to_string(), &sess).unwrap(); - let tts: Vec<_> = match expr.node { + let tts: Vec<_> = match expr.kind { ast::ExprKind::Mac(ref mac) => mac.stream().trees().collect(), _ => panic!("not a macro"), }; @@ -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!(); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index bf36c0d2f5658..a5792dab4749c 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -662,7 +662,7 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere fn print_meta_item(&mut self, item: &ast::MetaItem) { self.ibox(INDENT_UNIT); - match item.node { + match item.kind { ast::MetaItemKind::Word => self.print_path(&item.path, false, 0), ast::MetaItemKind::NameValue(ref value) => { self.print_path(&item.path, false, 0); @@ -966,7 +966,7 @@ impl<'a> State<'a> { crate fn print_type(&mut self, ty: &ast::Ty) { self.maybe_print_comment(ty.span.lo()); self.ibox(0); - match ty.node { + match ty.kind { ast::TyKind::Slice(ref ty) => { self.s.word("["); self.print_type(ty); @@ -1060,7 +1060,7 @@ impl<'a> State<'a> { self.hardbreak_if_not_bol(); self.maybe_print_comment(item.span.lo()); self.print_outer_attributes(&item.attrs); - match item.node { + match item.kind { ast::ForeignItemKind::Fn(ref decl, ref generics) => { self.head(""); self.print_fn(decl, ast::FnHeader::default(), @@ -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 { @@ -1550,7 +1550,7 @@ impl<'a> State<'a> { self.hardbreak_if_not_bol(); self.maybe_print_comment(ti.span.lo()); self.print_outer_attributes(&ti.attrs); - match ti.node { + match ti.kind { ast::TraitItemKind::Const(ref ty, ref default) => { self.print_associated_const( ti.ident, @@ -1597,7 +1597,7 @@ impl<'a> State<'a> { self.maybe_print_comment(ii.span.lo()); self.print_outer_attributes(&ii.attrs); self.print_defaultness(ii.defaultness); - match ii.node { + match ii.kind { ast::ImplItemKind::Const(ref ty, ref expr) => { self.print_associated_const(ii.ident, ty, Some(expr), &ii.vis); } @@ -1630,7 +1630,7 @@ impl<'a> State<'a> { crate fn print_stmt(&mut self, st: &ast::Stmt) { self.maybe_print_comment(st.span.lo()); - match st.node { + match st.kind { ast::StmtKind::Local(ref loc) => { self.print_outer_attributes(&loc.attrs); self.space_if_not_bol(); @@ -1703,7 +1703,7 @@ impl<'a> State<'a> { self.print_inner_attributes(attrs); for (i, st) in blk.stmts.iter().enumerate() { - match st.node { + match st.kind { ast::StmtKind::Expr(ref expr) if i == blk.stmts.len() - 1 => { self.maybe_print_comment(st.span.lo()); self.space_if_not_bol(); @@ -1734,33 +1734,30 @@ impl<'a> State<'a> { } fn print_else(&mut self, els: Option<&ast::Expr>) { - match els { - Some(_else) => { - match _else.node { - // Another `else if` block. - ast::ExprKind::If(ref i, ref then, ref e) => { - self.cbox(INDENT_UNIT - 1); - self.ibox(0); - self.s.word(" else if "); - self.print_expr_as_cond(i); - self.s.space(); - self.print_block(then); - self.print_else(e.as_ref().map(|e| &**e)) - } - // Final `else` block. - ast::ExprKind::Block(ref b, _) => { - self.cbox(INDENT_UNIT - 1); - self.ibox(0); - self.s.word(" else "); - self.print_block(b) - } - // Constraints would be great here! - _ => { - panic!("print_if saw if with weird alternative"); - } + if let Some(_else) = els { + match _else.kind { + // Another `else if` block. + ast::ExprKind::If(ref i, ref then, ref e) => { + self.cbox(INDENT_UNIT - 1); + self.ibox(0); + self.s.word(" else if "); + self.print_expr_as_cond(i); + self.s.space(); + self.print_block(then); + self.print_else(e.as_ref().map(|e| &**e)) + } + // Final `else` block. + ast::ExprKind::Block(ref b, _) => { + self.cbox(INDENT_UNIT - 1); + self.ibox(0); + self.s.word(" else "); + self.print_block(b) + } + // Constraints would be great here! + _ => { + panic!("print_if saw if with weird alternative"); } } - _ => {} } } @@ -1805,7 +1802,7 @@ impl<'a> State<'a> { /// Does `expr` need parenthesis when printed in a condition position? fn cond_needs_par(expr: &ast::Expr) -> bool { - match expr.node { + match expr.kind { // These cases need parens due to the parse error observed in #26461: `if return {}` // parses as the erroneous construct `if (return {})`, not `if (return) {}`. ast::ExprKind::Closure(..) | @@ -1905,7 +1902,7 @@ impl<'a> State<'a> { func: &ast::Expr, args: &[P]) { let prec = - match func.node { + match func.kind { ast::ExprKind::Field(..) => parser::PREC_FORCE_PAREN, _ => parser::PREC_POSTFIX, }; @@ -1941,7 +1938,7 @@ impl<'a> State<'a> { Fixity::None => (prec + 1, prec + 1), }; - let left_prec = match (&lhs.node, op.node) { + let left_prec = match (&lhs.kind, op.node) { // These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is // the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead // of `(x as i32) < ...`. We need to convince it _not_ to do that. @@ -2000,7 +1997,7 @@ impl<'a> State<'a> { self.ibox(INDENT_UNIT); self.ann.pre(self, AnnNode::Expr(expr)); - match expr.node { + match expr.kind { ast::ExprKind::Box(ref expr) => { self.word_space("box"); self.print_expr_maybe_paren(expr, parser::PREC_PREFIX); @@ -2356,7 +2353,7 @@ impl<'a> State<'a> { self.ann.pre(self, AnnNode::Pat(pat)); /* Pat isn't normalized, but the beauty of it is that it doesn't matter */ - match pat.node { + match pat.kind { PatKind::Wild => self.s.word("_"), PatKind::Ident(binding_mode, ident, ref sub) => { match binding_mode { @@ -2477,7 +2474,7 @@ impl<'a> State<'a> { } self.word_space("=>"); - match arm.body.node { + match arm.body.kind { ast::ExprKind::Block(ref blk, opt_label) => { if let Some(label) = opt_label { self.print_ident(label.ident); @@ -2763,13 +2760,13 @@ impl<'a> State<'a> { self.print_outer_attributes_inline(&input.attrs); - match input.ty.node { + match input.ty.kind { ast::TyKind::Infer if is_closure => self.print_pat(&input.pat), _ => { if let Some(eself) = input.to_self() { self.print_explicit_self(&eself); } else { - let invalid = if let PatKind::Ident(_, ident, _) = input.pat.node { + let invalid = if let PatKind::Ident(_, ident, _) = input.pat.kind { ident.name == kw::Invalid } else { false diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index fceaed360cdb4..982755e868054 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -375,7 +375,7 @@ crate fn needs_par_as_let_scrutinee(order: i8) -> bool { /// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and /// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not. pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool { - match value.node { + match value.kind { ast::ExprKind::Struct(..) => true, ast::ExprKind::Assign(ref lhs, ref rhs) | diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 4fc29d70540fd..a36783e2b642d 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -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); @@ -333,7 +333,7 @@ pub fn walk_field_pattern<'a, V: Visitor<'a>>(visitor: &mut V, fp: &'a FieldPat) } pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) { - match typ.node { + match typ.kind { TyKind::Slice(ref ty) | TyKind::Paren(ref ty) => { visitor.visit_ty(ty) } @@ -443,7 +443,7 @@ pub fn walk_assoc_ty_constraint<'a, V: Visitor<'a>>(visitor: &mut V, } pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) { - match pattern.node { + match pattern.kind { PatKind::TupleStruct(ref path, ref elems) => { visitor.visit_path(path, pattern.id); walk_list!(visitor, visit_pat, elems); @@ -486,7 +486,7 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, foreign_item: &'a visitor.visit_vis(&foreign_item.vis); visitor.visit_ident(foreign_item.ident); - match foreign_item.node { + match foreign_item.kind { ForeignItemKind::Fn(ref function_declaration, ref generics) => { walk_fn_decl(visitor, function_declaration); visitor.visit_generics(generics) @@ -589,7 +589,7 @@ pub fn walk_trait_item<'a, V: Visitor<'a>>(visitor: &mut V, trait_item: &'a Trai visitor.visit_ident(trait_item.ident); walk_list!(visitor, visit_attribute, &trait_item.attrs); visitor.visit_generics(&trait_item.generics); - match trait_item.node { + match trait_item.kind { TraitItemKind::Const(ref ty, ref default) => { visitor.visit_ty(ty); walk_list!(visitor, visit_expr, default); @@ -617,7 +617,7 @@ pub fn walk_impl_item<'a, V: Visitor<'a>>(visitor: &mut V, impl_item: &'a ImplIt visitor.visit_ident(impl_item.ident); walk_list!(visitor, visit_attribute, &impl_item.attrs); visitor.visit_generics(&impl_item.generics); - match impl_item.node { + match impl_item.kind { ImplItemKind::Const(ref ty, ref expr) => { visitor.visit_ty(ty); visitor.visit_expr(expr); @@ -656,7 +656,7 @@ pub fn walk_block<'a, V: Visitor<'a>>(visitor: &mut V, block: &'a Block) { } pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) { - match statement.node { + match statement.kind { StmtKind::Local(ref local) => visitor.visit_local(local), StmtKind::Item(ref item) => visitor.visit_item(item), StmtKind::Expr(ref expression) | StmtKind::Semi(ref expression) => { @@ -683,7 +683,7 @@ pub fn walk_anon_const<'a, V: Visitor<'a>>(visitor: &mut V, constant: &'a AnonCo pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) { walk_list!(visitor, visit_attribute, expression.attrs.iter()); - match expression.node { + match expression.kind { ExprKind::Box(ref subexpression) => { visitor.visit_expr(subexpression) } diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index 75d727b9fb60b..becbf6d60a070 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -61,7 +61,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt<'_>, MacEager::expr(P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::InlineAsm(P(inline_asm)), + kind: ast::ExprKind::InlineAsm(P(inline_asm)), span: cx.with_def_site_ctxt(sp), attrs: ThinVec::new(), })) diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index 16f016036ea5e..790fdad5b3f58 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -18,8 +18,8 @@ pub fn expand_concat( let mut missing_literal = vec![]; let mut has_errors = false; for e in es { - match e.node { - ast::ExprKind::Lit(ref lit) => match lit.node { + match e.kind { + ast::ExprKind::Lit(ref lit) => match lit.kind { ast::LitKind::Str(ref s, _) | ast::LitKind::Float(ref s, _) | ast::LitKind::FloatUnsuffixed(ref s) => { diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index f344706d4ebf5..f6747658c070e 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -47,7 +47,7 @@ pub fn expand_concat_idents<'cx>(cx: &'cx mut ExtCtxt<'_>, fn make_expr(self: Box) -> Option> { Some(P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)), + kind: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)), span: self.ident.span, attrs: ThinVec::new(), })) @@ -56,7 +56,7 @@ pub fn expand_concat_idents<'cx>(cx: &'cx mut ExtCtxt<'_>, fn make_ty(self: Box) -> Option> { Some(P(ast::Ty { id: ast::DUMMY_NODE_ID, - node: ast::TyKind::Path(None, ast::Path::from_ident(self.ident)), + kind: ast::TyKind::Path(None, ast::Path::from_ident(self.ident)), span: self.ident.span, })) } diff --git a/src/libsyntax_ext/deriving/clone.rs b/src/libsyntax_ext/deriving/clone.rs index 9a4c540dc6f1f..9ef2c033b0784 100644 --- a/src/libsyntax_ext/deriving/clone.rs +++ b/src/libsyntax_ext/deriving/clone.rs @@ -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; diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 088b61be8b81b..003c2423576eb 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -131,7 +131,7 @@ fn stmt_let_undescore(cx: &mut ExtCtxt<'_>, sp: Span, expr: P) -> ast }); ast::Stmt { id: ast::DUMMY_NODE_ID, - node: ast::StmtKind::Local(local), + kind: ast::StmtKind::Local(local), span: sp, } } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index fec035d331dc5..9f75f72e820f2 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -355,7 +355,7 @@ fn find_type_parameters( impl<'a, 'b> visit::Visitor<'a> for Visitor<'a, 'b> { fn visit_ty(&mut self, ty: &'a ast::Ty) { - if let ast::TyKind::Path(_, ref path) = ty.node { + if let ast::TyKind::Path(_, ref path) = ty.kind { if let Some(segment) = path.segments.first() { if self.ty_param_names.contains(&segment.ident.name) { self.types.push(P(ty.clone())); @@ -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) @@ -530,7 +530,7 @@ impl<'a> TraitDef<'a> { defaultness: ast::Defaultness::Final, attrs: Vec::new(), generics: Generics::default(), - node: ast::ImplItemKind::TyAlias( + kind: ast::ImplItemKind::TyAlias( type_def.to_ty(cx, self.span, type_ident, generics)), tokens: None, } @@ -612,7 +612,7 @@ impl<'a> TraitDef<'a> { for ty in tys { // if we have already handled this type, skip it - if let ast::TyKind::Path(_, ref p) = ty.node { + if let ast::TyKind::Path(_, ref p) = ty.kind { if p.segments.len() == 1 && ty_param_names.contains(&p.segments[0].ident.name) { continue; @@ -960,7 +960,7 @@ impl<'a> MethodDef<'a> { vis: respan(trait_.span.shrink_to_lo(), ast::VisibilityKind::Inherited), defaultness: ast::Defaultness::Final, ident: method_ident, - node: ast::ImplItemKind::Method(ast::MethodSig { + kind: ast::ImplItemKind::Method(ast::MethodSig { header: ast::FnHeader { unsafety, abi, ..ast::FnHeader::default() @@ -1780,7 +1780,7 @@ pub fn cs_fold1(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()) } diff --git a/src/libsyntax_ext/global_allocator.rs b/src/libsyntax_ext/global_allocator.rs index 19a87e6dc6d74..cd2a9b61a76df 100644 --- a/src/libsyntax_ext/global_allocator.rs +++ b/src/libsyntax_ext/global_allocator.rs @@ -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)), } diff --git a/src/libsyntax_ext/global_asm.rs b/src/libsyntax_ext/global_asm.rs index c56b3f3fc808f..72fb5b47c2154 100644 --- a/src/libsyntax_ext/global_asm.rs +++ b/src/libsyntax_ext/global_asm.rs @@ -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, diff --git a/src/libsyntax_ext/plugin_macro_defs.rs b/src/libsyntax_ext/plugin_macro_defs.rs index ccdc5bd81a04b..315babceae32c 100644 --- a/src/libsyntax_ext/plugin_macro_defs.rs +++ b/src/libsyntax_ext/plugin_macro_defs.rs @@ -28,7 +28,7 @@ fn plugin_macro_def(name: Name, span: Span) -> P { 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, diff --git a/src/libsyntax_ext/proc_macro_harness.rs b/src/libsyntax_ext/proc_macro_harness.rs index f33c813d86cfe..9b53bcb841c67 100644 --- a/src/libsyntax_ext/proc_macro_harness.rs +++ b/src/libsyntax_ext/proc_macro_harness.rs @@ -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, }; diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs index 6c7e3e3eb9875..5d68a92579f96 100644 --- a/src/libsyntax_ext/test.rs +++ b/src/libsyntax_ext/test.rs @@ -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, @@ -285,7 +285,7 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { // type implements the `Termination` trait as `libtest` enforces that. let has_output = match decl.output { ast::FunctionRetTy::Default(..) => false, - ast::FunctionRetTy::Ty(ref t) if t.node.is_unit() => false, + ast::FunctionRetTy::Ty(ref t) if t.kind.is_unit() => false, _ => true }; @@ -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 diff --git a/src/libsyntax_ext/test_harness.rs b/src/libsyntax_ext/test_harness.rs index 56de0c97f81c0..fc1daa7d9b22a 100644 --- a/src/libsyntax_ext/test_harness.rs +++ b/src/libsyntax_ext/test_harness.rs @@ -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 { 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, diff --git a/src/test/ui-fulldeps/ast_stmt_expr_attr.rs b/src/test/ui-fulldeps/ast_stmt_expr_attr.rs index c90fe0014326e..6c5f539b87185 100644 --- a/src/test/ui-fulldeps/ast_stmt_expr_attr.rs +++ b/src/test/ui-fulldeps/ast_stmt_expr_attr.rs @@ -83,7 +83,7 @@ fn check_expr_attrs(es: &str, expected: &[&str]) { fn check_stmt_attrs(es: &str, expected: &[&str]) { let ps = ParseSess::new(FilePathMapping::empty()); let e = stmt(es, &ps).expect("parse error"); - let actual = e.node.attrs(); + let actual = e.kind.attrs(); str_compare(es, &expected.iter().map(|r| attr(r, &ps).unwrap()).collect::>(), actual, diff --git a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs index 596f515da2f7f..784f71a61fd72 100644 --- a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs @@ -48,7 +48,7 @@ fn parse_expr(ps: &ParseSess, src: &str) -> Option> { fn expr(kind: ExprKind) -> P { P(Expr { id: DUMMY_NODE_ID, - node: kind, + kind, span: DUMMY_SP, attrs: ThinVec::new(), }) @@ -154,7 +154,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P)) { 19 => { let pat = P(Pat { id: DUMMY_NODE_ID, - node: PatKind::Wild, + kind: PatKind::Wild, span: DUMMY_SP, }); iter_exprs(depth - 1, &mut |e| g(ExprKind::Let(pat.clone(), e))) @@ -172,7 +172,7 @@ struct RemoveParens; impl MutVisitor for RemoveParens { fn visit_expr(&mut self, e: &mut P) { - match e.node.clone() { + match e.kind.clone() { ExprKind::Paren(inner) => *e = inner, _ => {} }; @@ -190,7 +190,7 @@ impl MutVisitor for AddParens { visit_clobber(e, |e| { P(Expr { id: DUMMY_NODE_ID, - node: ExprKind::Paren(e), + kind: ExprKind::Paren(e), span: DUMMY_SP, attrs: ThinVec::new(), }) diff --git a/src/test/ui/ast-json/ast-json-output.stdout b/src/test/ui/ast-json/ast-json-output.stdout index d23cbe0240ee1..563885133a4c1 100644 --- a/src/test/ui/ast-json/ast-json-output.stdout +++ b/src/test/ui/ast-json/ast-json-output.stdout @@ -1 +1 @@ -{"module":{"inner":{"lo":0,"hi":0},"items":[{"ident":{"name":"core","span":{"lo":0,"hi":0}},"attrs":[],"id":0,"node":{"variant":"ExternCrate","fields":[null]},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"span":{"lo":0,"hi":0},"tokens":[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["extern",false]},"span":{"lo":0,"hi":0}}]},{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["crate",false]},"span":{"lo":0,"hi":0}}]},{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["core",false]},"span":{"lo":0,"hi":0}}]},{"variant":"Token","fields":[{"kind":"Semi","span":{"lo":0,"hi":0}}]}]}],"inline":true},"attrs":[],"span":{"lo":0,"hi":0}} +{"module":{"inner":{"lo":0,"hi":0},"items":[{"ident":{"name":"core","span":{"lo":0,"hi":0}},"attrs":[],"id":0,"kind":{"variant":"ExternCrate","fields":[null]},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"span":{"lo":0,"hi":0},"tokens":[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["extern",false]},"span":{"lo":0,"hi":0}}]},{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["crate",false]},"span":{"lo":0,"hi":0}}]},{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["core",false]},"span":{"lo":0,"hi":0}}]},{"variant":"Token","fields":[{"kind":"Semi","span":{"lo":0,"hi":0}}]}]}],"inline":true},"attrs":[],"span":{"lo":0,"hi":0}}