@@ -46,7 +46,6 @@ use syntax::symbol::{Symbol, keywords};
4646use syntax:: errors:: { Applicability , DiagnosticBuilder } ;
4747use syntax:: print:: pprust:: expr_to_string;
4848use syntax:: visit:: FnKind ;
49- use syntax:: struct_span_err;
5049
5150use rustc:: hir:: { self , GenericParamKind , PatKind } ;
5251
@@ -1438,15 +1437,10 @@ impl KeywordIdents {
14381437 UnderMacro ( under_macro) : UnderMacro ,
14391438 ident : ast:: Ident )
14401439 {
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 ( ) {
14471441 Edition :: Edition2015 => {
1448- match ident_str {
1449- "async" | "try" => Edition :: Edition2018 ,
1442+ match & ident . as_str ( ) [ .. ] {
1443+ "async" | "await" | " try" => Edition :: Edition2018 ,
14501444
14511445 // rust-lang/rust#56327: Conservatively do not
14521446 // attempt to report occurrences of `dyn` within
@@ -1462,43 +1456,16 @@ impl KeywordIdents {
14621456 // an identifier.
14631457 "dyn" if !under_macro => Edition :: Edition2018 ,
14641458
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 ,
14691459 _ => return ,
14701460 }
14711461 }
14721462
14731463 // 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 ,
14981465 } ;
14991466
15001467 // don't lint `r#foo`
1501- if is_raw_ident ( ident) {
1468+ if cx . sess . parse_sess . raw_identifier_spans . borrow ( ) . contains ( & ident. span ) {
15021469 return ;
15031470 }
15041471
0 commit comments