@@ -4044,8 +4044,8 @@ impl<'a> Parser<'a> {
40444044 let mut stmts = vec ! [ ] ;
40454045
40464046 while !self . eat ( & token:: CloseDelim ( token:: Brace ) ) {
4047- if let Some ( stmt) = self . parse_stmt_ ( ) {
4048- stmts. push ( self . finish_parsing_statement ( stmt) ? ) ;
4047+ if let Some ( stmt) = self . parse_full_stmt ( ) ? {
4048+ stmts. push ( stmt) ;
40494049 } else if self . token == token:: Eof {
40504050 break ;
40514051 } else {
@@ -4062,9 +4062,14 @@ impl<'a> Parser<'a> {
40624062 } ) )
40634063 }
40644064
4065- /// Finish parsing expressions that start with macros and handle trailing semicolons
4066- /// (or the lack thereof) -- c.f. `parse_stmt`.
4067- pub fn finish_parsing_statement ( & mut self , mut stmt : Stmt ) -> PResult < ' a , Stmt > {
4065+ /// Parse a statement, including the trailing semicolon.
4066+ /// This parses expression statements that begin with macros correctly (c.f. `parse_stmt`).
4067+ pub fn parse_full_stmt ( & mut self ) -> PResult < ' a , Option < Stmt > > {
4068+ let mut stmt = match self . parse_stmt_ ( ) {
4069+ Some ( stmt) => stmt,
4070+ None => return Ok ( None ) ,
4071+ } ;
4072+
40684073 if let StmtKind :: Mac ( mac) = stmt. node {
40694074 if mac. 1 != MacStmtStyle :: NoBraces ||
40704075 self . token == token:: Semi || self . token == token:: Eof {
@@ -4078,7 +4083,8 @@ impl<'a> Parser<'a> {
40784083 }
40794084 }
40804085
4081- self . handle_trailing_semicolon ( stmt)
4086+ stmt = self . handle_trailing_semicolon ( stmt) ?;
4087+ Ok ( Some ( stmt) )
40824088 }
40834089
40844090 fn handle_trailing_semicolon ( & mut self , mut stmt : Stmt ) -> PResult < ' a , Stmt > {
0 commit comments