about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-09-22 09:56:27 +0200
committerGitHub <noreply@github.com>2018-09-22 09:56:27 +0200
commit822c51121e7379ad72c2a2ccfed3443ecc40fbf4 (patch)
treec8bfbe482b6e2af917d6dfad6872bf2c45f15b65 /src/libsyntax
parente6ee4e056d7855cb0353efbb4207dceb9ab46414 (diff)
parentcb594cf3730c35fd6c514e98d9c7a0d78a00a02d (diff)
downloadrust-822c51121e7379ad72c2a2ccfed3443ecc40fbf4.tar.gz
rust-822c51121e7379ad72c2a2ccfed3443ecc40fbf4.zip
Rollup merge of #54261 - varkor:dyn-keyword-2018, r=petrochenkov
Make `dyn` a keyword in the 2018 edition

Proposed in https://github.com/rust-lang/rust/issues/44662#issuecomment-421596088.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/parser.rs5
-rw-r--r--src/libsyntax/parse/token.rs1
2 files changed, 4 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 6ec1ad969ee..f7af8a3c34c 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1578,8 +1578,9 @@ impl<'a> Parser<'a> {
             impl_dyn_multi = bounds.len() > 1 || self.prev_token_kind == PrevTokenKind::Plus;
             TyKind::ImplTrait(ast::DUMMY_NODE_ID, bounds)
         } else if self.check_keyword(keywords::Dyn) &&
-                  self.look_ahead(1, |t| t.can_begin_bound() &&
-                                         !can_continue_type_after_non_fn_ident(t)) {
+                  (self.span.edition() == Edition::Edition2018 ||
+                   self.look_ahead(1, |t| t.can_begin_bound() &&
+                                         !can_continue_type_after_non_fn_ident(t))) {
             self.bump(); // `dyn`
             // Always parse bounds greedily for better error recovery.
             let bounds = self.parse_generic_bounds()?;
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 6e8014284ec..01bc7f6ad30 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -136,6 +136,7 @@ fn ident_can_begin_type(ident: ast::Ident, is_raw: bool) -> bool {
         keywords::Unsafe.name(),
         keywords::Extern.name(),
         keywords::Typeof.name(),
+        keywords::Dyn.name(),
     ].contains(&ident.name)
 }