Skip to content

Commit a4ac584

Browse files
committed
---
yaml --- r: 22516 b: refs/heads/master c: 78d11b8 h: refs/heads/master v: v3
1 parent 98e8628 commit a4ac584

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5a63b2100ed69b14e929671430101cc786f41ea7
2+
refs/heads/master: 78d11b899b6ec4d2ed8c18499c1213fecd3c6424
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libsyntax/parse/parser.rs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -279,41 +279,46 @@ class parser {
279279
do self.parse_unspanned_seq(token::LBRACE, token::RBRACE,
280280
seq_sep_none()) |p| {
281281
let attrs = p.parse_outer_attributes();
282-
let flo = p.span.lo;
282+
let lo = p.span.lo;
283283
let pur = p.parse_fn_purity();
284+
// NB: at the moment, trait methods are public by default; this
285+
// could change.
286+
let vis = p.parse_visibility(public);
284287
let ident = p.parse_method_name();
285288
let tps = p.parse_ty_params();
286-
let d = p.parse_ty_fn_decl(pur), fhi = p.last_span.hi;
287-
#debug["parse_trait_methods(): trait method ends in %s",
288-
token_to_str(self.reader, self.token)];
289-
alt self.token {
289+
let d = p.parse_ty_fn_decl(pur);
290+
let hi = p.last_span.hi;
291+
#debug["parse_trait_methods(): trait method signature ends in \
292+
`%s`",
293+
token_to_str(p.reader, p.token)];
294+
alt p.token {
290295
token::SEMI {
291-
self.bump();
296+
p.bump();
297+
#debug["parse_trait_methods(): parsing required method"];
298+
// NB: at the moment, visibility annotations on required
299+
// methods are ignored; this could change.
292300
required({ident: ident, attrs: attrs,
293301
decl: {purity: pur with d}, tps: tps,
294-
span: mk_sp(flo, fhi)})
302+
span: mk_sp(lo, hi)})
295303
}
296304
token::LBRACE {
297-
self.bump();
305+
#debug["parse_trait_methods(): parsing provided method"];
298306
let (inner_attrs, body) =
299-
self.parse_inner_attrs_and_block(true);
307+
p.parse_inner_attrs_and_block(true);
300308
let attrs = vec::append(attrs, inner_attrs);
301-
self.eat(token::RBRACE);
302309
provided(@{ident: ident,
303310
attrs: attrs,
304311
tps: tps,
305312
decl: d,
306313
body: body,
307-
id: self.get_id(),
308-
span: mk_sp(flo, fhi),
309-
self_id: self.get_id(),
310-
// Provided traits methods always public for now
311-
vis: public})
314+
id: p.get_id(),
315+
span: mk_sp(lo, hi),
316+
self_id: p.get_id(),
317+
vis: vis})
312318
}
313319
314-
_ { self.fatal("expected `;` or `}` \
315-
but found `"
316-
+ token_to_str(self.reader, self.token) + "`");
320+
_ { p.fatal("expected `;` or `}` but found `" +
321+
token_to_str(p.reader, p.token) + "`");
317322
}
318323
}
319324
}

0 commit comments

Comments
 (0)