Skip to content

Commit c8850c7

Browse files
committed
Make ForeignItem an alias of Item.
1 parent 41601a8 commit c8850c7

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

src/librustc_parse/parser/item.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,7 @@ impl<'a> Parser<'a> {
11811181
attrs,
11821182
vis: visibility,
11831183
kind: ForeignItemKind::Macro(mac),
1184+
tokens: None,
11841185
}
11851186
)
11861187
}
@@ -1211,6 +1212,7 @@ impl<'a> Parser<'a> {
12111212
id: DUMMY_NODE_ID,
12121213
span: lo.to(hi),
12131214
vis,
1215+
tokens: None,
12141216
})
12151217
}
12161218

@@ -1228,7 +1230,8 @@ impl<'a> Parser<'a> {
12281230
kind: ForeignItemKind::Ty,
12291231
id: DUMMY_NODE_ID,
12301232
span: lo.to(hi),
1231-
vis
1233+
vis,
1234+
tokens: None,
12321235
})
12331236
}
12341237

@@ -1826,6 +1829,7 @@ impl<'a> Parser<'a> {
18261829
id: DUMMY_NODE_ID,
18271830
span,
18281831
vis,
1832+
tokens: None,
18291833
})
18301834
}
18311835

src/libsyntax/ast.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -2488,14 +2488,14 @@ impl VariantData {
24882488
///
24892489
/// The name might be a dummy name in case of anonymous items.
24902490
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
2491-
pub struct Item {
2491+
pub struct Item<K = ItemKind> {
24922492
pub attrs: Vec<Attribute>,
24932493
pub id: NodeId,
24942494
pub span: Span,
24952495
pub vis: Visibility,
24962496
pub ident: Ident,
24972497

2498-
pub kind: ItemKind,
2498+
pub kind: K,
24992499

25002500
/// Original tokens this item was parsed from. This isn't necessarily
25012501
/// available for all items, although over time more and more items should
@@ -2650,16 +2650,7 @@ impl ItemKind {
26502650
}
26512651
}
26522652

2653-
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
2654-
pub struct ForeignItem {
2655-
pub attrs: Vec<Attribute>,
2656-
pub id: NodeId,
2657-
pub span: Span,
2658-
pub vis: Visibility,
2659-
pub ident: Ident,
2660-
2661-
pub kind: ForeignItemKind,
2662-
}
2653+
pub type ForeignItem = Item<ForeignItemKind>;
26632654

26642655
/// An item within an `extern` block.
26652656
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]

src/libsyntax/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ pub fn noop_flat_map_item<T: MutVisitor>(mut item: P<Item>, visitor: &mut T)
10531053
pub fn noop_flat_map_foreign_item<T: MutVisitor>(mut item: ForeignItem, visitor: &mut T)
10541054
-> SmallVec<[ForeignItem; 1]>
10551055
{
1056-
let ForeignItem { ident, attrs, kind, id, span, vis } = &mut item;
1056+
let ForeignItem { ident, attrs, id, kind, vis, span, tokens: _ } = &mut item;
10571057
visitor.visit_ident(ident);
10581058
visit_attrs(attrs, visitor);
10591059
match kind {

src/libsyntax_expand/placeholders.rs

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId, vis: Option<ast::Visi
6565
AstFragment::ForeignItems(smallvec![ast::ForeignItem {
6666
id, span, ident, vis, attrs,
6767
kind: ast::ForeignItemKind::Macro(mac_placeholder()),
68+
tokens: None,
6869
}]),
6970
AstFragmentKind::Pat => AstFragment::Pat(P(ast::Pat {
7071
id, span, kind: ast::PatKind::Mac(mac_placeholder()),

0 commit comments

Comments
 (0)