File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -118,12 +118,18 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
118
118
119
119
fn make_stmts ( self : Box < ParserAnyMacro < ' a > > )
120
120
-> Option < SmallVector < ast:: Stmt > > {
121
+ let parse_stmt = |parser : & mut Parser < ' a > | -> :: parse:: PResult < ' a , _ > {
122
+ Ok ( match parser. parse_stmt ( ) ? {
123
+ Some ( stmt) => Some ( parser. finish_parsing_statement ( stmt) ?) ,
124
+ None => None ,
125
+ } )
126
+ } ;
121
127
let mut ret = SmallVector :: zero ( ) ;
122
128
loop {
123
129
let mut parser = self . parser . borrow_mut ( ) ;
124
130
match parser. token {
125
131
token:: Eof => break ,
126
- _ => match parser . parse_stmt ( ) {
132
+ _ => match parse_stmt ( & mut parser ) {
127
133
Ok ( maybe_stmt) => match maybe_stmt {
128
134
Some ( stmt) => ret. push ( stmt) ,
129
135
None => ( ) ,
Original file line number Diff line number Diff line change @@ -4064,7 +4064,7 @@ impl<'a> Parser<'a> {
4064
4064
4065
4065
/// Finish parsing expressions that start with macros and handle trailing semicolons
4066
4066
/// (or the lack thereof) -- c.f. `parse_stmt`.
4067
- fn finish_parsing_statement ( & mut self , mut stmt : Stmt ) -> PResult < ' a , Stmt > {
4067
+ pub fn finish_parsing_statement ( & mut self , mut stmt : Stmt ) -> PResult < ' a , Stmt > {
4068
4068
if let StmtKind :: Mac ( mac) = stmt. node {
4069
4069
if mac. 1 != MacStmtStyle :: NoBraces || self . token == token:: Semi {
4070
4070
stmt. node = StmtKind :: Mac ( mac) ;
@@ -4082,7 +4082,7 @@ impl<'a> Parser<'a> {
4082
4082
4083
4083
fn handle_trailing_semicolon ( & mut self , mut stmt : Stmt ) -> PResult < ' a , Stmt > {
4084
4084
match stmt. node {
4085
- StmtKind :: Expr ( ref expr) => {
4085
+ StmtKind :: Expr ( ref expr) if self . token != token :: Eof => {
4086
4086
// expression without semicolon
4087
4087
if classify:: expr_requires_semi_to_be_stmt ( expr) {
4088
4088
// Just check for errors and recover; do not eat semicolon yet.
You can’t perform that action at this time.
0 commit comments