diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-08 03:39:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-08 03:39:48 +0100 |
| commit | 0c9f669bde1a0754f83b05e30b802cb58c2fa765 (patch) | |
| tree | 2123edb9d0684545d9d49946291b5560956c5ecd | |
| parent | b8e921b8c8f2a03dc36843f7f31e04be8ee82f29 (diff) | |
| parent | c8850c7144c0414d519cf2d9b2759de30a0fbe79 (diff) | |
| download | rust-0c9f669bde1a0754f83b05e30b802cb58c2fa765.tar.gz rust-0c9f669bde1a0754f83b05e30b802cb58c2fa765.zip | |
Rollup merge of #67114 - Centril:foreign-item-alias, r=petrochenkov
Make `ForeignItem` an alias of `Item`. Working towards the merging of items in AST and syntactically. r? @petrochenkov
| -rw-r--r-- | src/librustc_parse/parser/item.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/mut_visit.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax_expand/placeholders.rs | 1 |
4 files changed, 10 insertions, 14 deletions
diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index c3e5b39635f..34ef12e818c 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -1181,6 +1181,7 @@ impl<'a> Parser<'a> { attrs, vis: visibility, kind: ForeignItemKind::Macro(mac), + tokens: None, } ) } @@ -1211,6 +1212,7 @@ impl<'a> Parser<'a> { id: DUMMY_NODE_ID, span: lo.to(hi), vis, + tokens: None, }) } @@ -1228,7 +1230,8 @@ impl<'a> Parser<'a> { kind: ForeignItemKind::Ty, id: DUMMY_NODE_ID, span: lo.to(hi), - vis + vis, + tokens: None, }) } @@ -1826,6 +1829,7 @@ impl<'a> Parser<'a> { id: DUMMY_NODE_ID, span, vis, + tokens: None, }) } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 75ddf10514d..92ba071a03d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2488,14 +2488,14 @@ impl VariantData { /// /// The name might be a dummy name in case of anonymous items. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub struct Item { +pub struct Item<K = ItemKind> { pub attrs: Vec<Attribute>, pub id: NodeId, pub span: Span, pub vis: Visibility, pub ident: Ident, - pub kind: ItemKind, + pub kind: K, /// Original tokens this item was parsed from. This isn't necessarily /// available for all items, although over time more and more items should @@ -2650,16 +2650,7 @@ impl ItemKind { } } -#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub struct ForeignItem { - pub attrs: Vec<Attribute>, - pub id: NodeId, - pub span: Span, - pub vis: Visibility, - pub ident: Ident, - - pub kind: ForeignItemKind, -} +pub type ForeignItem = Item<ForeignItemKind>; /// An item within an `extern` block. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 8889e5df26c..f8795d885d2 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -1053,7 +1053,7 @@ 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, kind, id, span, vis } = &mut item; + let ForeignItem { ident, attrs, id, kind, vis, span, tokens: _ } = &mut item; visitor.visit_ident(ident); visit_attrs(attrs, visitor); match kind { diff --git a/src/libsyntax_expand/placeholders.rs b/src/libsyntax_expand/placeholders.rs index 74ade1de20e..faea04e691b 100644 --- a/src/libsyntax_expand/placeholders.rs +++ b/src/libsyntax_expand/placeholders.rs @@ -65,6 +65,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId, vis: Option<ast::Visi AstFragment::ForeignItems(smallvec![ast::ForeignItem { id, span, ident, vis, attrs, kind: ast::ForeignItemKind::Macro(mac_placeholder()), + tokens: None, }]), AstFragmentKind::Pat => AstFragment::Pat(P(ast::Pat { id, span, kind: ast::PatKind::Mac(mac_placeholder()), |
