diff options
| author | bors <bors@rust-lang.org> | 2019-09-27 10:05:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-09-27 10:05:38 +0000 |
| commit | 590ae0ec4d0c782f7cf97cff7474dc4012c1b615 (patch) | |
| tree | 6599f55c2c1113952f9a1d369773392252304b6e /src/libsyntax | |
| parent | 59367b074f1523353dddefa678ffe3cac9fd4e50 (diff) | |
| parent | 80b63ddca59b16ca503f2f8306e9200102745426 (diff) | |
| download | rust-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')
28 files changed, 295 insertions, 298 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b634dcca7fc..a7f035dc9ec 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<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 @@ 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<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 { - 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<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 @@ impl Expr { } 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 @@ 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<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 type ExplicitSelf = Spanned<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 @@ 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<Attribute>, 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<Attribute>, - 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 b5037b75f79..2a8e6b2cc95 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<Symbol>| { 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<F>(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<ReprAttr> { 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<ReprAttr> { } 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 9d06b926f97..122cb7fb12b 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<Vec<NestedMetaItem>> { 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<Symbol> { - 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<NestedMetaItem>) -> 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<F: FnOnce(&mut Vec<ast::Attribute>)>(&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 7eeea4e7bdf..990358c674f 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<ast::Pat>) { - 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<ast::Expr>) { 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<ast::Expr>) -> Option<P<ast::Expr>> { 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 0b6cf30bd27..34b5b1e5b5c 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 aa76667c2e9..54cfb80573e 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<ast::Expr> { 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<ast::Ty> { 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<DummyResult>) -> Option<SmallVec<[ast::Stmt; 1]>> { 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 f903b66e296..6b93d045588 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<ast::Ty> { + pub fn ty(&self, span: Span, kind: ast::TyKind) -> P<ast::Ty> { 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::Item>) -> 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<ast::Stmt>) -> P<ast::Block> { @@ -239,10 +239,10 @@ impl<'a> ExtCtxt<'a> { }) } - pub fn expr(&self, span: Span, node: ast::ExprKind) -> P<ast::Expr> { + pub fn expr(&self, span: Span, kind: ast::ExprKind) -> P<ast::Expr> { 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<ast::Pat> { - P(ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span }) + pub fn pat(&self, span: Span, kind: PatKind) -> P<ast::Pat> { + P(ast::Pat { id: ast::DUMMY_NODE_ID, kind, span }) } pub fn pat_wild(&self, span: Span) -> P<ast::Pat> { self.pat(span, PatKind::Wild) @@ -567,14 +567,14 @@ impl<'a> ExtCtxt<'a> { } pub fn item(&self, span: Span, name: Ident, - attrs: Vec<ast::Attribute>, node: ast::ItemKind) -> P<ast::Item> { + attrs: Vec<ast::Attribute>, kind: ast::ItemKind) -> P<ast::Item> { // FIXME: Would be nice if our generated code didn't violate // Rust coding conventions P(ast::Item { ident: name, attrs, id: ast::DUMMY_NODE_ID, - node, + kind, vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited), span, tokens: None, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index c8078d2bb71..02e7c6775a4 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<ast::Expr>) { 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<ast::Expr>) -> Option<P<ast::Expr>> { 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<ast::Pat>) { 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<ast::Ty>) { - 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 c24f6a66603..aec4a683141 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 52a0f95bce7..8eecef1020d 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<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> { - match item.node { + match item.kind { ast::ItemKind::Mac(_) => return self.remove(item.id).make_items(), ast::ItemKind::MacroDef(_) => return smallvec![item], _ => {} @@ -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<ast::Expr>) { - 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<ast::Expr>) -> Option<P<ast::Expr>> { - 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<ast::Pat>) { - 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<ast::Ty>) { - 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 47b17ced816..e17bbf79fd5 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 b50ca1ad1cf..622b48ab928 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 5a37222ee55..43b5df38e14 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -432,9 +432,9 @@ pub fn noop_visit_ty_constraint<T: MutVisitor>( } pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, 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<T: MutVisitor>(li: &mut NestedMetaItem, vis: &m } pub fn noop_visit_meta_item<T: MutVisitor>(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<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) { pub fn noop_flat_map_trait_item<T: MutVisitor>(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<T: MutVisitor>(mut item: TraitItem, vis: &mut T) pub fn noop_flat_map_impl_item<T: MutVisitor>(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<T: MutVisitor>(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<T: MutVisitor>(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<T: MutVisitor>(krate: &mut Crate, vis: &mut T) { // Mutates one item into possibly many items. pub fn noop_flat_map_item<T: MutVisitor>(mut item: P<Item>, visitor: &mut T) -> SmallVec<[P<Item>; 1]> { - let Item { ident, attrs, id, node, vis, span, tokens: _ } = item.deref_mut(); + let Item { ident, attrs, id, kind, vis, span, tokens: _ } = item.deref_mut(); visitor.visit_ident(ident); visit_attrs(attrs, visitor); visitor.visit_id(id); - visitor.visit_item_kind(node); + visitor.visit_item_kind(kind); visitor.visit_vis(vis); visitor.visit_span(span); @@ -1035,10 +1035,10 @@ pub fn noop_flat_map_item<T: MutVisitor>(mut item: P<Item>, visitor: &mut T) pub fn noop_flat_map_foreign_item<T: MutVisitor>(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<T: MutVisitor>(mut item: ForeignItem, visitor: } pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, 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<T: MutVisitor>(AnonConst { id, value }: &mut AnonCo vis.visit_expr(value); } -pub fn noop_visit_expr<T: MutVisitor>(Expr { node, id, span, attrs }: &mut Expr, vis: &mut T) { - match node { +pub fn noop_visit_expr<T: MutVisitor>(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<T: MutVisitor>(mut e: P<Expr>, vis: &mut T) -> Optio Some({ vis.visit_expr(&mut e); e }) } -pub fn noop_flat_map_stmt<T: MutVisitor>(Stmt { node, mut span, mut id }: Stmt, vis: &mut T) +pub fn noop_flat_map_stmt<T: MutVisitor>(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<T: MutVisitor>(node: StmtKind, vis: &mut T) +pub fn noop_flat_map_stmt_kind<T: MutVisitor>(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 cf6151d17b1..44688bd36b5 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 6ebfab3a133..44560688750 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 59de5f14123..ec5d00e0952 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<QSelf>, 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<QSelf>, 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<QSelf>, 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 <expr>?` _ => 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 36233de3cfb..fcd5b2782fd 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<Lit, LitError> { - 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 b2b6504919e..cc582819b6b 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 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); diff --git a/src/libsyntax/parse/tests.rs b/src/libsyntax/parse/tests.rs index 5cb59b3f827..3bdb9227b4e 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<Span> { } 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 bf36c0d2f56..a5792dab474 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -662,7 +662,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + 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<ast::Expr>]) { 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 fceaed360cd..982755e8680 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 4fc29d70540..a36783e2b64 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) } |
