提交 c8850c71 编写于 作者: M Mazdak Farrokhzad

Make `ForeignItem` an alias of `Item`.

上级 41601a8c
...@@ -1181,6 +1181,7 @@ pub fn parse_foreign_item(&mut self, extern_sp: Span) -> PResult<'a, ForeignItem ...@@ -1181,6 +1181,7 @@ pub fn parse_foreign_item(&mut self, extern_sp: Span) -> PResult<'a, ForeignItem
attrs, attrs,
vis: visibility, vis: visibility,
kind: ForeignItemKind::Macro(mac), kind: ForeignItemKind::Macro(mac),
tokens: None,
} }
) )
} }
...@@ -1211,6 +1212,7 @@ fn parse_item_foreign_static(&mut self, vis: ast::Visibility, lo: Span, attrs: V ...@@ -1211,6 +1212,7 @@ fn parse_item_foreign_static(&mut self, vis: ast::Visibility, lo: Span, attrs: V
id: DUMMY_NODE_ID, id: DUMMY_NODE_ID,
span: lo.to(hi), span: lo.to(hi),
vis, vis,
tokens: None,
}) })
} }
...@@ -1228,7 +1230,8 @@ fn parse_item_foreign_type(&mut self, vis: ast::Visibility, lo: Span, attrs: Vec ...@@ -1228,7 +1230,8 @@ fn parse_item_foreign_type(&mut self, vis: ast::Visibility, lo: Span, attrs: Vec
kind: ForeignItemKind::Ty, kind: ForeignItemKind::Ty,
id: DUMMY_NODE_ID, id: DUMMY_NODE_ID,
span: lo.to(hi), span: lo.to(hi),
vis vis,
tokens: None,
}) })
} }
...@@ -1826,6 +1829,7 @@ fn parse_item_foreign_fn( ...@@ -1826,6 +1829,7 @@ fn parse_item_foreign_fn(
id: DUMMY_NODE_ID, id: DUMMY_NODE_ID,
span, span,
vis, vis,
tokens: None,
}) })
} }
......
...@@ -2488,14 +2488,14 @@ pub fn ctor_id(&self) -> Option<NodeId> { ...@@ -2488,14 +2488,14 @@ pub fn ctor_id(&self) -> Option<NodeId> {
/// ///
/// The name might be a dummy name in case of anonymous items. /// The name might be a dummy name in case of anonymous items.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Item { pub struct Item<K = ItemKind> {
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
pub id: NodeId, pub id: NodeId,
pub span: Span, pub span: Span,
pub vis: Visibility, pub vis: Visibility,
pub ident: Ident, pub ident: Ident,
pub kind: ItemKind, pub kind: K,
/// Original tokens this item was parsed from. This isn't necessarily /// Original tokens this item was parsed from. This isn't necessarily
/// available for all items, although over time more and more items should /// available for all items, although over time more and more items should
...@@ -2650,16 +2650,7 @@ pub fn descriptive_variant(&self) -> &str { ...@@ -2650,16 +2650,7 @@ pub fn descriptive_variant(&self) -> &str {
} }
} }
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub type ForeignItem = Item<ForeignItemKind>;
pub struct ForeignItem {
pub attrs: Vec<Attribute>,
pub id: NodeId,
pub span: Span,
pub vis: Visibility,
pub ident: Ident,
pub kind: ForeignItemKind,
}
/// An item within an `extern` block. /// An item within an `extern` block.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
......
...@@ -1053,7 +1053,7 @@ pub fn noop_flat_map_item<T: MutVisitor>(mut item: P<Item>, visitor: &mut T) ...@@ -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) pub fn noop_flat_map_foreign_item<T: MutVisitor>(mut item: ForeignItem, visitor: &mut T)
-> SmallVec<[ForeignItem; 1]> -> 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); visitor.visit_ident(ident);
visit_attrs(attrs, visitor); visit_attrs(attrs, visitor);
match kind { match kind {
......
...@@ -65,6 +65,7 @@ fn mac_placeholder() -> ast::Mac { ...@@ -65,6 +65,7 @@ fn mac_placeholder() -> ast::Mac {
AstFragment::ForeignItems(smallvec![ast::ForeignItem { AstFragment::ForeignItems(smallvec![ast::ForeignItem {
id, span, ident, vis, attrs, id, span, ident, vis, attrs,
kind: ast::ForeignItemKind::Macro(mac_placeholder()), kind: ast::ForeignItemKind::Macro(mac_placeholder()),
tokens: None,
}]), }]),
AstFragmentKind::Pat => AstFragment::Pat(P(ast::Pat { AstFragmentKind::Pat => AstFragment::Pat(P(ast::Pat {
id, span, kind: ast::PatKind::Mac(mac_placeholder()), 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.
先完成此消息的编辑!
想要评论请 注册