File tree Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,14 @@ pub use self::Lit::*;
15
15
pub use self :: Token :: * ;
16
16
17
17
use ast:: { self } ;
18
+ use edition:: Edition ;
18
19
use parse:: ParseSess ;
19
20
use print:: pprust;
20
21
use ptr:: P ;
21
22
use serialize:: { Decodable , Decoder , Encodable , Encoder } ;
22
23
use symbol:: keywords;
23
24
use syntax:: parse:: parse_stream_from_source_str;
24
- use syntax_pos:: { self , Span , FileName } ;
25
+ use syntax_pos:: { self , hygiene , Span , FileName } ;
25
26
use tokenstream:: { TokenStream , TokenTree } ;
26
27
use tokenstream;
27
28
@@ -168,7 +169,11 @@ pub fn is_used_keyword(id: ast::Ident) -> bool {
168
169
169
170
/// Returns `true` if the token is a keyword reserved for possible future use.
170
171
pub fn is_unused_keyword ( id : ast:: Ident ) -> bool {
171
- id. name >= keywords:: Abstract . name ( ) && id. name <= keywords:: Yield . name ( )
172
+ let edition = || id. span . ctxt ( ) . outer ( ) . expn_info ( ) . map_or_else ( || hygiene:: default_edition ( ) ,
173
+ |einfo| einfo. callee . edition ) ;
174
+ id. name >= keywords:: Abstract . name ( ) && id. name <= keywords:: Yield . name ( ) ||
175
+ id. name == keywords:: Proc . name ( ) && edition ( ) == Edition :: Edition2015 ||
176
+ id. name == keywords:: Async . name ( ) && edition ( ) == Edition :: Edition2018
172
177
}
173
178
174
179
/// Returns `true` if the token is either a special identifier or a keyword.
Original file line number Diff line number Diff line change @@ -383,16 +383,20 @@ declare_keywords! {
383
383
( 53 , Virtual , "virtual" )
384
384
( 54 , Yield , "yield" )
385
385
386
+ // Edition-specific keywords reserved for future use.
387
+ ( 55 , Async , "async" ) // >= 2018 Edition Only
388
+ ( 56 , Proc , "proc" ) // <= 2015 Edition Only
389
+
386
390
// Special lifetime names
387
- ( 55 , UnderscoreLifetime , "'_" )
388
- ( 56 , StaticLifetime , "'static" )
391
+ ( 57 , UnderscoreLifetime , "'_" )
392
+ ( 58 , StaticLifetime , "'static" )
389
393
390
394
// Weak keywords, have special meaning only in specific contexts.
391
- ( 57 , Auto , "auto" )
392
- ( 58 , Catch , "catch" )
393
- ( 59 , Default , "default" )
394
- ( 60 , Dyn , "dyn" )
395
- ( 61 , Union , "union" )
395
+ ( 59 , Auto , "auto" )
396
+ ( 60 , Catch , "catch" )
397
+ ( 61 , Default , "default" )
398
+ ( 62 , Dyn , "dyn" )
399
+ ( 63 , Union , "union" )
396
400
}
397
401
398
402
// If an interner exists, return it. Otherwise, prepare a fresh one.
You can’t perform that action at this time.
0 commit comments