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