Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ForeignItem an alias of Item. #67114

Merged
merged 1 commit into from
Dec 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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