summaryrefslogtreecommitdiffstats
path: root/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs')
-rw-r--r--src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs b/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs
new file mode 100644
index 000000000..4d6dc06b4
--- /dev/null
+++ b/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs
@@ -0,0 +1,49 @@
+// force-host
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_attribute]
+pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream {
+ assert!(attr.to_string().is_empty());
+ assert_eq!(item.to_string(), "let string = \"Hello, world!\" ;");
+ item
+}
+
+#[proc_macro_attribute]
+pub fn expect_my_macro_stmt(attr: TokenStream, item: TokenStream) -> TokenStream {
+ assert!(attr.to_string().is_empty());
+ assert_eq!(item.to_string(), "my_macro! (\"{}\", string) ;");
+ item
+}
+
+#[proc_macro_attribute]
+pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
+ assert!(attr.to_string().is_empty());
+ assert_eq!(item.to_string(), "print_str(\"string\")");
+ item
+}
+
+#[proc_macro_attribute]
+pub fn expect_my_macro_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
+ assert!(attr.to_string().is_empty());
+ assert_eq!(item.to_string(), "my_macro! (\"{}\", string)");
+ item
+}
+
+#[proc_macro_attribute]
+pub fn duplicate(attr: TokenStream, item: TokenStream) -> TokenStream {
+ assert!(attr.to_string().is_empty());
+ format!("{}, {}", item, item).parse().unwrap()
+}
+
+#[proc_macro_attribute]
+pub fn no_output(attr: TokenStream, item: TokenStream) -> TokenStream {
+ assert!(attr.to_string().is_empty());
+ assert!(!item.to_string().is_empty());
+ "".parse().unwrap()
+}