Skip to content

Commit 246947b

Browse files
Fix raw ident handling (a little)
1 parent 941416a commit 246947b

File tree

2 files changed

+11
-4
lines changed
  • crates

2 files changed

+11
-4
lines changed

crates/proc-macro-srv/src/tests/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ fn test_fn_like_macro_clone_ident_subtree() {
6060
fn test_fn_like_macro_clone_raw_ident() {
6161
assert_expand(
6262
"fn_like_clone_tokens",
63-
"r#\"ident\"#",
64-
expect![[r##"
63+
"r#async",
64+
expect![[r#"
6565
SUBTREE $
66-
LITERAL r#"ident"# 4294967295"##]],
66+
IDENT async 4294967295"#]],
6767
);
6868
}
6969

crates/proc-macro-test/imp/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,14 @@ fn clone_tree(t: TokenTree) -> TokenTree {
9090
new.set_span(orig.span());
9191
TokenTree::Group(new)
9292
}
93-
TokenTree::Ident(orig) => TokenTree::Ident(Ident::new(&orig.to_string(), orig.span())),
93+
TokenTree::Ident(orig) => {
94+
let s = orig.to_string();
95+
if let Some(rest) = s.strip_prefix("r#") {
96+
TokenTree::Ident(Ident::new_raw(rest, orig.span()))
97+
} else {
98+
TokenTree::Ident(Ident::new(&s, orig.span()))
99+
}
100+
}
94101
TokenTree::Punct(orig) => {
95102
let mut new = Punct::new(orig.as_char(), orig.spacing());
96103
new.set_span(orig.span());

0 commit comments

Comments
 (0)