]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #49609 - abonander:attr-macro-stmt-expr, r=petrochenkov
authorkennytm <kennytm@gmail.com>
Wed, 4 Apr 2018 09:07:25 +0000 (11:07 +0200)
committerGitHub <noreply@github.com>
Wed, 4 Apr 2018 09:07:25 +0000 (11:07 +0200)
run-pass/attr-stmt-expr: expand test cases

Follow-up to https://github.com/rust-lang/rust/pull/49124#discussion_r178542587

r? @petrochenkov

src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs
src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs

index 082dd63992968ae9fa4ca55dfd4c38f4c49e9201..98316c62ef135a0bf5dc4c8f4b429b5c230f0bc3 100644 (file)
@@ -14,7 +14,8 @@
 #![feature(proc_macro, stmt_expr_attributes)]
 
 extern crate attr_stmt_expr;
-use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr};
+use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr,
+                     no_output, noop};
 
 fn print_str(string: &'static str) {
     // macros are handled a bit differently
@@ -29,6 +30,17 @@ fn main() {
     #[expect_print_stmt]
     println!("{}", string);
 
+    let _: () = {
+        #[no_output]
+        "Hello, world!"
+    };
+
+    let _: &'static str = #[noop] "Hello, world!";
+
+    let _: &'static str = {
+        #[noop] "Hello, world!"
+    };
+
     #[expect_expr]
     print_str("string")
 }
index 189e6bbd00dba4e7718df7e07c336033730ca062..972368b7b532a59f825f9536334388ad535729bb 100644 (file)
@@ -44,3 +44,18 @@ pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
     assert_eq!(item.to_string(), "println!(\"{}\" , string)");
     item
 }
+
+#[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()
+
+}
+
+#[proc_macro_attribute]
+pub fn noop(attr: TokenStream, item: TokenStream) -> TokenStream {
+    assert!(attr.to_string().is_empty());
+    assert!(!item.to_string().is_empty());
+    item
+}