1 // run-pass
2 #![allow(unused)]
3
4 // Like other items, private imports can be imported and used non-lexically in paths.
5 mod a {
6 use a as foo;
7 use self::foo::foo as bar;
8
9 mod b {
10 use super::bar;
11 }
12 }
13
f()14 mod foo { pub fn f() {} }
f()15 mod bar { pub fn f() {} }
16
f() -> bool17 pub fn f() -> bool { true }
18
19 // Items and explicit imports shadow globs.
g()20 fn g() {
21 use foo::*;
22 use bar::*;
23 fn f() -> bool { true }
24 let _: bool = f();
25 }
26
h()27 fn h() {
28 use foo::*;
29 use bar::*;
30 use f;
31 let _: bool = f();
32 }
33
34 // Here, there appears to be shadowing but isn't because of namespaces.
35 mod b {
36 use foo::*; // This imports `f` in the value namespace.
37 use super::b as f; // This imports `f` only in the type namespace,
test()38 fn test() { self::f(); } // so the glob isn't shadowed.
39 }
40
41 // Here, there is shadowing in one namespace, but not the other.
42 mod c {
43 mod test {
f()44 pub fn f() {}
45 pub mod f {}
46 }
47 use self::test::*; // This glob-imports `f` in both namespaces.
f()48 mod f { pub fn f() {} } // This shadows the glob only in the value namespace.
49
test()50 fn test() {
51 self::f(); // Check that the glob-imported value isn't shadowed.
52 self::f::f(); // Check that the glob-imported module is shadowed.
53 }
54 }
55
56 // Unused names can be ambiguous.
57 mod d {
58 pub use foo::*; // This imports `f` in the value namespace.
59 pub use bar::*; // This also imports `f` in the value namespace.
60 }
61
62 mod e {
63 pub use d::*; // n.b. Since `e::f` is not used, this is not considered to be a use of `d::f`.
64 }
65
main()66 fn main() {}
67