rust/tests/ui/proc-macro/expr-stmt-nonterminal-tokens.rs
2024-02-16 20:02:50 +00:00

38 lines
673 B
Rust

//@ check-pass
//@ aux-build:test-macros.rs
#![feature(decl_macro)]
#![feature(stmt_expr_attributes)]
#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;
#[macro_use]
extern crate test_macros;
macro mac {
(expr $expr:expr) => {
#[derive(Print)]
enum E {
V = { let _ = $expr; 0 },
}
},
(stmt $stmt:stmt) => {
#[derive(Print)]
enum E {
V = { let _ = { $stmt }; 0 },
}
},
}
const PATH: u8 = 2;
fn main() {
mac!(expr #[allow(warnings)] 0);
mac!(stmt 0);
mac!(stmt {});
mac!(stmt PATH);
mac!(stmt 0 + 1);
mac!(stmt PATH + 1);
}