未验证 提交 0c9f669b 编写于 作者: M Mazdak Farrokhzad 提交者: GitHub

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
......@@ -1181,6 +1181,7 @@ pub fn parse_foreign_item(&mut self, extern_sp: Span) -> PResult<'a, ForeignItem
attrs,
vis: visibility,
kind: ForeignItemKind::Macro(mac),
tokens: None,
}
)
}
......@@ -1211,6 +1212,7 @@ fn parse_item_foreign_static(&mut self, vis: ast::Visibility, lo: Span, attrs: V
id: DUMMY_NODE_ID,
span: lo.to(hi),
vis,
tokens: None,
})
}
......@@ -1228,7 +1230,8 @@ fn parse_item_foreign_type(&mut self, vis: ast::Visibility, lo: Span, attrs: Vec
kind: ForeignItemKind::Ty,
id: DUMMY_NODE_ID,
span: lo.to(hi),
vis
vis,
tokens: None,
})
}
......@@ -1826,6 +1829,7 @@ fn parse_item_foreign_fn(
id: DUMMY_NODE_ID,
span,
vis,
tokens: None,
})
}
......
......@@ -2488,14 +2488,14 @@ pub fn ctor_id(&self) -> Option<NodeId> {
///
/// 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 @@ pub fn descriptive_variant(&self) -> &str {
}
}
#[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)]
......
......@@ -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 {
......
......@@ -65,6 +65,7 @@ fn mac_placeholder() -> ast::Mac {
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()),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册