]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0252.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0252.md
1 Two items of the same name cannot be imported without rebinding one of the
2 items under a new local name.
3
4 Erroneous code example:
5
6 ```compile_fail,E0252
7 use foo::baz;
8 use bar::baz; // error, do `use bar::baz as quux` instead
9
10 fn main() {}
11
12 mod foo {
13     pub struct baz;
14 }
15
16 mod bar {
17     pub mod baz {}
18 }
19 ```
20
21 You can use aliases in order to fix this error. Example:
22
23 ```
24 use foo::baz as foo_baz;
25 use bar::baz; // ok!
26
27 fn main() {}
28
29 mod foo {
30     pub struct baz;
31 }
32
33 mod bar {
34     pub mod baz {}
35 }
36 ```
37
38 Or you can reference the item with its parent:
39
40 ```
41 use bar::baz;
42
43 fn main() {
44     let x = foo::baz; // ok!
45 }
46
47 mod foo {
48     pub struct baz;
49 }
50
51 mod bar {
52     pub mod baz {}
53 }
54 ```