Skip to content

Commit

Permalink
Rollup merge of rust-lang#49609 - abonander:attr-macro-stmt-expr, r=p…
Browse files Browse the repository at this point in the history
…etrochenkov

run-pass/attr-stmt-expr: expand test cases

Follow-up to rust-lang#49124 (comment)

r? @petrochenkov
  • Loading branch information
kennytm authored Apr 3, 2018
2 parents 78e0254 + 58217ed commit 0878e0f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
}
15 changes: 15 additions & 0 deletions src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 0878e0f

Please sign in to comment.