]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0519.md
Auto merge of #106262 - GuillaumeGomez:migrate-more-scraped-examples-css, r=notriddle
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0519.md
1 The current crate is indistinguishable from one of its dependencies, in terms
2 of metadata.
3
4 Example of erroneous code:
5
6 `a.rs`
7 ```ignore (cannot-link-with-other-tests)
8 #![crate_name = "a"]
9 #![crate_type = "lib"]
10
11 pub fn foo() {}
12 ```
13
14 `b.rs`
15 ```ignore (cannot-link-with-other-tests)
16 #![crate_name = "a"]
17 #![crate_type = "lib"]
18
19 // error: the current crate is indistinguishable from one of its dependencies:
20 //        it has the same crate-name `a` and was compiled with the same
21 //        `-C metadata` arguments. This will result in symbol conflicts between
22 //        the two.
23 extern crate a;
24
25 pub fn foo() {}
26
27 fn bar() {
28     a::foo(); // is this calling the local crate or the dependency?
29 }
30 ```
31
32 The above example compiles two crates with exactly the same name and
33 `crate_type` (plus any other metadata). This causes an error because it becomes
34 impossible for the compiler to distinguish between symbols (`pub` item names).
35
36 This error can be fixed by:
37  * Using [Cargo](../cargo/index.html), the Rust package manager, automatically
38    fixing this issue.
39  * Recompiling the crate with different metadata (different name/
40    `crate_type`).