Skip to content

Commit db0d0e8

Browse files
committed
Add additional semicolon test
1 parent 758834d commit db0d0e8

File tree

4 files changed

+126
-108
lines changed

4 files changed

+126
-108
lines changed

src/test/ui/proc-macro/allowed-attr-stmt-expr.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ fn print_str(string: &'static str) {
2626
macro_rules! make_stmt {
2727
($stmt:stmt) => {
2828
#[print_attr]
29-
#[allow(unused)]
30-
$stmt
29+
#[rustc_dummy]
30+
$stmt; // This semicolon is *not* passed to the macro,
31+
// since `$stmt` is already a statement.
3132
}
3233
}
3334

@@ -37,6 +38,10 @@ macro_rules! second_make_stmt {
3738
}
3839
}
3940

41+
// The macro will see a semicolon here
42+
#[print_attr]
43+
struct ItemWithSemi;
44+
4045

4146
fn main() {
4247
make_stmt!(struct Foo {});
@@ -56,6 +61,12 @@ fn main() {
5661
#[rustc_dummy]
5762
struct Other {};
5863

64+
// The macro also sees a semicolon,
65+
// for consistency with the `ItemWithSemi` case above.
66+
#[print_attr]
67+
#[rustc_dummy]
68+
struct NonBracedStruct;
69+
5970
#[expect_expr]
6071
print_str("string")
6172
}

0 commit comments

Comments
 (0)