]> git.proxmox.com Git - rustc.git/blob - tests/ui/hygiene/legacy_interaction.rs
New upstream version 1.70.0+dfsg1
[rustc.git] / tests / ui / hygiene / legacy_interaction.rs
1 // check-pass
2 #![allow(dead_code)]
3
4 // aux-build:legacy_interaction.rs
5
6 #![feature(decl_macro)]
7 #[allow(unused)]
8
9 extern crate legacy_interaction;
10 // ^ defines
11 // ```rust
12 // macro_rules! m {
13 // () => {
14 // fn f() {} // (1)
15 // g() // (2)
16 // }
17 // }
18 // ```rust
19
20 mod def_site {
21 // Unless this macro opts out of hygiene, it should resolve the same wherever it is invoked.
22 pub macro m2() {
23 ::legacy_interaction::m!();
24 f(); // This should resolve to (1)
25 fn g() {} // We want (2) resolve to this, not to (4)
26 }
27 }
28
29 mod use_site {
30 fn test() {
31 fn f() -> bool { true } // (3)
32 fn g() -> bool { true } // (4)
33
34 ::def_site::m2!();
35
36 let _: bool = f(); // This should resolve to (3)
37 let _: bool = g(); // This should resolve to (4)
38 }
39 }
40
41 fn main() {}