]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/uniform-paths/macros.rs
#[feature(uniform_paths)]: allow `use x::y;` to resolve through `self::x`, not just...
[rust.git] / src / test / run-pass / uniform-paths / macros.rs
1 // Copyright 2018 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
11 // edition:2018
12
13 #![feature(uniform_paths)]
14
15 // This test is similar to `basic.rs`, but with macros defining local items.
16
17 // Test that ambiguity errors are not emitted between `self::test` and
18 // `::test`, assuming the latter (crate) is not in `extern_prelude`.
19 macro_rules! m1 {
20     () => {
21         mod test {
22             pub struct Foo(pub ());
23         }
24     }
25 }
26 use test::Foo;
27 m1!();
28
29 // Test that qualified paths can refer to both the external crate and local item.
30 macro_rules! m2 {
31     () => {
32         mod std {
33             pub struct io(pub ());
34         }
35     }
36 }
37 use ::std::io as std_io;
38 use self::std::io as local_io;
39 m2!();
40
41 fn main() {
42     Foo(());
43     std_io::stdout();
44     local_io(());
45 }