@@ -413,23 +413,30 @@ declare_keywords! {
413413 ( 49 , Virtual , "virtual" )
414414 ( 50 , Yield , "yield" )
415415
416+ // Edition-specific keywords currently in use.
417+ ( 51 , Try , "try" ) // >= 2018 Edition Only
418+
416419 // Edition-specific keywords reserved for future use.
417- ( 51 , Async , "async" ) // >= 2018 Edition Only
420+ ( 52 , Async , "async" ) // >= 2018 Edition Only
418421
419422 // Special lifetime names
420- ( 52 , UnderscoreLifetime , "'_" )
421- ( 53 , StaticLifetime , "'static" )
423+ ( 53 , UnderscoreLifetime , "'_" )
424+ ( 54 , StaticLifetime , "'static" )
422425
423426 // Weak keywords, have special meaning only in specific contexts.
424- ( 54 , Auto , "auto" )
425- ( 55 , Catch , "catch" )
426- ( 56 , Default , "default" )
427- ( 57 , Dyn , "dyn" )
428- ( 58 , Union , "union" )
429- ( 59 , Existential , "existential" )
427+ ( 55 , Auto , "auto" )
428+ ( 56 , Catch , "catch" )
429+ ( 57 , Default , "default" )
430+ ( 58 , Dyn , "dyn" )
431+ ( 59 , Union , "union" )
432+ ( 60 , Existential , "existential" )
430433}
431434
432435impl Symbol {
436+ fn is_used_keyword_2018 ( self ) -> bool {
437+ self == keywords:: Try . name ( )
438+ }
439+
433440 fn is_unused_keyword_2018 ( self ) -> bool {
434441 self == keywords:: Async . name ( )
435442 }
@@ -444,7 +451,9 @@ impl Ident {
444451
445452 /// Returns `true` if the token is a keyword used in the language.
446453 pub fn is_used_keyword ( self ) -> bool {
447- self . name >= keywords:: As . name ( ) && self . name <= keywords:: While . name ( )
454+ // Note: `span.edition()` is relatively expensive, don't call it unless necessary.
455+ self . name >= keywords:: As . name ( ) && self . name <= keywords:: While . name ( ) ||
456+ self . name . is_used_keyword_2018 ( ) && self . span . edition ( ) == Edition :: Edition2018
448457 }
449458
450459 /// Returns `true` if the token is a keyword reserved for possible future use.
0 commit comments