Unnamed repository; edit this file 'description' to name the repository.
Fix raw ident handling (a little)
Amos Wenger 2022-07-22
parent 941416a · commit 246947b
-rw-r--r--crates/proc-macro-srv/src/tests/mod.rs6
-rw-r--r--crates/proc-macro-test/imp/src/lib.rs9
2 files changed, 11 insertions, 4 deletions
diff --git a/crates/proc-macro-srv/src/tests/mod.rs b/crates/proc-macro-srv/src/tests/mod.rs
index 1277106d71..07222907f0 100644
--- a/crates/proc-macro-srv/src/tests/mod.rs
+++ b/crates/proc-macro-srv/src/tests/mod.rs
@@ -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"#]],
);
}
diff --git a/crates/proc-macro-test/imp/src/lib.rs b/crates/proc-macro-test/imp/src/lib.rs
index 7760774a3f..feeacdb640 100644
--- a/crates/proc-macro-test/imp/src/lib.rs
+++ b/crates/proc-macro-test/imp/src/lib.rs
@@ -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());