summaryrefslogtreecommitdiffstats
path: root/src/test/ui/proc-macro/auxiliary/raw-ident.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/proc-macro/auxiliary/raw-ident.rs')
-rw-r--r--src/test/ui/proc-macro/auxiliary/raw-ident.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/proc-macro/auxiliary/raw-ident.rs b/src/test/ui/proc-macro/auxiliary/raw-ident.rs
new file mode 100644
index 000000000..9daee21aa
--- /dev/null
+++ b/src/test/ui/proc-macro/auxiliary/raw-ident.rs
@@ -0,0 +1,35 @@
+// force-host
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+use proc_macro::{TokenStream, TokenTree, Ident, Punct, Spacing, Span};
+
+#[proc_macro]
+pub fn make_struct(input: TokenStream) -> TokenStream {
+ match input.into_iter().next().unwrap() {
+ TokenTree::Ident(ident) => {
+ vec![
+ TokenTree::Ident(Ident::new("struct", Span::call_site())),
+ TokenTree::Ident(Ident::new_raw(&ident.to_string(), Span::call_site())),
+ TokenTree::Punct(Punct::new(';', Spacing::Alone))
+ ].into_iter().collect()
+ }
+ _ => panic!()
+ }
+}
+
+#[proc_macro]
+pub fn make_bad_struct(input: TokenStream) -> TokenStream {
+ match input.into_iter().next().unwrap() {
+ TokenTree::Ident(ident) => {
+ vec![
+ TokenTree::Ident(Ident::new_raw("struct", Span::call_site())),
+ TokenTree::Ident(Ident::new(&ident.to_string(), Span::call_site())),
+ TokenTree::Punct(Punct::new(';', Spacing::Alone))
+ ].into_iter().collect()
+ }
+ _ => panic!()
+ }
+}