@@ -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 ( ) ?;
@@ -64,7 +61,7 @@ impl<'a> Parser<'a> {
6461 let path = self . parse_path ( PathStyle :: Expr ) ?;
6562
6663 if self . eat ( & token:: Not ) {
67- return self . parse_stmt_mac ( lo, attrs. into ( ) , path, macro_legacy_warnings ) ;
64+ return self . parse_stmt_mac ( lo, attrs. into ( ) , path) ;
6865 }
6966
7067 let expr = if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
@@ -127,7 +124,6 @@ impl<'a> Parser<'a> {
127124 lo : Span ,
128125 attrs : AttrVec ,
129126 path : ast:: Path ,
130- legacy_warnings : bool ,
131127 ) -> PResult < ' a , Option < Stmt > > {
132128 let args = self . parse_mac_args ( ) ?;
133129 let delim = args. delim ( ) ;
@@ -140,30 +136,6 @@ impl<'a> Parser<'a> {
140136
141137 let kind = if delim == token:: Brace || self . token == token:: Semi || self . token == token:: Eof
142138 {
143- StmtKind :: Mac ( P ( ( mac, style, attrs. into ( ) ) ) )
144- }
145- // We used to incorrectly stop parsing macro-expanded statements here.
146- // If the next token will be an error anyway but could have parsed with the
147- // earlier behavior, stop parsing here and emit a warning to avoid breakage.
148- else if legacy_warnings
149- && self . token . can_begin_expr ( )
150- && match self . token . kind {
151- // These can continue an expression, so we can't stop parsing and warn.
152- token:: OpenDelim ( token:: Paren )
153- | token:: OpenDelim ( token:: Bracket )
154- | token:: BinOp ( token:: Minus )
155- | token:: BinOp ( token:: Star )
156- | token:: BinOp ( token:: And )
157- | token:: BinOp ( token:: Or )
158- | token:: AndAnd
159- | token:: OrOr
160- | token:: DotDot
161- | token:: DotDotDot
162- | token:: DotDotEq => false ,
163- _ => true ,
164- }
165- {
166- self . warn_missing_semicolon ( ) ;
167139 StmtKind :: Mac ( P ( ( mac, style, attrs) ) )
168140 } else {
169141 // Since none of the above applied, this is an expression statement macro.
@@ -310,7 +282,7 @@ impl<'a> Parser<'a> {
310282 // bar;
311283 //
312284 // which is valid in other languages, but not Rust.
313- match self . parse_stmt_without_recovery ( false ) {
285+ match self . parse_stmt_without_recovery ( ) {
314286 Ok ( Some ( stmt) ) => {
315287 if self . look_ahead ( 1 , |t| t == & token:: OpenDelim ( token:: Brace ) )
316288 || do_not_suggest_help
@@ -369,7 +341,7 @@ impl<'a> Parser<'a> {
369341 if self . token == token:: Eof {
370342 break ;
371343 }
372- let stmt = match self . parse_full_stmt ( false ) {
344+ let stmt = match self . parse_full_stmt ( ) {
373345 Err ( mut err) => {
374346 self . maybe_annotate_with_ascription ( & mut err, false ) ;
375347 err. emit ( ) ;
@@ -389,11 +361,11 @@ impl<'a> Parser<'a> {
389361 }
390362
391363 /// Parses a statement, including the trailing semicolon.
392- pub fn parse_full_stmt ( & mut self , macro_legacy_warnings : bool ) -> PResult < ' a , Option < Stmt > > {
364+ pub fn parse_full_stmt ( & mut self ) -> PResult < ' a , Option < Stmt > > {
393365 // Skip looking for a trailing semicolon when we have an interpolated statement.
394366 maybe_whole ! ( self , NtStmt , |x| Some ( x) ) ;
395367
396- let mut stmt = match self . parse_stmt_without_recovery ( macro_legacy_warnings ) ? {
368+ let mut stmt = match self . parse_stmt_without_recovery ( ) ? {
397369 Some ( stmt) => stmt,
398370 None => return Ok ( None ) ,
399371 } ;
@@ -433,13 +405,8 @@ impl<'a> Parser<'a> {
433405 }
434406 }
435407 StmtKind :: Local ( ..) => {
436- // We used to incorrectly allow a macro-expanded let statement to lack a semicolon.
437- if macro_legacy_warnings && self . token != token:: Semi {
438- self . warn_missing_semicolon ( ) ;
439- } else {
440- self . expect_semi ( ) ?;
441- eat_semi = false ;
442- }
408+ self . expect_semi ( ) ?;
409+ eat_semi = false ;
443410 }
444411 _ => { }
445412 }
@@ -451,17 +418,6 @@ impl<'a> Parser<'a> {
451418 Ok ( Some ( stmt) )
452419 }
453420
454- fn warn_missing_semicolon ( & self ) {
455- self . diagnostic ( )
456- . struct_span_warn ( self . token . span , {
457- & format ! ( "expected `;`, found {}" , super :: token_descr( & self . token) )
458- } )
459- . note ( {
460- "this was erroneously allowed and will become a hard error in a future release"
461- } )
462- . emit ( ) ;
463- }
464-
465421 pub ( super ) fn mk_block ( & self , stmts : Vec < Stmt > , rules : BlockCheckMode , span : Span ) -> P < Block > {
466422 P ( Block { stmts, id : DUMMY_NODE_ID , rules, span } )
467423 }
0 commit comments