@@ -4044,8 +4044,8 @@ impl<'a> Parser<'a> {
4044
4044
let mut stmts = vec ! [ ] ;
4045
4045
4046
4046
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) ;
4049
4049
} else if self . token == token:: Eof {
4050
4050
break ;
4051
4051
} else {
@@ -4062,9 +4062,14 @@ impl<'a> Parser<'a> {
4062
4062
} ) )
4063
4063
}
4064
4064
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
+
4068
4073
if let StmtKind :: Mac ( mac) = stmt. node {
4069
4074
if mac. 1 != MacStmtStyle :: NoBraces ||
4070
4075
self . token == token:: Semi || self . token == token:: Eof {
@@ -4078,7 +4083,8 @@ impl<'a> Parser<'a> {
4078
4083
}
4079
4084
}
4080
4085
4081
- self . handle_trailing_semicolon ( stmt)
4086
+ stmt = self . handle_trailing_semicolon ( stmt) ?;
4087
+ Ok ( Some ( stmt) )
4082
4088
}
4083
4089
4084
4090
fn handle_trailing_semicolon ( & mut self , mut stmt : Stmt ) -> PResult < ' a , Stmt > {
0 commit comments