docs/test: add UI test and long-form error docs for E0519
This commit is contained in:
parent
270c94e484
commit
da7fcc7a09
@ -280,6 +280,7 @@
|
|||||||
E0516: include_str!("./error_codes/E0516.md"),
|
E0516: include_str!("./error_codes/E0516.md"),
|
||||||
E0517: include_str!("./error_codes/E0517.md"),
|
E0517: include_str!("./error_codes/E0517.md"),
|
||||||
E0518: include_str!("./error_codes/E0518.md"),
|
E0518: include_str!("./error_codes/E0518.md"),
|
||||||
|
E0519: include_str!("./error_codes/E0519.md"),
|
||||||
E0520: include_str!("./error_codes/E0520.md"),
|
E0520: include_str!("./error_codes/E0520.md"),
|
||||||
E0521: include_str!("./error_codes/E0521.md"),
|
E0521: include_str!("./error_codes/E0521.md"),
|
||||||
E0522: include_str!("./error_codes/E0522.md"),
|
E0522: include_str!("./error_codes/E0522.md"),
|
||||||
@ -616,7 +617,6 @@
|
|||||||
// E0489, // type/lifetime parameter not in scope here
|
// E0489, // type/lifetime parameter not in scope here
|
||||||
E0490, // a value of type `..` is borrowed for too long
|
E0490, // a value of type `..` is borrowed for too long
|
||||||
E0514, // metadata version mismatch
|
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
|
E0523, // two dependencies have same (crate-name, disambiguator) but different SVH
|
||||||
// E0526, // shuffle indices are not constant
|
// E0526, // shuffle indices are not constant
|
||||||
// E0540, // multiple rustc_deprecated attributes
|
// E0540, // multiple rustc_deprecated attributes
|
||||||
|
40
compiler/rustc_error_codes/src/error_codes/E0519.md
Normal file
40
compiler/rustc_error_codes/src/error_codes/E0519.md
Normal file
@ -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`).
|
8
src/test/ui/error-codes/E0519.rs
Normal file
8
src/test/ui/error-codes/E0519.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// no need to create a new aux file, we can use an existing.
|
||||||
|
// aux-build: crateresolve1-1.rs
|
||||||
|
|
||||||
|
// set same metadata as `crateresolve1`
|
||||||
|
#![crate_name = "crateresolve1"]
|
||||||
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
|
extern crate crateresolve1; //~ ERROR E0519
|
9
src/test/ui/error-codes/E0519.stderr
Normal file
9
src/test/ui/error-codes/E0519.stderr
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
error[E0519]: the current crate is indistinguishable from one of its dependencies: it has the same crate-name `crateresolve1` and was compiled with the same `-C metadata` arguments. This will result in symbol conflicts between the two.
|
||||||
|
--> $DIR/E0519.rs:8:1
|
||||||
|
|
|
||||||
|
LL | extern crate crateresolve1;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0519`.
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
// A few of those error codes can't be tested but all the others can and *should* be tested!
|
// A few of those error codes can't be tested but all the others can and *should* be tested!
|
||||||
const EXEMPTED_FROM_TEST: &[&str] = &[
|
const EXEMPTED_FROM_TEST: &[&str] = &[
|
||||||
"E0313", "E0461", "E0465", "E0476", "E0490", "E0514", "E0519", "E0523", "E0554", "E0640",
|
"E0313", "E0461", "E0465", "E0476", "E0490", "E0514", "E0523", "E0554", "E0640", "E0717",
|
||||||
"E0717", "E0729", "E0789",
|
"E0729", "E0789",
|
||||||
];
|
];
|
||||||
|
|
||||||
// Some error codes don't have any tests apparently...
|
// Some error codes don't have any tests apparently...
|
||||||
|
Loading…
Reference in New Issue
Block a user