]>
Commit | Line | Data |
---|---|---|
2c00a5a8 XL |
1 | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
b7449926 | 11 | // run-pass |
2c00a5a8 XL |
12 | // ignore-pretty pretty-printing is unhygienic |
13 | ||
14 | // aux-build:legacy_interaction.rs | |
15 | ||
16 | #![feature(decl_macro)] | |
17 | #[allow(unused)] | |
18 | ||
19 | extern crate legacy_interaction; | |
20 | // ^ defines | |
21 | // ```rust | |
22 | // macro_rules! m { | |
23 | // () => { | |
24 | // fn f() // (1) | |
25 | // g() // (2) | |
26 | // } | |
27 | // } | |
28 | // ```rust | |
29 | ||
30 | mod def_site { | |
31 | // Unless this macro opts out of hygiene, it should resolve the same wherever it is invoked. | |
32 | pub macro m2() { | |
33 | ::legacy_interaction::m!(); | |
34 | f(); // This should resolve to (1) | |
35 | fn g() {} // We want (2) resolve to this, not to (4) | |
36 | } | |
37 | } | |
38 | ||
39 | mod use_site { | |
40 | fn test() { | |
41 | fn f() -> bool { true } // (3) | |
42 | fn g() -> bool { true } // (4) | |
43 | ||
44 | ::def_site::m2!(); | |
45 | ||
46 | let _: bool = f(); // This should resolve to (3) | |
47 | let _: bool = g(); // This should resolve to (4) | |
48 | } | |
49 | } | |
50 | ||
51 | fn main() {} |