-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #79326 - Aaron1011:fix/builtin-macro-stmt, r=petrochenkov
Always invoke statement attributes on the statement itself This is preparation for PR #78296, which will require us to handle statement items in addition to normal items.
- Loading branch information
Showing
15 changed files
with
658 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// aux-build:attr-stmt-expr.rs | ||
// aux-build:test-macros.rs | ||
// compile-flags: -Z span-debug | ||
// check-pass | ||
|
||
#![feature(proc_macro_hygiene)] | ||
#![feature(stmt_expr_attributes)] | ||
#![feature(rustc_attrs)] | ||
#![allow(dead_code)] | ||
|
||
#![no_std] // Don't load unnecessary hygiene information from std | ||
extern crate std; | ||
|
||
extern crate attr_stmt_expr; | ||
extern crate test_macros; | ||
use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr}; | ||
use test_macros::print_attr; | ||
use std::println; | ||
|
||
fn print_str(string: &'static str) { | ||
// macros are handled a bit differently | ||
#[expect_print_expr] | ||
println!("{}", string) | ||
} | ||
|
||
macro_rules! make_stmt { | ||
($stmt:stmt) => { | ||
$stmt | ||
} | ||
} | ||
|
||
macro_rules! second_make_stmt { | ||
($stmt:stmt) => { | ||
make_stmt!($stmt); | ||
} | ||
} | ||
|
||
|
||
fn main() { | ||
make_stmt!(struct Foo {}); | ||
|
||
#[print_attr] | ||
#[expect_let] | ||
let string = "Hello, world!"; | ||
|
||
#[print_attr] | ||
#[expect_print_stmt] | ||
println!("{}", string); | ||
|
||
#[print_attr] | ||
second_make_stmt!(#[allow(dead_code)] struct Bar {}); | ||
|
||
#[print_attr] | ||
#[rustc_dummy] | ||
struct Other {}; | ||
|
||
#[expect_expr] | ||
print_str("string") | ||
} |
Oops, something went wrong.