libsyntax: Parse visibility modifiers before foreign items
This commit is contained in:
parent
7e7411e620
commit
0bcb3bc536
3 changed files with 15 additions and 8 deletions
|
|
@ -1485,7 +1485,8 @@ type foreign_item =
|
|||
attrs: ~[attribute],
|
||||
node: foreign_item_,
|
||||
id: node_id,
|
||||
span: span};
|
||||
span: span,
|
||||
vis: visibility};
|
||||
|
||||
#[auto_serialize]
|
||||
enum foreign_item_ {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,8 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold)
|
|||
}
|
||||
},
|
||||
id: fld.new_id(ni.id),
|
||||
span: fld.new_span(ni.span)};
|
||||
span: fld.new_span(ni.span),
|
||||
vis: ni.vis};
|
||||
}
|
||||
|
||||
fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> {
|
||||
|
|
|
|||
|
|
@ -2940,7 +2940,8 @@ impl parser {
|
|||
(id, item_mod(m), Some(inner_attrs.inner))
|
||||
}
|
||||
|
||||
fn parse_item_foreign_fn(+attrs: ~[attribute]) -> @foreign_item {
|
||||
fn parse_item_foreign_fn(vis: ast::visibility,
|
||||
+attrs: ~[attribute]) -> @foreign_item {
|
||||
let lo = self.span.lo;
|
||||
let purity = self.parse_fn_purity();
|
||||
let t = self.parse_fn_header();
|
||||
|
|
@ -2951,10 +2952,12 @@ impl parser {
|
|||
attrs: attrs,
|
||||
node: foreign_item_fn(decl, purity, t.tps),
|
||||
id: self.get_id(),
|
||||
span: mk_sp(lo, hi)};
|
||||
span: mk_sp(lo, hi),
|
||||
vis: vis};
|
||||
}
|
||||
|
||||
fn parse_item_foreign_const(+attrs: ~[attribute]) -> @foreign_item {
|
||||
fn parse_item_foreign_const(vis: ast::visibility,
|
||||
+attrs: ~[attribute]) -> @foreign_item {
|
||||
let lo = self.span.lo;
|
||||
self.expect_keyword(~"const");
|
||||
let ident = self.parse_ident();
|
||||
|
|
@ -2966,7 +2969,8 @@ impl parser {
|
|||
attrs: attrs,
|
||||
node: foreign_item_const(move ty),
|
||||
id: self.get_id(),
|
||||
span: mk_sp(lo, hi)};
|
||||
span: mk_sp(lo, hi),
|
||||
vis: vis};
|
||||
}
|
||||
|
||||
fn parse_fn_purity() -> purity {
|
||||
|
|
@ -2982,10 +2986,11 @@ impl parser {
|
|||
}
|
||||
|
||||
fn parse_foreign_item(+attrs: ~[attribute]) -> @foreign_item {
|
||||
let vis = self.parse_visibility();
|
||||
if self.is_keyword(~"const") {
|
||||
self.parse_item_foreign_const(move attrs)
|
||||
self.parse_item_foreign_const(vis, move attrs)
|
||||
} else {
|
||||
self.parse_item_foreign_fn(move attrs)
|
||||
self.parse_item_foreign_fn(vis, move attrs)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue