Skip to content

Commit b9169a4

Browse files
committed
---
yaml --- r: 140160 b: refs/heads/try2 c: 2733a1f h: refs/heads/master v: v3
1 parent 8831bdf commit b9169a4

File tree

2 files changed

+20
-33
lines changed

2 files changed

+20
-33
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: ab03c1e42218a08f6051e5708e6a538d3db9f1f3
8+
refs/heads/try2: 2733a1f14b6602f97d225ee8794db46d5d5e9efe
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libsyntax/parse/parser.rs

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ pub impl Parser {
520520
token::LBRACE => {
521521
debug!("parse_trait_methods(): parsing provided method");
522522
let (inner_attrs, body) =
523-
p.parse_inner_attrs_and_block(true);
523+
p.parse_inner_attrs_and_block();
524524
let attrs = vec::append(attrs, inner_attrs);
525525
provided(@ast::method {
526526
ident: ident,
@@ -1975,7 +1975,7 @@ pub impl Parser {
19751975
fn parse_while_expr(&self) -> @expr {
19761976
let lo = self.last_span.lo;
19771977
let cond = self.parse_expr();
1978-
let body = self.parse_block_no_value();
1978+
let body = self.parse_block();
19791979
let hi = body.span.hi;
19801980
return self.mk_expr(lo, hi, expr_while(cond, body));
19811981
}
@@ -2003,7 +2003,7 @@ pub impl Parser {
20032003
}
20042004

20052005
let lo = self.last_span.lo;
2006-
let body = self.parse_block_no_value();
2006+
let body = self.parse_block();
20072007
let hi = body.span.hi;
20082008
return self.mk_expr(lo, hi, expr_loop(body, opt_ident));
20092009
} else {
@@ -2581,47 +2581,35 @@ pub impl Parser {
25812581
!classify::expr_requires_semi_to_be_stmt(e);
25822582
}
25832583

2584+
// parse a block. No inner attrs are allowed.
25842585
fn parse_block(&self) -> blk {
2585-
// disallow inner attrs:
2586-
let (attrs, blk) = self.parse_inner_attrs_and_block(false);
2587-
assert!(vec::is_empty(attrs));
2588-
return blk;
2586+
maybe_whole!(self, nt_block);
2587+
2588+
let lo = self.span.lo;
2589+
if self.eat_keyword(&~"unsafe") {
2590+
self.obsolete(copy *self.span, ObsoleteUnsafeBlock);
2591+
}
2592+
self.expect(&token::LBRACE);
2593+
2594+
return self.parse_block_tail_(lo, default_blk, ~[]);
25892595
}
25902596

2591-
// I claim the existence of the 'parse_attrs' flag strongly
2592-
// suggests a name-change or refactoring for this function.
2593-
fn parse_inner_attrs_and_block(&self, parse_attrs: bool)
2597+
// parse a block. Inner attrs are allowed.
2598+
fn parse_inner_attrs_and_block(&self)
25942599
-> (~[attribute], blk) {
25952600

25962601
maybe_whole!(pair_empty self, nt_block);
25972602

2598-
fn maybe_parse_inner_attrs_and_next(p: &Parser, parse_attrs: bool) ->
2599-
(~[attribute], ~[attribute]) {
2600-
if parse_attrs {
2601-
p.parse_inner_attrs_and_next()
2602-
} else {
2603-
(~[], ~[])
2604-
}
2605-
}
2606-
26072603
let lo = self.span.lo;
26082604
if self.eat_keyword(&~"unsafe") {
26092605
self.obsolete(copy *self.span, ObsoleteUnsafeBlock);
26102606
}
26112607
self.expect(&token::LBRACE);
2612-
let (inner, next) =
2613-
maybe_parse_inner_attrs_and_next(self, parse_attrs);
2608+
let (inner, next) = self.parse_inner_attrs_and_next();
26142609

26152610
(inner, self.parse_block_tail_(lo, default_blk, next))
26162611
}
2617-
2618-
fn parse_block_no_value(&self) -> blk {
2619-
// We parse blocks that cannot have a value the same as any other
2620-
// block; the type checker will make sure that the tail expression (if
2621-
// any) has unit type.
2622-
return self.parse_block();
2623-
}
2624-
2612+
26252613
// Precondition: already parsed the '{' or '#{'
26262614
// I guess that also means "already parsed the 'impure'" if
26272615
// necessary, and this should take a qualifier.
@@ -3108,7 +3096,7 @@ pub impl Parser {
31083096
fn parse_item_fn(&self, purity: purity, abis: AbiSet) -> item_info {
31093097
let (ident, generics) = self.parse_fn_header();
31103098
let decl = self.parse_fn_decl();
3111-
let (inner_attrs, body) = self.parse_inner_attrs_and_block(true);
3099+
let (inner_attrs, body) = self.parse_inner_attrs_and_block();
31123100
(ident,
31133101
item_fn(decl, purity, abis, generics, body),
31143102
Some(inner_attrs))
@@ -3126,7 +3114,7 @@ pub impl Parser {
31263114
p.parse_arg()
31273115
};
31283116

3129-
let (inner_attrs, body) = self.parse_inner_attrs_and_block(true);
3117+
let (inner_attrs, body) = self.parse_inner_attrs_and_block();
31303118
let hi = body.span.hi;
31313119
let attrs = vec::append(attrs, inner_attrs);
31323120
@ast::method {
@@ -4126,7 +4114,6 @@ pub impl Parser {
41264114
}
41274115

41284116
// parse a foreign item; on failure, return iovi_none.
4129-
// trying to differentiate this from the other parse_foreign_item....
41304117
fn parse_foreign_item(
41314118
&self,
41324119
attrs: ~[attribute],

0 commit comments

Comments
 (0)