]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/imports/duplicate.rs
New upstream version 1.16.0+dfsg1
[rustc.git] / src / test / compile-fail / imports / duplicate.rs
CommitLineData
9e0c209e
SL
1// Copyright 2016 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
9e0c209e
SL
11mod a {
12 pub fn foo() {}
13}
14
15mod b {
16 pub fn foo() {}
17}
18
19mod c {
20 pub use a::foo;
21}
22
23mod d {
24 use a::foo; //~ NOTE previous import
25 use a::foo; //~ ERROR `foo` has already been imported
26 //~| NOTE already imported
27}
28
29mod e {
30 pub use a::*;
31 pub use c::*; // ok
32}
33
34mod f {
32a655c1
SL
35 pub use a::*; //~ NOTE `foo` could refer to the name imported here
36 pub use b::*; //~ NOTE `foo` could also refer to the name imported here
9e0c209e
SL
37}
38
39mod g {
32a655c1
SL
40 pub use a::*; //~ NOTE `foo` could refer to the name imported here
41 pub use f::*; //~ NOTE `foo` could also refer to the name imported here
9e0c209e
SL
42}
43
44fn main() {
45 e::foo();
46 f::foo(); //~ ERROR `foo` is ambiguous
476ff2be 47 //~| NOTE consider adding an explicit import of `foo` to disambiguate
9e0c209e 48 g::foo(); //~ ERROR `foo` is ambiguous
476ff2be 49 //~| NOTE consider adding an explicit import of `foo` to disambiguate
9e0c209e
SL
50}
51
52mod ambiguous_module_errors {
53 pub mod m1 { pub use super::m1 as foo; }
54 pub mod m2 { pub use super::m2 as foo; }
55
56 use self::m1::*; //~ NOTE
57 //~| NOTE
58 use self::m2::*; //~ NOTE
59 //~| NOTE
60
61 use self::foo::bar; //~ ERROR `foo` is ambiguous
62 //~| NOTE
63
64 fn f() {
65 foo::bar(); //~ ERROR `foo` is ambiguous
66 //~| NOTE
67 }
68}