Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/proc-macro-srv/src/tests/mod.rs30
-rw-r--r--crates/proc-macro-test/imp/src/lib.rs16
2 files changed, 46 insertions, 0 deletions
diff --git a/crates/proc-macro-srv/src/tests/mod.rs b/crates/proc-macro-srv/src/tests/mod.rs
index d4be992465..30e1ea3343 100644
--- a/crates/proc-macro-srv/src/tests/mod.rs
+++ b/crates/proc-macro-srv/src/tests/mod.rs
@@ -57,6 +57,35 @@ fn test_fn_like_macro_clone_ident_subtree() {
}
#[test]
+fn test_fn_like_macro_clone_raw_ident() {
+ assert_expand(
+ "fn_like_clone_tokens",
+ "r#\"ident\"#",
+ expect![[r##"
+ SUBTREE $
+ LITERAL r#"ident"# 4294967295"##]],
+ );
+}
+
+#[test]
+fn test_fn_like_mk_literals() {
+ assert_expand(
+ "fn_like_mk_literals",
+ r#""#,
+ expect![[r#"
+ SUBTREE $
+ LITERAL b"byte_string" 4294967295
+ LITERAL 'c' 4294967295
+ LITERAL "string" 4294967295
+ LITERAL "maybe \"raw\"?" 4294967295
+ LITERAL 3.14f64 4294967295
+ LITERAL 3.14 4294967295
+ LITERAL 123i64 4294967295
+ LITERAL 123 4294967295"#]],
+ );
+}
+
+#[test]
fn test_fn_like_macro_clone_literals() {
assert_expand(
"fn_like_clone_tokens",
@@ -105,6 +134,7 @@ fn list_test_macros() {
fn_like_panic [FuncLike]
fn_like_error [FuncLike]
fn_like_clone_tokens [FuncLike]
+ fn_like_mk_literals [FuncLike]
attr_noop [Attr]
attr_panic [Attr]
attr_error [Attr]
diff --git a/crates/proc-macro-test/imp/src/lib.rs b/crates/proc-macro-test/imp/src/lib.rs
index 0082eb7bda..d18b357a04 100644
--- a/crates/proc-macro-test/imp/src/lib.rs
+++ b/crates/proc-macro-test/imp/src/lib.rs
@@ -24,6 +24,22 @@ pub fn fn_like_clone_tokens(args: TokenStream) -> TokenStream {
clone_stream(args)
}
+#[proc_macro]
+pub fn fn_like_mk_literals(_args: TokenStream) -> TokenStream {
+ let trees: Vec<TokenTree> = vec![
+ TokenTree::from(Literal::byte_string(b"byte_string")),
+ TokenTree::from(Literal::character('c')),
+ TokenTree::from(Literal::string("string")),
+ // as of 2022-07-21, there's no method on `Literal` to build a raw
+ // string or a raw byte string
+ TokenTree::from(Literal::f64_suffixed(3.14)),
+ TokenTree::from(Literal::f64_unsuffixed(3.14)),
+ TokenTree::from(Literal::i64_suffixed(123)),
+ TokenTree::from(Literal::i64_unsuffixed(123)),
+ ];
+ TokenStream::from_iter(trees)
+}
+
#[proc_macro_attribute]
pub fn attr_noop(_args: TokenStream, item: TokenStream) -> TokenStream {
item