mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Make tt generic over the span data
This commit is contained in:
parent
d805c74c51
commit
41a46a78f2
48 changed files with 806 additions and 569 deletions
|
@ -9,7 +9,7 @@ use test_utils::{bench, bench_fixture, skip_slow_tests};
|
|||
|
||||
use crate::{
|
||||
parser::{MetaVarKind, Op, RepeatKind, Separator},
|
||||
syntax_node_to_token_tree, DeclarativeMacro,
|
||||
syntax_node_to_token_tree, tt, DeclarativeMacro,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
@ -91,7 +91,14 @@ fn invocation_fixtures(rules: &FxHashMap<String, DeclarativeMacro>) -> Vec<(Stri
|
|||
// So we just skip any error cases and try again
|
||||
let mut try_cnt = 0;
|
||||
loop {
|
||||
let mut subtree = tt::Subtree::default();
|
||||
let mut subtree = tt::Subtree {
|
||||
delimiter: tt::Delimiter {
|
||||
open: tt::TokenId::UNSPECIFIED,
|
||||
close: tt::TokenId::UNSPECIFIED,
|
||||
kind: tt::DelimiterKind::Invisible,
|
||||
},
|
||||
token_trees: vec![],
|
||||
};
|
||||
for op in rule.lhs.iter() {
|
||||
collect_from_op(op, &mut subtree, &mut seed);
|
||||
}
|
||||
|
@ -196,12 +203,15 @@ fn invocation_fixtures(rules: &FxHashMap<String, DeclarativeMacro>) -> Vec<(Stri
|
|||
*seed
|
||||
}
|
||||
fn make_ident(ident: &str) -> tt::TokenTree {
|
||||
tt::Leaf::Ident(tt::Ident { id: tt::TokenId::unspecified(), text: SmolStr::new(ident) })
|
||||
.into()
|
||||
tt::Leaf::Ident(tt::Ident {
|
||||
span: tt::TokenId::unspecified(),
|
||||
text: SmolStr::new(ident),
|
||||
})
|
||||
.into()
|
||||
}
|
||||
fn make_punct(char: char) -> tt::TokenTree {
|
||||
tt::Leaf::Punct(tt::Punct {
|
||||
id: tt::TokenId::unspecified(),
|
||||
span: tt::TokenId::unspecified(),
|
||||
char,
|
||||
spacing: tt::Spacing::Alone,
|
||||
})
|
||||
|
@ -209,7 +219,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, DeclarativeMacro>) -> Vec<(Stri
|
|||
}
|
||||
fn make_literal(lit: &str) -> tt::TokenTree {
|
||||
tt::Leaf::Literal(tt::Literal {
|
||||
id: tt::TokenId::unspecified(),
|
||||
span: tt::TokenId::unspecified(),
|
||||
text: SmolStr::new(lit),
|
||||
})
|
||||
.into()
|
||||
|
@ -219,7 +229,11 @@ fn invocation_fixtures(rules: &FxHashMap<String, DeclarativeMacro>) -> Vec<(Stri
|
|||
token_trees: Option<Vec<tt::TokenTree>>,
|
||||
) -> tt::TokenTree {
|
||||
tt::Subtree {
|
||||
delimiter: Some(tt::Delimiter { id: tt::TokenId::unspecified(), kind }),
|
||||
delimiter: tt::Delimiter {
|
||||
open: tt::TokenId::unspecified(),
|
||||
close: tt::TokenId::unspecified(),
|
||||
kind,
|
||||
},
|
||||
token_trees: token_trees.unwrap_or_default(),
|
||||
}
|
||||
.into()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue