@@ -46,7 +46,6 @@ use syntax::symbol::{Symbol, keywords};
46
46
use syntax:: errors:: { Applicability , DiagnosticBuilder } ;
47
47
use syntax:: print:: pprust:: expr_to_string;
48
48
use syntax:: visit:: FnKind ;
49
- use syntax:: struct_span_err;
50
49
51
50
use rustc:: hir:: { self , GenericParamKind , PatKind } ;
52
51
@@ -1438,15 +1437,10 @@ impl KeywordIdents {
1438
1437
UnderMacro ( under_macro) : UnderMacro ,
1439
1438
ident : ast:: Ident )
1440
1439
{
1441
- let ident_str = & ident. as_str ( ) [ ..] ;
1442
- let cur_edition = cx. sess . edition ( ) ;
1443
- let is_raw_ident = |ident : ast:: Ident | {
1444
- cx. sess . parse_sess . raw_identifier_spans . borrow ( ) . contains ( & ident. span )
1445
- } ;
1446
- let next_edition = match cur_edition {
1440
+ let next_edition = match cx. sess . edition ( ) {
1447
1441
Edition :: Edition2015 => {
1448
- match ident_str {
1449
- "async" | "try" => Edition :: Edition2018 ,
1442
+ match & ident . as_str ( ) [ .. ] {
1443
+ "async" | "await" | " try" => Edition :: Edition2018 ,
1450
1444
1451
1445
// rust-lang/rust#56327: Conservatively do not
1452
1446
// attempt to report occurrences of `dyn` within
@@ -1462,43 +1456,16 @@ impl KeywordIdents {
1462
1456
// an identifier.
1463
1457
"dyn" if !under_macro => Edition :: Edition2018 ,
1464
1458
1465
- // Only issue warnings for `await` if the `async_await`
1466
- // feature isn't being used. Otherwise, users need
1467
- // to keep using `await` for the macro exposed by std.
1468
- "await" if !cx. sess . features_untracked ( ) . async_await => Edition :: Edition2018 ,
1469
1459
_ => return ,
1470
1460
}
1471
1461
}
1472
1462
1473
1463
// There are no new keywords yet for the 2018 edition and beyond.
1474
- // However, `await` is a "false" keyword in the 2018 edition,
1475
- // and can only be used if the `async_await` feature is enabled.
1476
- // Otherwise, we emit an error.
1477
- _ => {
1478
- if "await" == ident_str
1479
- && !cx. sess . features_untracked ( ) . async_await
1480
- && !is_raw_ident ( ident)
1481
- {
1482
- let mut err = struct_span_err ! (
1483
- cx. sess,
1484
- ident. span,
1485
- E0721 ,
1486
- "`await` is a keyword in the {} edition" , cur_edition,
1487
- ) ;
1488
- err. span_suggestion (
1489
- ident. span ,
1490
- "you can use a raw identifier to stay compatible" ,
1491
- "r#await" . to_string ( ) ,
1492
- Applicability :: MachineApplicable ,
1493
- ) ;
1494
- err. emit ( ) ;
1495
- }
1496
- return
1497
- } ,
1464
+ _ => return ,
1498
1465
} ;
1499
1466
1500
1467
// don't lint `r#foo`
1501
- if is_raw_ident ( ident) {
1468
+ if cx . sess . parse_sess . raw_identifier_spans . borrow ( ) . contains ( & ident. span ) {
1502
1469
return ;
1503
1470
}
1504
1471
0 commit comments