提交 0bcb3bc5 编写于 作者: P Patrick Walton

libsyntax: Parse visibility modifiers before foreign items

上级 7e7411e6
......@@ -1485,7 +1485,8 @@ impl class_mutability : cmp::Eq {
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 @@ fn parse_item_mod() -> item_info {
(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 @@ fn parse_item_foreign_fn(+attrs: ~[attribute]) -> @foreign_item {
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 @@ fn parse_item_foreign_const(+attrs: ~[attribute]) -> @foreign_item {
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 @@ fn parse_fn_purity() -> purity {
}
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)
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册