]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/ast.rs
Rename `Ty.node` to `Ty.kind`
[rust.git] / src / libsyntax / ast.rs
index bcbc0a19ce768d5e54ce7f715d8b7f4eaf6e8e32..73751c422f6e09a12ffe5cff701cd33621cba6b6 100644 (file)
@@ -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<P<Ty>> {
-        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 @@ pub(super) fn to_ty(&self) -> Option<P<Ty>> {
         };
 
         Some(P(Ty {
-            node,
+            kind,
             id: self.id,
             span: self.span,
         }))
@@ -569,7 +569,7 @@ pub fn walk(&self, it: &mut impl FnMut(&Pat) -> bool) {
             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 @@ pub fn walk(&self, it: &mut impl FnMut(&Pat) -> bool) {
 
     /// Is this a `..` pattern?
     pub fn is_rest(&self) -> bool {
-        match self.node {
+        match self.kind {
             PatKind::Rest => 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<Attribute>,
 }
@@ -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 {
+        if let ExprKind::Block(ref block, _) = self.kind {
             match block.stmts.last().map(|last_stmt| &last_stmt.node) {
                 // 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 @@ pub fn returns(&self) -> bool {
     }
 
     fn to_bound(&self) -> Option<GenericBound> {
-        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 @@ fn to_bound(&self) -> Option<GenericBound> {
     }
 
     pub(super) fn to_ty(&self) -> Option<P<Ty>> {
-        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 @@ pub(super) fn to_ty(&self) -> Option<P<Ty>> {
         };
 
         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<Attribute>,
     pub generics: Generics,
-    pub node: TraitItemKind,
+    pub kind: TraitItemKind,
     pub span: Span,
     /// See `Item::tokens` for what this is.
     pub tokens: Option<TokenStream>,
@@ -1497,7 +1497,7 @@ pub struct ImplItem {
     pub defaultness: Defaultness,
     pub attrs: Vec<Attribute>,
     pub generics: Generics,
-    pub node: ImplItemKind,
+    pub kind: ImplItemKind,
     pub span: Span,
     /// See `Item::tokens` for what this is.
     pub tokens: Option<TokenStream>,
@@ -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 enum SelfKind {
 
 impl Param {
     pub fn to_self(&self) -> Option<ExplicitSelf> {
-        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 @@ pub fn to_self(&self) -> Option<ExplicitSelf> {
     }
 
     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 @@ pub fn from_self(attrs: ThinVec<Attribute>, eself: ExplicitSelf, eself_ident: Id
         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 @@ pub fn from_self(attrs: ThinVec<Attribute>, eself: ExplicitSelf, eself_ident: Id
                 Mutability::Immutable,
                 P(Ty {
                     id: DUMMY_NODE_ID,
-                    node: TyKind::Rptr(
+                    kind: TyKind::Rptr(
                         lt,
                         MutTy {
                             ty: infer_ty,
@@ -2387,7 +2387,7 @@ pub enum ItemKind {
     ),
     /// A macro invocation.
     ///
-    /// E.g., `macro_rules! foo { .. }` or `foo!(..)`.
+    /// E.g., `foo!(..)`.
     Mac(Mac),
 
     /// A macro definition.