mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Parse contextual dyn keyword properly in edition 2015
This commit is contained in:
parent
9fd6c695da
commit
f4199f786e
10 changed files with 164 additions and 11 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue