mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Test macros doing edition dependent parsing
This commit is contained in:
parent
2c32ee7cfa
commit
546eb6b530
8 changed files with 92 additions and 62 deletions
|
@ -3,11 +3,15 @@
|
|||
|
||||
use std::fmt;
|
||||
|
||||
use span::Edition;
|
||||
use syntax::{SyntaxKind, SyntaxKind::*, T};
|
||||
|
||||
use tt::buffer::TokenBuffer;
|
||||
|
||||
pub(crate) fn to_parser_input<S: Copy + fmt::Debug>(buffer: &TokenBuffer<'_, S>) -> parser::Input {
|
||||
pub(crate) fn to_parser_input<S: Copy + fmt::Debug>(
|
||||
edition: Edition,
|
||||
buffer: &TokenBuffer<'_, S>,
|
||||
) -> parser::Input {
|
||||
let mut res = parser::Input::default();
|
||||
|
||||
let mut current = buffer.begin();
|
||||
|
@ -60,6 +64,10 @@ pub(crate) fn to_parser_input<S: Copy + fmt::Debug>(buffer: &TokenBuffer<'_, S>)
|
|||
"_" => res.push(T![_]),
|
||||
i if i.starts_with('\'') => res.push(LIFETIME_IDENT),
|
||||
_ if ident.is_raw.yes() => res.push(IDENT),
|
||||
"gen" if !edition.at_least_2024() => res.push(IDENT),
|
||||
"async" | "await" | "dyn" | "try" if !edition.at_least_2018() => {
|
||||
res.push(IDENT)
|
||||
}
|
||||
text => match SyntaxKind::from_keyword(text) {
|
||||
Some(kind) => res.push(kind),
|
||||
None => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue