about summary refs log tree commit diff
diff options
context:
space:
mode:
-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() {}