diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-04-29 02:20:46 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-05-17 23:13:09 +0300 |
| commit | f89e3562450b4fddd36b536087d782c934dd6477 (patch) | |
| tree | 704b91ef4a6a2e3ec3fa031e857b4e816a9a9d5d /src/libsyntax/parse | |
| parent | 640884bad0199e80a7701469a3d0eae0977b5998 (diff) | |
| download | rust-f89e3562450b4fddd36b536087d782c934dd6477.tar.gz rust-f89e3562450b4fddd36b536087d782c934dd6477.zip | |
Add two keywords specific to editions 2015 and 2018 respectively
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/token.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index a1c056cbb2c..cbafad253b8 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -15,13 +15,14 @@ pub use self::Lit::*; pub use self::Token::*; use ast::{self}; +use edition::Edition; use parse::ParseSess; use print::pprust; use ptr::P; use serialize::{Decodable, Decoder, Encodable, Encoder}; use symbol::keywords; use syntax::parse::parse_stream_from_source_str; -use syntax_pos::{self, Span, FileName}; +use syntax_pos::{self, hygiene, Span, FileName}; use tokenstream::{TokenStream, TokenTree}; use tokenstream; @@ -168,7 +169,11 @@ pub fn is_used_keyword(id: ast::Ident) -> bool { /// Returns `true` if the token is a keyword reserved for possible future use. pub fn is_unused_keyword(id: ast::Ident) -> bool { - id.name >= keywords::Abstract.name() && id.name <= keywords::Yield.name() + let edition = || id.span.ctxt().outer().expn_info().map_or_else(|| hygiene::default_edition(), + |einfo| einfo.callee.edition); + id.name >= keywords::Abstract.name() && id.name <= keywords::Yield.name() || + id.name == keywords::Proc.name() && edition() == Edition::Edition2015 || + id.name == keywords::Async.name() && edition() == Edition::Edition2018 } /// Returns `true` if the token is either a special identifier or a keyword. |
