Skip to content

Commit 2985b8e

Browse files
committed
* Parsing sequence changed
1- visibility parse 2- purity parse
1 parent 42c05fe commit 2985b8e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,11 @@ impl Parser {
333333
let is_static = p.parse_staticness();
334334
let static_sty = spanned(lo, p.span.hi, sty_static);
335335

336+
let vis = p.parse_visibility();
336337
let pur = p.parse_fn_purity();
337338
// NB: at the moment, trait methods are public by default; this
338339
// could change.
339-
let vis = p.parse_visibility();
340+
340341
let ident = p.parse_method_name();
341342

342343
let tps = p.parse_ty_params();
@@ -2528,13 +2529,14 @@ impl Parser {
25282529
self.parse_value_ident()
25292530
}
25302531

2531-
fn parse_method(pr: visibility) -> @method {
2532+
fn parse_method() -> @method {
25322533
let attrs = self.parse_outer_attributes();
25332534
let lo = self.span.lo;
25342535

25352536
let is_static = self.parse_staticness();
25362537
let static_sty = spanned(lo, self.span.hi, sty_static);
2537-
2538+
2539+
let visa = self.parse_visibility();
25382540
let pur = self.parse_fn_purity();
25392541
let ident = self.parse_method_name();
25402542
let tps = self.parse_ty_params();
@@ -2549,7 +2551,7 @@ impl Parser {
25492551
@{ident: ident, attrs: attrs,
25502552
tps: tps, self_ty: self_ty, purity: pur, decl: decl,
25512553
body: body, id: self.get_id(), span: mk_sp(lo, body.span.hi),
2552-
self_id: self.get_id(), vis: pr}
2554+
self_id: self.get_id(), vis: visa}
25532555
}
25542556

25552557
fn parse_item_trait() -> item_info {
@@ -2606,8 +2608,7 @@ impl Parser {
26062608
let mut meths = ~[];
26072609
self.expect(token::LBRACE);
26082610
while !self.eat(token::RBRACE) {
2609-
let vis = self.parse_visibility();
2610-
meths.push(self.parse_method(vis));
2611+
meths.push(self.parse_method());
26112612
}
26122613
(ident, item_impl(tps, opt_trait, ty, meths), None)
26132614
}
@@ -2763,7 +2764,7 @@ impl Parser {
27632764
return a_var;
27642765
} else {
27652766
self.obsolete(copy self.span, ObsoleteClassMethod);
2766-
return @method_member(self.parse_method(vis));
2767+
return @method_member(self.parse_method());
27672768
}
27682769
}
27692770

@@ -2869,9 +2870,9 @@ impl Parser {
28692870
(id, item_mod(m), Some(inner_attrs.inner))
28702871
}
28712872

2872-
fn parse_item_foreign_fn(vis: ast::visibility,
2873-
+attrs: ~[attribute]) -> @foreign_item {
2873+
fn parse_item_foreign_fn( +attrs: ~[attribute]) -> @foreign_item {
28742874
let lo = self.span.lo;
2875+
let vis = self.parse_visibility();
28752876
let purity = self.parse_fn_purity();
28762877
let t = self.parse_fn_header();
28772878
let (decl, _) = self.parse_fn_decl(|p| p.parse_arg());
@@ -2919,7 +2920,7 @@ impl Parser {
29192920
if self.is_keyword(~"const") {
29202921
self.parse_item_foreign_const(vis, move attrs)
29212922
} else {
2922-
self.parse_item_foreign_fn(vis, move attrs)
2923+
self.parse_item_foreign_fn( move attrs)
29232924
}
29242925
}
29252926

@@ -3239,7 +3240,7 @@ impl Parser {
32393240
maybe_append(attrs, extra_attrs)));
32403241
} else if foreign_items_allowed &&
32413242
(self.is_keyword(~"fn") || self.is_keyword(~"pure")) {
3242-
let item = self.parse_item_foreign_fn(visibility, attrs);
3243+
let item = self.parse_item_foreign_fn(attrs);
32433244
return iovi_foreign_item(item);
32443245
} else if items_allowed && self.is_keyword(~"unsafe")
32453246
&& self.look_ahead(1u) != token::LBRACE {

0 commit comments

Comments
 (0)