diff options
| author | Ezra Shaw <ezrasure@outlook.com> | 2022-12-21 13:48:12 +1300 |
|---|---|---|
| committer | Ezra Shaw <ezrasure@outlook.com> | 2022-12-29 13:16:10 +1300 |
| commit | da7fcc7a09c213808134561ce99303b8d559d02b (patch) | |
| tree | 5fef35a9e58afc211630d229e41a1730d12dc79a /compiler/rustc_error_codes/src | |
| parent | 270c94e484e19764a2832ef918c95224eb3f17c7 (diff) | |
| download | rust-da7fcc7a09c213808134561ce99303b8d559d02b.tar.gz rust-da7fcc7a09c213808134561ce99303b8d559d02b.zip | |
docs/test: add UI test and long-form error docs for `E0519`
Diffstat (limited to 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0519.md | 40 |
2 files changed, 41 insertions, 1 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index e6d26240e24..68eac479f9e 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -280,6 +280,7 @@ E0515: include_str!("./error_codes/E0515.md"), E0516: include_str!("./error_codes/E0516.md"), E0517: include_str!("./error_codes/E0517.md"), E0518: include_str!("./error_codes/E0518.md"), +E0519: include_str!("./error_codes/E0519.md"), E0520: include_str!("./error_codes/E0520.md"), E0521: include_str!("./error_codes/E0521.md"), E0522: include_str!("./error_codes/E0522.md"), @@ -616,7 +617,6 @@ E0791: include_str!("./error_codes/E0791.md"), // E0489, // type/lifetime parameter not in scope here E0490, // a value of type `..` is borrowed for too long E0514, // metadata version mismatch - E0519, // local crate and dependency have same (crate-name, disambiguator) E0523, // two dependencies have same (crate-name, disambiguator) but different SVH // E0526, // shuffle indices are not constant // E0540, // multiple rustc_deprecated attributes diff --git a/compiler/rustc_error_codes/src/error_codes/E0519.md b/compiler/rustc_error_codes/src/error_codes/E0519.md new file mode 100644 index 00000000000..12876e2ad75 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0519.md @@ -0,0 +1,40 @@ +The current crate is indistinguishable from one of its dependencies, in terms +of metadata. + +Example of erroneous code: + +`a.rs` +```ignore (cannot-link-with-other-tests) +#![crate_name = "a"] +#![crate_type = "lib"] + +pub fn foo() {} +``` + +`b.rs` +```ignore (cannot-link-with-other-tests) +#![crate_name = "a"] +#![crate_type = "lib"] + +// error: the current crate is indistinguishable from one of its dependencies: +// it has the same crate-name `a` and was compiled with the same +// `-C metadata` arguments. This will result in symbol conflicts between +// the two. +extern crate a; + +pub fn foo() {} + +fn bar() { + a::foo(); // is this calling the local crate or the dependency? +} +``` + +The above example compiles two crates with exactly the same name and +`crate_type` (plus any other metadata). This causes an error because it becomes +impossible for the compiler to distinguish between symbols (`pub` item names). + +This error can be fixed by: + * Using [Cargo](../cargo/index.html), the Rust package manager, automatically + fixing this issue. + * Recompiling the crate with different metadata (different name/ + `crate_type`). |
