]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0255.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0255.md
1 You can't import a value whose name is the same as another value defined in the
2 module.
3
4 Erroneous code example:
5
6 ```compile_fail,E0255
7 use bar::foo; // error: an item named `foo` is already in scope
8
9 fn foo() {}
10
11 mod bar {
12      pub fn foo() {}
13 }
14
15 fn main() {}
16 ```
17
18 You can use aliases in order to fix this error. Example:
19
20 ```
21 use bar::foo as bar_foo; // ok!
22
23 fn foo() {}
24
25 mod bar {
26      pub fn foo() {}
27 }
28
29 fn main() {}
30 ```
31
32 Or you can reference the item with its parent:
33
34 ```
35 fn foo() {}
36
37 mod bar {
38      pub fn foo() {}
39 }
40
41 fn main() {
42     bar::foo(); // we get the item by referring to its parent
43 }
44 ```