@@ -88,6 +88,7 @@ pub trait AstBuilder {
88
88
89
89
// statements
90
90
fn stmt_expr ( & self , expr : P < ast:: Expr > ) -> ast:: Stmt ;
91
+ fn stmt_semi ( & self , expr : P < ast:: Expr > ) -> ast:: Stmt ;
91
92
fn stmt_let ( & self , sp : Span , mutbl : bool , ident : ast:: Ident , ex : P < ast:: Expr > ) -> ast:: Stmt ;
92
93
fn stmt_let_typed ( & self ,
93
94
sp : Span ,
@@ -99,12 +100,8 @@ pub trait AstBuilder {
99
100
fn stmt_item ( & self , sp : Span , item : P < ast:: Item > ) -> ast:: Stmt ;
100
101
101
102
// blocks
102
- fn block ( & self , span : Span , stmts : Vec < ast:: Stmt > ,
103
- expr : Option < P < ast:: Expr > > ) -> P < ast:: Block > ;
103
+ fn block ( & self , span : Span , stmts : Vec < ast:: Stmt > ) -> P < ast:: Block > ;
104
104
fn block_expr ( & self , expr : P < ast:: Expr > ) -> P < ast:: Block > ;
105
- fn block_all ( & self , span : Span ,
106
- stmts : Vec < ast:: Stmt > ,
107
- expr : Option < P < ast:: Expr > > ) -> P < ast:: Block > ;
108
105
109
106
// expressions
110
107
fn expr ( & self , span : Span , node : ast:: ExprKind ) -> P < ast:: Expr > ;
@@ -509,6 +506,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
509
506
}
510
507
511
508
fn stmt_expr ( & self , expr : P < ast:: Expr > ) -> ast:: Stmt {
509
+ ast:: Stmt {
510
+ id : ast:: DUMMY_NODE_ID ,
511
+ span : expr. span ,
512
+ node : ast:: StmtKind :: Expr ( expr) ,
513
+ }
514
+ }
515
+
516
+ fn stmt_semi ( & self , expr : P < ast:: Expr > ) -> ast:: Stmt {
512
517
ast:: Stmt {
513
518
id : ast:: DUMMY_NODE_ID ,
514
519
span : expr. span ,
@@ -567,11 +572,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
567
572
} )
568
573
}
569
574
570
- fn block ( & self , span : Span , stmts : Vec < ast:: Stmt > ,
571
- expr : Option < P < Expr > > ) -> P < ast:: Block > {
572
- self . block_all ( span, stmts, expr)
573
- }
574
-
575
575
fn stmt_item ( & self , sp : Span , item : P < ast:: Item > ) -> ast:: Stmt {
576
576
ast:: Stmt {
577
577
id : ast:: DUMMY_NODE_ID ,
@@ -581,19 +581,19 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
581
581
}
582
582
583
583
fn block_expr ( & self , expr : P < ast:: Expr > ) -> P < ast:: Block > {
584
- self . block_all ( expr. span , Vec :: new ( ) , Some ( expr ) )
585
- }
586
- fn block_all ( & self ,
587
- span : Span ,
588
- stmts : Vec < ast :: Stmt > ,
589
- expr : Option < P < ast :: Expr > > ) -> P < ast :: Block > {
590
- P ( ast:: Block {
591
- stmts : stmts ,
592
- expr : expr ,
593
- id : ast:: DUMMY_NODE_ID ,
594
- rules : BlockCheckMode :: Default ,
595
- span : span,
596
- } )
584
+ self . block ( expr. span , vec ! [ ast :: Stmt {
585
+ id : ast :: DUMMY_NODE_ID ,
586
+ span : expr . span ,
587
+ node : ast :: StmtKind :: Expr ( expr ) ,
588
+ } ] )
589
+ }
590
+ fn block ( & self , span : Span , stmts : Vec < ast :: Stmt > ) -> P < ast:: Block > {
591
+ P ( ast :: Block {
592
+ stmts : stmts ,
593
+ id : ast:: DUMMY_NODE_ID ,
594
+ rules : BlockCheckMode :: Default ,
595
+ span : span,
596
+ } )
597
597
}
598
598
599
599
fn expr ( & self , span : Span , node : ast:: ExprKind ) -> P < ast:: Expr > {
@@ -962,14 +962,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
962
962
ids : Vec < ast:: Ident > ,
963
963
stmts : Vec < ast:: Stmt > )
964
964
-> P < ast:: Expr > {
965
- self . lambda ( span, ids, self . block ( span, stmts, None ) )
965
+ self . lambda ( span, ids, self . block ( span, stmts) )
966
966
}
967
967
fn lambda_stmts_0 ( & self , span : Span , stmts : Vec < ast:: Stmt > ) -> P < ast:: Expr > {
968
- self . lambda0 ( span, self . block ( span, stmts, None ) )
968
+ self . lambda0 ( span, self . block ( span, stmts) )
969
969
}
970
970
fn lambda_stmts_1 ( & self , span : Span , stmts : Vec < ast:: Stmt > ,
971
971
ident : ast:: Ident ) -> P < ast:: Expr > {
972
- self . lambda1 ( span, self . block ( span, stmts, None ) , ident)
972
+ self . lambda1 ( span, self . block ( span, stmts) , ident)
973
973
}
974
974
975
975
fn arg ( & self , span : Span , ident : ast:: Ident , ty : P < ast:: Ty > ) -> ast:: Arg {
0 commit comments