Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/parser/src/shortcuts.rs')
| -rw-r--r-- | crates/parser/src/shortcuts.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/parser/src/shortcuts.rs b/crates/parser/src/shortcuts.rs index 7f49cc087a..1cf81e79b0 100644 --- a/crates/parser/src/shortcuts.rs +++ b/crates/parser/src/shortcuts.rs @@ -12,7 +12,7 @@ use std::mem; use crate::{ - LexedStr, Step, + Edition, LexedStr, Step, SyntaxKind::{self, *}, }; @@ -25,7 +25,7 @@ pub enum StrStep<'a> { } impl LexedStr<'_> { - pub fn to_input(&self) -> crate::Input { + pub fn to_input(&self, edition: Edition) -> crate::Input { let _p = tracing::info_span!("LexedStr::to_input").entered(); let mut res = crate::Input::default(); let mut was_joint = false; @@ -35,8 +35,11 @@ impl LexedStr<'_> { was_joint = false } else if kind == SyntaxKind::IDENT { let token_text = self.text(i); - let contextual_kw = - SyntaxKind::from_contextual_keyword(token_text).unwrap_or(SyntaxKind::IDENT); + let contextual_kw = if !edition.at_least_2018() && token_text == "dyn" { + SyntaxKind::DYN_KW + } else { + SyntaxKind::from_contextual_keyword(token_text).unwrap_or(SyntaxKind::IDENT) + }; res.push_ident(contextual_kw); } else { if was_joint { |