@@ -88,6 +88,7 @@ pub trait AstBuilder {
8888
8989 // statements
9090 fn stmt_expr ( & self , expr : P < ast:: Expr > ) -> ast:: Stmt ;
91+ fn stmt_semi ( & self , expr : P < ast:: Expr > ) -> ast:: Stmt ;
9192 fn stmt_let ( & self , sp : Span , mutbl : bool , ident : ast:: Ident , ex : P < ast:: Expr > ) -> ast:: Stmt ;
9293 fn stmt_let_typed ( & self ,
9394 sp : Span ,
@@ -99,12 +100,8 @@ pub trait AstBuilder {
99100 fn stmt_item ( & self , sp : Span , item : P < ast:: Item > ) -> ast:: Stmt ;
100101
101102 // 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 > ;
104104 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 > ;
108105
109106 // expressions
110107 fn expr ( & self , span : Span , node : ast:: ExprKind ) -> P < ast:: Expr > ;
@@ -509,6 +506,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
509506 }
510507
511508 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 {
512517 ast:: Stmt {
513518 id : ast:: DUMMY_NODE_ID ,
514519 span : expr. span ,
@@ -567,11 +572,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
567572 } )
568573 }
569574
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-
575575 fn stmt_item ( & self , sp : Span , item : P < ast:: Item > ) -> ast:: Stmt {
576576 ast:: Stmt {
577577 id : ast:: DUMMY_NODE_ID ,
@@ -581,19 +581,19 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
581581 }
582582
583583 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+ } )
597597 }
598598
599599 fn expr ( & self , span : Span , node : ast:: ExprKind ) -> P < ast:: Expr > {
@@ -962,14 +962,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
962962 ids : Vec < ast:: Ident > ,
963963 stmts : Vec < ast:: Stmt > )
964964 -> P < ast:: Expr > {
965- self . lambda ( span, ids, self . block ( span, stmts, None ) )
965+ self . lambda ( span, ids, self . block ( span, stmts) )
966966 }
967967 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) )
969969 }
970970 fn lambda_stmts_1 ( & self , span : Span , stmts : Vec < ast:: Stmt > ,
971971 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)
973973 }
974974
975975 fn arg ( & self , span : Span , ident : ast:: Ident , ty : P < ast:: Ty > ) -> ast:: Arg {
0 commit comments