mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Fix raw ident handling (a little)
This commit is contained in:
parent
941416a1d6
commit
246947b779
2 changed files with 11 additions and 4 deletions
|
@ -60,10 +60,10 @@ fn test_fn_like_macro_clone_ident_subtree() {
|
|||
fn test_fn_like_macro_clone_raw_ident() {
|
||||
assert_expand(
|
||||
"fn_like_clone_tokens",
|
||||
"r#\"ident\"#",
|
||||
expect![[r##"
|
||||
"r#async",
|
||||
expect![[r#"
|
||||
SUBTREE $
|
||||
LITERAL r#"ident"# 4294967295"##]],
|
||||
IDENT async 4294967295"#]],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,14 @@ fn clone_tree(t: TokenTree) -> TokenTree {
|
|||
new.set_span(orig.span());
|
||||
TokenTree::Group(new)
|
||||
}
|
||||
TokenTree::Ident(orig) => TokenTree::Ident(Ident::new(&orig.to_string(), orig.span())),
|
||||
TokenTree::Ident(orig) => {
|
||||
let s = orig.to_string();
|
||||
if let Some(rest) = s.strip_prefix("r#") {
|
||||
TokenTree::Ident(Ident::new_raw(rest, orig.span()))
|
||||
} else {
|
||||
TokenTree::Ident(Ident::new(&s, orig.span()))
|
||||
}
|
||||
}
|
||||
TokenTree::Punct(orig) => {
|
||||
let mut new = Punct::new(orig.as_char(), orig.spacing());
|
||||
new.set_span(orig.span());
|
||||
|
|
Loading…
Reference in a new issue