@@ -22,17 +22,14 @@ impl<'a> Parser<'a> {
2222 /// Parses a statement. This stops just before trailing semicolons on everything but items.
2323 /// e.g., a `StmtKind::Semi` parses to a `StmtKind::Expr`, leaving the trailing `;` unconsumed.
2424 pub fn parse_stmt ( & mut self ) -> PResult < ' a , Option < Stmt > > {
25- Ok ( self . parse_stmt_without_recovery ( true ) . unwrap_or_else ( |mut e| {
25+ Ok ( self . parse_stmt_without_recovery ( ) . unwrap_or_else ( |mut e| {
2626 e. emit ( ) ;
2727 self . recover_stmt_ ( SemiColonMode :: Break , BlockMode :: Ignore ) ;
2828 None
2929 } ) )
3030 }
3131
32- fn parse_stmt_without_recovery (
33- & mut self ,
34- macro_legacy_warnings : bool ,
35- ) -> PResult < ' a , Option < Stmt > > {
32+ fn parse_stmt_without_recovery ( & mut self ) -> PResult < ' a , Option < Stmt > > {
3633 maybe_whole ! ( self , NtStmt , |x| Some ( x) ) ;
3734
3835 let attrs = self . parse_outer_attributes ( ) ?;
@@ -74,7 +71,7 @@ impl<'a> Parser<'a> {
7471 let path = self . parse_path ( PathStyle :: Expr ) ?;
7572
7673 if self . eat ( & token:: Not ) {
77- return self . parse_stmt_mac ( lo, attrs. into ( ) , path, macro_legacy_warnings ) ;
74+ return self . parse_stmt_mac ( lo, attrs. into ( ) , path) ;
7875 }
7976
8077 let expr = if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
@@ -137,7 +134,6 @@ impl<'a> Parser<'a> {
137134 lo : Span ,
138135 attrs : AttrVec ,
139136 path : ast:: Path ,
140- legacy_warnings : bool ,
141137 ) -> PResult < ' a , Option < Stmt > > {
142138 let args = self . parse_mac_args ( ) ?;
143139 let delim = args. delim ( ) ;
@@ -150,30 +146,6 @@ impl<'a> Parser<'a> {
150146
151147 let kind = if delim == token:: Brace || self . token == token:: Semi || self . token == token:: Eof
152148 {
153- StmtKind :: Mac ( P ( ( mac, style, attrs. into ( ) ) ) )
154- }
155- // We used to incorrectly stop parsing macro-expanded statements here.
156- // If the next token will be an error anyway but could have parsed with the
157- // earlier behavior, stop parsing here and emit a warning to avoid breakage.
158- else if legacy_warnings
159- && self . token . can_begin_expr ( )
160- && match self . token . kind {
161- // These can continue an expression, so we can't stop parsing and warn.
162- token:: OpenDelim ( token:: Paren )
163- | token:: OpenDelim ( token:: Bracket )
164- | token:: BinOp ( token:: Minus )
165- | token:: BinOp ( token:: Star )
166- | token:: BinOp ( token:: And )
167- | token:: BinOp ( token:: Or )
168- | token:: AndAnd
169- | token:: OrOr
170- | token:: DotDot
171- | token:: DotDotDot
172- | token:: DotDotEq => false ,
173- _ => true ,
174- }
175- {
176- self . warn_missing_semicolon ( ) ;
177149 StmtKind :: Mac ( P ( ( mac, style, attrs) ) )
178150 } else {
179151 // Since none of the above applied, this is an expression statement macro.
@@ -334,7 +306,7 @@ impl<'a> Parser<'a> {
334306 // bar;
335307 //
336308 // which is valid in other languages, but not Rust.
337- match self . parse_stmt_without_recovery ( false ) {
309+ match self . parse_stmt_without_recovery ( ) {
338310 Ok ( Some ( stmt) ) => {
339311 if self . look_ahead ( 1 , |t| t == & token:: OpenDelim ( token:: Brace ) )
340312 || do_not_suggest_help
@@ -393,7 +365,7 @@ impl<'a> Parser<'a> {
393365 if self . token == token:: Eof {
394366 break ;
395367 }
396- let stmt = match self . parse_full_stmt ( false ) {
368+ let stmt = match self . parse_full_stmt ( ) {
397369 Err ( mut err) => {
398370 self . maybe_annotate_with_ascription ( & mut err, false ) ;
399371 err. emit ( ) ;
@@ -413,11 +385,11 @@ impl<'a> Parser<'a> {
413385 }
414386
415387 /// Parses a statement, including the trailing semicolon.
416- pub fn parse_full_stmt ( & mut self , macro_legacy_warnings : bool ) -> PResult < ' a , Option < Stmt > > {
388+ pub fn parse_full_stmt ( & mut self ) -> PResult < ' a , Option < Stmt > > {
417389 // Skip looking for a trailing semicolon when we have an interpolated statement.
418390 maybe_whole ! ( self , NtStmt , |x| Some ( x) ) ;
419391
420- let mut stmt = match self . parse_stmt_without_recovery ( macro_legacy_warnings ) ? {
392+ let mut stmt = match self . parse_stmt_without_recovery ( ) ? {
421393 Some ( stmt) => stmt,
422394 None => return Ok ( None ) ,
423395 } ;
@@ -457,13 +429,8 @@ impl<'a> Parser<'a> {
457429 }
458430 }
459431 StmtKind :: Local ( ..) => {
460- // We used to incorrectly allow a macro-expanded let statement to lack a semicolon.
461- if macro_legacy_warnings && self . token != token:: Semi {
462- self . warn_missing_semicolon ( ) ;
463- } else {
464- self . expect_semi ( ) ?;
465- eat_semi = false ;
466- }
432+ self . expect_semi ( ) ?;
433+ eat_semi = false ;
467434 }
468435 _ => { }
469436 }
@@ -475,17 +442,6 @@ impl<'a> Parser<'a> {
475442 Ok ( Some ( stmt) )
476443 }
477444
478- fn warn_missing_semicolon ( & self ) {
479- self . diagnostic ( )
480- . struct_span_warn ( self . token . span , {
481- & format ! ( "expected `;`, found {}" , super :: token_descr( & self . token) )
482- } )
483- . note ( {
484- "this was erroneously allowed and will become a hard error in a future release"
485- } )
486- . emit ( ) ;
487- }
488-
489445 pub ( super ) fn mk_block ( & self , stmts : Vec < Stmt > , rules : BlockCheckMode , span : Span ) -> P < Block > {
490446 P ( Block { stmts, id : DUMMY_NODE_ID , rules, span } )
491447 }
0 commit comments