@@ -520,7 +520,7 @@ pub impl Parser {
520
520
token:: LBRACE => {
521
521
debug ! ( "parse_trait_methods(): parsing provided method" ) ;
522
522
let ( inner_attrs, body) =
523
- p. parse_inner_attrs_and_block ( true ) ;
523
+ p. parse_inner_attrs_and_block ( ) ;
524
524
let attrs = vec:: append ( attrs, inner_attrs) ;
525
525
provided ( @ast:: method {
526
526
ident : ident,
@@ -1975,7 +1975,7 @@ pub impl Parser {
1975
1975
fn parse_while_expr( & self ) -> @expr {
1976
1976
let lo = self . last_span . lo ;
1977
1977
let cond = self . parse_expr ( ) ;
1978
- let body = self . parse_block_no_value ( ) ;
1978
+ let body = self . parse_block ( ) ;
1979
1979
let hi = body. span . hi ;
1980
1980
return self . mk_expr ( lo, hi, expr_while ( cond, body) ) ;
1981
1981
}
@@ -2003,7 +2003,7 @@ pub impl Parser {
2003
2003
}
2004
2004
2005
2005
let lo = self . last_span . lo ;
2006
- let body = self . parse_block_no_value ( ) ;
2006
+ let body = self . parse_block ( ) ;
2007
2007
let hi = body. span . hi ;
2008
2008
return self . mk_expr ( lo, hi, expr_loop ( body, opt_ident) ) ;
2009
2009
} else {
@@ -2581,47 +2581,35 @@ pub impl Parser {
2581
2581
!classify:: expr_requires_semi_to_be_stmt ( e) ;
2582
2582
}
2583
2583
2584
+ // parse a block. No inner attrs are allowed.
2584
2585
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, ~[ ] ) ;
2589
2595
}
2590
2596
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 )
2594
2599
-> ( ~[ attribute ] , blk ) {
2595
2600
2596
2601
maybe_whole ! ( pair_empty self , nt_block) ;
2597
2602
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
-
2607
2603
let lo = self . span . lo ;
2608
2604
if self . eat_keyword ( & ~"unsafe ") {
2609
2605
self . obsolete ( copy * self . span , ObsoleteUnsafeBlock ) ;
2610
2606
}
2611
2607
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 ( ) ;
2614
2609
2615
2610
( inner, self . parse_block_tail_ ( lo, default_blk, next) )
2616
2611
}
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
+
2625
2613
// Precondition: already parsed the '{' or '#{'
2626
2614
// I guess that also means "already parsed the 'impure'" if
2627
2615
// necessary, and this should take a qualifier.
@@ -3108,7 +3096,7 @@ pub impl Parser {
3108
3096
fn parse_item_fn ( & self , purity : purity , abis : AbiSet ) -> item_info {
3109
3097
let ( ident, generics) = self . parse_fn_header ( ) ;
3110
3098
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 ( ) ;
3112
3100
( ident,
3113
3101
item_fn ( decl, purity, abis, generics, body) ,
3114
3102
Some ( inner_attrs) )
@@ -3126,7 +3114,7 @@ pub impl Parser {
3126
3114
p. parse_arg ( )
3127
3115
} ;
3128
3116
3129
- let ( inner_attrs, body) = self . parse_inner_attrs_and_block ( true ) ;
3117
+ let ( inner_attrs, body) = self . parse_inner_attrs_and_block ( ) ;
3130
3118
let hi = body. span . hi ;
3131
3119
let attrs = vec:: append ( attrs, inner_attrs) ;
3132
3120
@ast:: method {
@@ -4126,7 +4114,6 @@ pub impl Parser {
4126
4114
}
4127
4115
4128
4116
// parse a foreign item; on failure, return iovi_none.
4129
- // trying to differentiate this from the other parse_foreign_item....
4130
4117
fn parse_foreign_item(
4131
4118
& self ,
4132
4119
attrs: ~[ attribute] ,
0 commit comments