about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-09-27 10:05:38 +0000
committerbors <bors@rust-lang.org>2019-09-27 10:05:38 +0000
commit590ae0ec4d0c782f7cf97cff7474dc4012c1b615 (patch)
tree6599f55c2c1113952f9a1d369773392252304b6e /src/libsyntax/parse/parser
parent59367b074f1523353dddefa678ffe3cac9fd4e50 (diff)
parent80b63ddca59b16ca503f2f8306e9200102745426 (diff)
downloadrust-590ae0ec4d0c782f7cf97cff7474dc4012c1b615.tar.gz
rust-590ae0ec4d0c782f7cf97cff7474dc4012c1b615.zip
Auto merge of #64813 - varkor:node-to-kind, r=Centril
Rename `*.node` to `*.kind`, and `hair::Pattern*` to `hair::Pat*`

In both `ast::Expr` and `hir::Expr`:

- Rename `Expr.node` to `Expr.kind`.
- Rename `Pat.node` to `Pat.kind`.
- Rename `ImplItem.node` to `ImplItem.kind`.
- Rename `Lit.node` to `Lit.kind`.
- Rename `TraitItem.node` to `TraitItem.kind`.
- Rename `Ty.node` to `Ty.kind`.
- Rename `Stmt.node` to `Stmt.kind`.
- Rename `Item.node` to `Item.kind`.
- Rename `ForeignItem.node` to `ForeignItem.kind`.
- Rename `MetaItem.node` to `MetaItem.kind`.

Also:
- Rename `hair::FieldPattern` to `hair::FieldPat`.
- Rename `hair::PatternKind` to `hair::PatKind`.
- Rename `hair::PatternRange` to `hair::PatRange`.
- Rename `PatternContext` to `PatCtxt`.
- Rename `PatternTypeProjection` to `PatTyProj`.
- Rename `hair::Pattern` to `hair::Pat`.

These two sets of changes are grouped together to aid with merging. The only changes are renamings.

r? @petrochenkov
Diffstat (limited to 'src/libsyntax/parse/parser')
-rw-r--r--src/libsyntax/parse/parser/expr.rs16
-rw-r--r--src/libsyntax/parse/parser/item.rs30
-rw-r--r--src/libsyntax/parse/parser/pat.rs14
-rw-r--r--src/libsyntax/parse/parser/path.rs2
-rw-r--r--src/libsyntax/parse/parser/stmt.rs22
-rw-r--r--src/libsyntax/parse/parser/ty.rs6
6 files changed, 45 insertions, 45 deletions
diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs
index d0c865a7b8e..c776704b285 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::<Vec<_>>(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<Expr>> {
         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<Attribute>) -> P<Expr> {
-        P(Expr { node, span, attrs, id: DUMMY_NODE_ID })
+    crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: ThinVec<Attribute>) -> P<Expr> {
+        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 0d073f0cc97..370030d02c7 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<Attribute>) -> 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<Attribute>) -> P<Item> {
         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 3c624959ead..de72f1c4d49 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<Pat>) {
                 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<Pat> {
-        P(Pat { node, span, id: ast::DUMMY_NODE_ID })
+    fn mk_pat(&self, span: Span, kind: PatKind) -> P<Pat> {
+        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 87839f8c70e..463ae9124ca 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 02da56f6e35..855b03ddd6f 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 5697edd8e48..b4c006ca2b1 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);