@@ -22,17 +22,14 @@ impl<'a> Parser<'a> {
22
22
/// Parses a statement. This stops just before trailing semicolons on everything but items.
23
23
/// e.g., a `StmtKind::Semi` parses to a `StmtKind::Expr`, leaving the trailing `;` unconsumed.
24
24
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| {
26
26
e. emit ( ) ;
27
27
self . recover_stmt_ ( SemiColonMode :: Break , BlockMode :: Ignore ) ;
28
28
None
29
29
} ) )
30
30
}
31
31
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 > > {
36
33
maybe_whole ! ( self , NtStmt , |x| Some ( x) ) ;
37
34
38
35
let attrs = self . parse_outer_attributes ( ) ?;
@@ -74,7 +71,7 @@ impl<'a> Parser<'a> {
74
71
let path = self . parse_path ( PathStyle :: Expr ) ?;
75
72
76
73
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) ;
78
75
}
79
76
80
77
let expr = if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
@@ -137,7 +134,6 @@ impl<'a> Parser<'a> {
137
134
lo : Span ,
138
135
attrs : AttrVec ,
139
136
path : ast:: Path ,
140
- legacy_warnings : bool ,
141
137
) -> PResult < ' a , Option < Stmt > > {
142
138
let args = self . parse_mac_args ( ) ?;
143
139
let delim = args. delim ( ) ;
@@ -150,30 +146,6 @@ impl<'a> Parser<'a> {
150
146
151
147
let kind = if delim == token:: Brace || self . token == token:: Semi || self . token == token:: Eof
152
148
{
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 ( ) ;
177
149
StmtKind :: Mac ( P ( ( mac, style, attrs) ) )
178
150
} else {
179
151
// Since none of the above applied, this is an expression statement macro.
@@ -334,7 +306,7 @@ impl<'a> Parser<'a> {
334
306
// bar;
335
307
//
336
308
// which is valid in other languages, but not Rust.
337
- match self . parse_stmt_without_recovery ( false ) {
309
+ match self . parse_stmt_without_recovery ( ) {
338
310
Ok ( Some ( stmt) ) => {
339
311
if self . look_ahead ( 1 , |t| t == & token:: OpenDelim ( token:: Brace ) )
340
312
|| do_not_suggest_help
@@ -393,7 +365,7 @@ impl<'a> Parser<'a> {
393
365
if self . token == token:: Eof {
394
366
break ;
395
367
}
396
- let stmt = match self . parse_full_stmt ( false ) {
368
+ let stmt = match self . parse_full_stmt ( ) {
397
369
Err ( mut err) => {
398
370
self . maybe_annotate_with_ascription ( & mut err, false ) ;
399
371
err. emit ( ) ;
@@ -413,11 +385,11 @@ impl<'a> Parser<'a> {
413
385
}
414
386
415
387
/// 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 > > {
417
389
// Skip looking for a trailing semicolon when we have an interpolated statement.
418
390
maybe_whole ! ( self , NtStmt , |x| Some ( x) ) ;
419
391
420
- let mut stmt = match self . parse_stmt_without_recovery ( macro_legacy_warnings ) ? {
392
+ let mut stmt = match self . parse_stmt_without_recovery ( ) ? {
421
393
Some ( stmt) => stmt,
422
394
None => return Ok ( None ) ,
423
395
} ;
@@ -457,13 +429,8 @@ impl<'a> Parser<'a> {
457
429
}
458
430
}
459
431
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 ;
467
434
}
468
435
_ => { }
469
436
}
@@ -475,17 +442,6 @@ impl<'a> Parser<'a> {
475
442
Ok ( Some ( stmt) )
476
443
}
477
444
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
-
489
445
pub ( super ) fn mk_block ( & self , stmts : Vec < Stmt > , rules : BlockCheckMode , span : Span ) -> P < Block > {
490
446
P ( Block { stmts, id : DUMMY_NODE_ID , rules, span } )
491
447
}
0 commit comments