diff options
| author | kennytm <kennytm@gmail.com> | 2018-04-04 11:07:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-04 11:07:25 +0200 |
| commit | b3b7e776cb92f74c25c268f9031abdc5588a1ded (patch) | |
| tree | 85b284a92bfb98dbfe92482b31b926b600cb7bde | |
| parent | dd2ec6a0996d76dc10bcf83ea93aa655621885d8 (diff) | |
| parent | 58217edd2fbb9f51b5838c6da97ef8dc4bfdef33 (diff) | |
| download | rust-b3b7e776cb92f74c25c268f9031abdc5588a1ded.tar.gz rust-b3b7e776cb92f74c25c268f9031abdc5588a1ded.zip | |
Rollup merge of #49609 - abonander:attr-macro-stmt-expr, r=petrochenkov
run-pass/attr-stmt-expr: expand test cases Follow-up to https://github.com/rust-lang/rust/pull/49124#discussion_r178542587 r? @petrochenkov
| -rw-r--r-- | src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs | 14 | ||||
| -rw-r--r-- | src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs | 15 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs b/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs index 082dd639929..98316c62ef1 100644 --- a/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs +++ b/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs @@ -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") } diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs index 189e6bbd00d..972368b7b53 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs @@ -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 +} |
