Skip to content

Commit 0878e0f

Browse files
authored
Rollup merge of #49609 - abonander:attr-macro-stmt-expr, r=petrochenkov
run-pass/attr-stmt-expr: expand test cases Follow-up to #49124 (comment) r? @petrochenkov
2 parents 78e0254 + 58217ed commit 0878e0f

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

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

+13-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
#![feature(proc_macro, stmt_expr_attributes)]
1515

1616
extern crate attr_stmt_expr;
17-
use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr};
17+
use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr,
18+
no_output, noop};
1819

1920
fn print_str(string: &'static str) {
2021
// macros are handled a bit differently
@@ -29,6 +30,17 @@ fn main() {
2930
#[expect_print_stmt]
3031
println!("{}", string);
3132

33+
let _: () = {
34+
#[no_output]
35+
"Hello, world!"
36+
};
37+
38+
let _: &'static str = #[noop] "Hello, world!";
39+
40+
let _: &'static str = {
41+
#[noop] "Hello, world!"
42+
};
43+
3244
#[expect_expr]
3345
print_str("string")
3446
}

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

+15
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,18 @@ pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
4444
assert_eq!(item.to_string(), "println!(\"{}\" , string)");
4545
item
4646
}
47+
48+
#[proc_macro_attribute]
49+
pub fn no_output(attr: TokenStream, item: TokenStream) -> TokenStream {
50+
assert!(attr.to_string().is_empty());
51+
assert!(!item.to_string().is_empty());
52+
"".parse().unwrap()
53+
54+
}
55+
56+
#[proc_macro_attribute]
57+
pub fn noop(attr: TokenStream, item: TokenStream) -> TokenStream {
58+
assert!(attr.to_string().is_empty());
59+
assert!(!item.to_string().is_empty());
60+
item
61+
}

0 commit comments

Comments
 (0)