13
13
use abi;
14
14
use abi:: AbiSet ;
15
15
use ast:: { Sigil , BorrowedSigil , ManagedSigil , OwnedSigil } ;
16
- use ast:: { CallSugar , NoSugar , DoSugar } ;
16
+ use ast:: { CallSugar , NoSugar } ;
17
17
use ast:: { BareFnTy , ClosureTy } ;
18
18
use ast:: { RegionTyParamBound , TraitTyParamBound } ;
19
19
use ast:: { Provided , Public , Purity } ;
@@ -24,7 +24,7 @@ use ast::{Crate, CrateConfig, Decl, DeclItem};
24
24
use ast:: { DeclLocal , DefaultBlock , UnDeref , BiDiv , EMPTY_CTXT , EnumDef , ExplicitSelf } ;
25
25
use ast:: { Expr , Expr_ , ExprAddrOf , ExprMatch , ExprAgain } ;
26
26
use ast:: { ExprAssign , ExprAssignOp , ExprBinary , ExprBlock , ExprBox } ;
27
- use ast:: { ExprBreak , ExprCall , ExprCast , ExprDoBody } ;
27
+ use ast:: { ExprBreak , ExprCall , ExprCast } ;
28
28
use ast:: { ExprField , ExprFnBlock , ExprIf , ExprIndex } ;
29
29
use ast:: { ExprLit , ExprLogLevel , ExprLoop , ExprMac } ;
30
30
use ast:: { ExprMethodCall , ExprParen , ExprPath , ExprProc } ;
@@ -1796,9 +1796,6 @@ impl Parser {
1796
1796
return self . parse_if_expr ( ) ;
1797
1797
} else if self . eat_keyword ( keywords:: For ) {
1798
1798
return self . parse_for_expr ( None ) ;
1799
- } else if self . eat_keyword ( keywords:: Do ) {
1800
- return self . parse_sugary_call_expr ( lo, ~"do", DoSugar ,
1801
- ExprDoBody ) ;
1802
1799
} else if self . eat_keyword ( keywords:: While ) {
1803
1800
return self . parse_while_expr ( ) ;
1804
1801
} else if Parser :: token_is_lifetime ( & self . token ) {
@@ -2541,75 +2538,6 @@ impl Parser {
2541
2538
self . mk_expr ( lo, hi, ExprForLoop ( pat, expr, loop_block, opt_ident) )
2542
2539
}
2543
2540
2544
-
2545
- // parse a 'do'.
2546
- // the 'do' expression parses as a call, but looks like
2547
- // a function call followed by a closure expression.
2548
- pub fn parse_sugary_call_expr ( & mut self ,
2549
- lo : BytePos ,
2550
- keyword : ~str ,
2551
- sugar : CallSugar ,
2552
- ctor: |v: @Expr | -> Expr_ )
2553
- -> @Expr {
2554
- // Parse the callee `foo` in
2555
- // do foo || {
2556
- // do foo.bar || {
2557
- // etc, or the portion of the call expression before the lambda in
2558
- // do foo() || {
2559
- // or
2560
- // do foo.bar(a) || {
2561
- // Turn on the restriction to stop at | or || so we can parse
2562
- // them as the lambda arguments
2563
- let e = self . parse_expr_res ( RESTRICT_NO_BAR_OR_DOUBLEBAR_OP ) ;
2564
- match e. node {
2565
- ExprCall ( f, ref args, NoSugar ) => {
2566
- let block = self . parse_lambda_block_expr ( ) ;
2567
- let last_arg = self . mk_expr ( block. span . lo , block. span . hi ,
2568
- ctor ( block) ) ;
2569
- let args = vec:: append_one ( ( * args) . clone ( ) , last_arg) ;
2570
- self . mk_expr ( lo, block. span . hi , ExprCall ( f, args, sugar) )
2571
- }
2572
- ExprMethodCall ( _, i, ref tps, ref args, NoSugar ) => {
2573
- let block = self . parse_lambda_block_expr ( ) ;
2574
- let last_arg = self . mk_expr ( block. span . lo , block. span . hi ,
2575
- ctor ( block) ) ;
2576
- let args = vec:: append_one ( ( * args) . clone ( ) , last_arg) ;
2577
- let method_call = self . mk_method_call ( i,
2578
- ( * tps) . clone ( ) ,
2579
- args,
2580
- sugar) ;
2581
- self . mk_expr ( lo, block. span . hi , method_call)
2582
- }
2583
- ExprField ( f, i, ref tps) => {
2584
- let block = self . parse_lambda_block_expr ( ) ;
2585
- let last_arg = self . mk_expr ( block. span . lo , block. span . hi ,
2586
- ctor ( block) ) ;
2587
- let method_call = self . mk_method_call ( i,
2588
- ( * tps) . clone ( ) ,
2589
- ~[ f, last_arg] ,
2590
- sugar) ;
2591
- self . mk_expr ( lo, block. span . hi , method_call)
2592
- }
2593
- ExprPath ( ..) | ExprCall ( ..) | ExprMethodCall ( ..) |
2594
- ExprParen ( ..) => {
2595
- let block = self . parse_lambda_block_expr ( ) ;
2596
- let last_arg = self . mk_expr ( block. span . lo , block. span . hi ,
2597
- ctor ( block) ) ;
2598
- let call = self . mk_call ( e, ~[ last_arg] , sugar) ;
2599
- self . mk_expr ( lo, last_arg. span . hi , call)
2600
- }
2601
- _ => {
2602
- // There may be other types of expressions that can
2603
- // represent the callee in `do` expressions
2604
- // but they aren't represented by tests
2605
- debug ! ( "sugary call on {:?}" , e. node) ;
2606
- self . span_fatal (
2607
- e. span ,
2608
- format ! ( "`{}` must be followed by a block call" , keyword) ) ;
2609
- }
2610
- }
2611
- }
2612
-
2613
2541
pub fn parse_while_expr ( & mut self ) -> @Expr {
2614
2542
let lo = self . last_span . lo ;
2615
2543
let cond = self . parse_expr ( ) ;
0 commit comments