@@ -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 ( ) ?;
@@ -64,7 +61,7 @@ impl<'a> Parser<'a> {
64
61
let path = self . parse_path ( PathStyle :: Expr ) ?;
65
62
66
63
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) ;
68
65
}
69
66
70
67
let expr = if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
@@ -127,7 +124,6 @@ impl<'a> Parser<'a> {
127
124
lo : Span ,
128
125
attrs : AttrVec ,
129
126
path : ast:: Path ,
130
- legacy_warnings : bool ,
131
127
) -> PResult < ' a , Option < Stmt > > {
132
128
let args = self . parse_mac_args ( ) ?;
133
129
let delim = args. delim ( ) ;
@@ -140,30 +136,6 @@ impl<'a> Parser<'a> {
140
136
141
137
let kind = if delim == token:: Brace || self . token == token:: Semi || self . token == token:: Eof
142
138
{
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 ( ) ;
167
139
StmtKind :: Mac ( P ( ( mac, style, attrs) ) )
168
140
} else {
169
141
// Since none of the above applied, this is an expression statement macro.
@@ -310,7 +282,7 @@ impl<'a> Parser<'a> {
310
282
// bar;
311
283
//
312
284
// which is valid in other languages, but not Rust.
313
- match self . parse_stmt_without_recovery ( false ) {
285
+ match self . parse_stmt_without_recovery ( ) {
314
286
Ok ( Some ( stmt) ) => {
315
287
if self . look_ahead ( 1 , |t| t == & token:: OpenDelim ( token:: Brace ) )
316
288
|| do_not_suggest_help
@@ -369,7 +341,7 @@ impl<'a> Parser<'a> {
369
341
if self . token == token:: Eof {
370
342
break ;
371
343
}
372
- let stmt = match self . parse_full_stmt ( false ) {
344
+ let stmt = match self . parse_full_stmt ( ) {
373
345
Err ( mut err) => {
374
346
self . maybe_annotate_with_ascription ( & mut err, false ) ;
375
347
err. emit ( ) ;
@@ -389,11 +361,11 @@ impl<'a> Parser<'a> {
389
361
}
390
362
391
363
/// 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 > > {
393
365
// Skip looking for a trailing semicolon when we have an interpolated statement.
394
366
maybe_whole ! ( self , NtStmt , |x| Some ( x) ) ;
395
367
396
- let mut stmt = match self . parse_stmt_without_recovery ( macro_legacy_warnings ) ? {
368
+ let mut stmt = match self . parse_stmt_without_recovery ( ) ? {
397
369
Some ( stmt) => stmt,
398
370
None => return Ok ( None ) ,
399
371
} ;
@@ -433,13 +405,8 @@ impl<'a> Parser<'a> {
433
405
}
434
406
}
435
407
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 ;
443
410
}
444
411
_ => { }
445
412
}
@@ -451,17 +418,6 @@ impl<'a> Parser<'a> {
451
418
Ok ( Some ( stmt) )
452
419
}
453
420
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
-
465
421
pub ( super ) fn mk_block ( & self , stmts : Vec < Stmt > , rules : BlockCheckMode , span : Span ) -> P < Block > {
466
422
P ( Block { stmts, id : DUMMY_NODE_ID , rules, span } )
467
423
}
0 commit comments