]> git.lizzy.rs Git - rust.git/blob - tests/ui/macros/macro-expansion-tests.rs
Rollup merge of #106717 - klensy:typo, r=lcnr
[rust.git] / tests / ui / macros / macro-expansion-tests.rs
1 #![allow(unused_macros)]
2
3 mod macros_cant_escape_fns {
4     fn f() {
5         macro_rules! m { () => { 3 + 4 } }
6     }
7     fn g() -> i32 { m!() }
8     //~^ ERROR cannot find macro
9 }
10
11 mod macros_cant_escape_mods {
12     mod f {
13         macro_rules! m { () => { 3 + 4 } }
14     }
15     fn g() -> i32 { m!() }
16     //~^ ERROR cannot find macro
17 }
18
19 mod macros_can_escape_flattened_mods_test {
20     #[macro_use]
21     mod f {
22         macro_rules! m { () => { 3 + 4 } }
23     }
24     fn g() -> i32 { m!() }
25 }
26
27 fn macro_tokens_should_match() {
28     macro_rules! m { (a) => { 13 } }
29     m!(a);
30 }
31
32 // should be able to use a bound identifier as a literal in a macro definition:
33 fn self_macro_parsing() {
34     macro_rules! foo { (zz) => { 287; } }
35     fn f(zz: i32) {
36         foo!(zz);
37     }
38 }
39
40 fn main() {}