diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 083bc00b34b8..89b27f0b7b36 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -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); diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index b951614511d2..5f2343065f76 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -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); @@ -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,7 +2172,7 @@ 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, @@ -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, }) } @@ -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, }) } diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 5a8d5daaf09b..f98ce418909b 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -1133,7 +1133,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), _ => { diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 4179cf2ff807..815a239405cd 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -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 42a76a721a33..538f181dd331 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -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), } diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index f4ac39921113..a8f460b740c9 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -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)) } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 2657dbfd7adf..1a9166c2988d 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -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)), @@ -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), } diff --git a/src/librustc/hir/pat_util.rs b/src/librustc/hir/pat_util.rs index 118e168f8776..feb0d97822c4 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 d5140141d7e8..81b89b92210a 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -1617,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 { @@ -1710,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, }; @@ -1724,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, }; @@ -1757,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); diff --git a/src/librustc/hir/upvars.rs b/src/librustc/hir/upvars.rs index 3442881e0f4f..5c5f7f612008 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); diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index b31b25d6beed..8a27c5b35c51 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); @@ -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); diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index a30b1214a221..bb17905dd78f 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -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/liveness.rs b/src/librustc/middle/liveness.rs index 6b539ec544d4..162b03c83590 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()); } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index fe28c6d21fc2..c6a46f60927e 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() @@ -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/region.rs b/src/librustc/middle/region.rs index 63e925346d7e..a3c21d8af46c 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -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); } @@ -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, diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 849eed957a84..5dc10dbc54df 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -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(), @@ -1141,7 +1141,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { 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 { diff --git a/src/librustc_ast_borrowck/cfg/construct.rs b/src/librustc_ast_borrowck/cfg/construct.rs index 48d0699c146a..ef35e3615cdc 100644 --- a/src/librustc_ast_borrowck/cfg/construct.rs +++ b/src/librustc_ast_borrowck/cfg/construct.rs @@ -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(..) | diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 875f16241a62..ed31bc9106e2 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -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, @@ -614,7 +614,7 @@ impl EarlyLintPass for AnonymousParameters { match it.node { 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 @@ -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)), }; diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index bb6119d0ff2a..cf67be21c1ad 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -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); } } @@ -412,7 +412,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals { 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/unused.rs b/src/librustc_lint/unused.rs index cd9cebd6c6fb..d13e4ad8a8b0 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -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 @@ -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. diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index c8402018570a..d47a1a7bc895 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1047,7 +1047,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, } diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index c3aed74bcaad..d0dd06f64d16 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, diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 8b80c9d7d673..ff24286c51b7 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -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) { diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index a49955b02df5..822c9318dc39 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -270,7 +270,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> { "refutable pattern in {}: {} not covered", origin, joined_patterns ); - err.span_label(pat.span, match &pat.node { + err.span_label(pat.span, match &pat.kind { 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", @@ -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 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,7 +321,7 @@ 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 { + match pat.kind { PatKind::Binding(.., None) => true, PatKind::Binding(.., Some(ref s)) => pat_is_catchall(s), PatKind::Ref(ref s, _) => pat_is_catchall(s), @@ -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 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,7 +618,7 @@ impl<'v> Visitor<'v> for AtBindingPatternVisitor<'_, '_, '_> { } fn visit_pat(&mut self, pat: &Pat) { - match pat.node { + match pat.kind { PatKind::Binding(.., ref subpat) => { if !self.bindings_allowed { struct_span_err!(self.cx.tcx.sess, pat.span, E0303, diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 435244965f4a..2a8c87396053 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -449,7 +449,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> { let mut ty = self.tables.node_type(pat.hir_id); - let kind = match pat.node { + let kind = match pat.kind { PatKind::Wild => PatternKind::Wild, PatKind::Lit(ref value) => self.lower_lit(value), diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index e6fa833c7b25..853fcb1beabf 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_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 75d6fcf95ad9..2511ee147595 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -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) => @@ -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); } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index a862a7011ef1..39086ec8b9be 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -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(); diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 9f8068fbcf7c..bb73efe0f6f1 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -1134,7 +1134,7 @@ macro_rules! method { impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item, node); method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr, kind); - method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat, node); + method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat, kind); method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty, node); fn visit_item(&mut self, item: &'b Item) { diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index b13b7e2b528e..e5ddf0d340d6 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -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. diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index bddc24f94433..5fd04be77000 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -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); diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index fe5ef3ed3b73..8ce85e01da15 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -640,15 +640,15 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { .. }) | 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 { @@ -659,7 +659,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { } 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_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index a7c307fdf894..d2d3854d2758 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/mod.rs b/src/librustc_typeck/check/mod.rs index 486f4a1d5f67..cef2fdcda2fa 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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 { @@ -4205,7 +4205,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { })) => { 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(), @@ -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(), diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index 77564bf141a1..53ee0777c7c1 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(..) | @@ -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 1ba21651812d..90407780a302 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -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/writeback.rs b/src/librustc_typeck/check/writeback.rs index b22decf6eb9e..de78c1cdfaba 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -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/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index aad1c80c3dc7..b438d1492205 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -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/libsyntax/ast.rs b/src/libsyntax/ast.rs index 966e65fd5e51..8b9bbb6816d7 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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 node = 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`. @@ -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, } @@ -1821,7 +1821,7 @@ 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 { TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))), @@ -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 @@ -1857,7 +1857,7 @@ impl 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, diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 0c3922ee96ec..990358c674ff 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)); } } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 3079382a3b23..6af6027ba9d9 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -511,7 +511,7 @@ impl MacResult for MacEager { return Some(P(ast::Pat { id: ast::DUMMY_NODE_ID, span: e.span, - node: PatKind::Lit(e), + kind: PatKind::Lit(e), })); } } @@ -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, } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 4f61a7e427e2..ff52bd1e971c 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -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) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 3cec7c1e7ecf..c03dd832cb68 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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!(), diff --git a/src/libsyntax/ext/placeholders.rs b/src/libsyntax/ext/placeholders.rs index 827a2f9da323..c2f77b96ad80 100644 --- a/src/libsyntax/ext/placeholders.rs +++ b/src/libsyntax/ext/placeholders.rs @@ -39,7 +39,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment { }); let pat = P(ast::Pat { id, - node: ast::PatKind::Mac(mac_placeholder()), + kind: ast::PatKind::Mac(mac_placeholder()), span, }); @@ -68,7 +68,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment { node: 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()), @@ -311,7 +311,7 @@ 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), } diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index 516f3bb0e9e5..c9a31dc68bff 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -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, }; diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 6b7c574b82fa..b8c5b7497de1 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -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); diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index c73ef982b070..ecc1cdd8bca0 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -21,7 +21,7 @@ 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 { @@ -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, } } @@ -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 }); @@ -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.node, ) { 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/parser/pat.rs b/src/libsyntax/parse/parser/pat.rs index 3c624959eadb..de72f1c4d490 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/tests.rs b/src/libsyntax/parse/tests.rs index 984a2018e7a1..7b7148588501 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()); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d43b77824135..e5060fdd39de 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2353,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 { @@ -2766,7 +2766,7 @@ impl<'a> State<'a> { 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/visit.rs b/src/libsyntax/visit.rs index c91b9f8bc3ae..5b790837f0aa 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -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); diff --git a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs index 7e4fd467e132..745e3695ec1c 100644 --- a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs @@ -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)))