about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2023-07-23 10:09:43 +0000
committerDeadbeef <ent3rm4n@gmail.com>2023-07-23 10:09:43 +0000
commit0d9c871736092fa804e1edf4e2d198cf2fe659df (patch)
tree06ba569f8072dc8091bd9385665e529239975e7b
parentdf9bd80d74b72aacf336d4f1a4e44ddaff2757ba (diff)
downloadrust-0d9c871736092fa804e1edf4e2d198cf2fe659df.tar.gz
rust-0d9c871736092fa804e1edf4e2d198cf2fe659df.zip
add proc macro test
-rw-r--r--tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs14
-rw-r--r--tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs16
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs
new file mode 100644
index 00000000000..0907061d64a
--- /dev/null
+++ b/tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs
@@ -0,0 +1,14 @@
+// force-host
+// edition: 2018
+// no-prefer-dynamic
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+use std::str::FromStr;
+
+#[proc_macro]
+pub fn number_of_tokens(_: TokenStream) -> TokenStream {
+    TokenStream::from_str("c\"\"").unwrap().into_iter().count().to_string().parse().unwrap()
+}
diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs
new file mode 100644
index 00000000000..b3557c71b74
--- /dev/null
+++ b/tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs
@@ -0,0 +1,16 @@
+// even if this crate is edition 2021, proc macros compiled using older
+// editions should still be able to observe the pre-2021 token behavior
+//
+// adapted from tests/ui/rust-2021/reserved-prefixes-via-macro.rs
+
+// edition: 2021
+// check-pass
+
+// aux-build: count.rs
+extern crate count;
+
+const _: () = {
+    assert!(count::number_of_tokens!() == 2);
+};
+
+fn main() {}