Skip to content

Commit

Permalink
Make ForeignItem an alias of Item.
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Dec 7, 2019
1 parent 41601a8 commit c8850c7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
6 changes: 5 additions & 1 deletion src/librustc_parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ impl<'a> Parser<'a> {
attrs,
vis: visibility,
kind: ForeignItemKind::Macro(mac),
tokens: None,
}
)
}
Expand Down Expand Up @@ -1211,6 +1212,7 @@ impl<'a> Parser<'a> {
id: DUMMY_NODE_ID,
span: lo.to(hi),
vis,
tokens: None,
})
}

Expand All @@ -1228,7 +1230,8 @@ impl<'a> Parser<'a> {
kind: ForeignItemKind::Ty,
id: DUMMY_NODE_ID,
span: lo.to(hi),
vis
vis,
tokens: None,
})
}

Expand Down Expand Up @@ -1826,6 +1829,7 @@ impl<'a> Parser<'a> {
id: DUMMY_NODE_ID,
span,
vis,
tokens: None,
})
}

Expand Down
15 changes: 3 additions & 12 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax_expand/placeholders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit c8850c7

Please sign in to comment.