Skip to content

Commit

Permalink
Rollup merge of rust-lang#100599 - MatthewPeterKelly:add-E0523-descri…
Browse files Browse the repository at this point in the history
…ption-and-test, r=compiler-errors,GuillaumeGomez

Add compiler error E0523 long description and test

This PR is one step towards addressing:  rust-lang#61137.
  • Loading branch information
matthiaskrgr authored Feb 7, 2023
2 parents e4dd9ed + 2bcd4e2 commit 6d225bb
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 15 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ 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"),
E0523: include_str!("./error_codes/E0523.md"),
E0524: include_str!("./error_codes/E0524.md"),
E0525: include_str!("./error_codes/E0525.md"),
E0527: include_str!("./error_codes/E0527.md"),
Expand Down Expand Up @@ -622,7 +623,6 @@ E0793: include_str!("./error_codes/E0793.md"),
// E0488, // lifetime of variable does not enclose its declaration
// E0489, // type/lifetime parameter not in scope here
// E0490, // removed: unreachable
E0523, // two dependencies have same (crate-name, disambiguator) but different SVH
// E0526, // shuffle indices are not constant
// E0540, // multiple rustc_deprecated attributes
// E0548, // replaced with a generic attribute input check
Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0464.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
The compiler found multiple library files with the requested crate name.

```compile_fail
// aux-build:crateresolve-1.rs
// aux-build:crateresolve-2.rs
// aux-build:crateresolve-3.rs
extern crate crateresolve;
//~^ ERROR multiple candidates for `rlib` dependency `crateresolve` found
fn main() {}
```

This error can occur in several different cases -- for example, when using
`extern crate` or passing `--extern` options without crate paths. It can also be
caused by caching issues with the build directory, in which case `cargo clean`
may help.

In the above example, there are three different library files, all of which
define the same crate name. Without providing a full path, there is no way for
the compiler to know which crate it should use.
25 changes: 25 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0523.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#### Note: this error code is no longer emitted by the compiler.

The compiler found multiple library files with the requested crate name.

```compile_fail
// aux-build:crateresolve-1.rs
// aux-build:crateresolve-2.rs
// aux-build:crateresolve-3.rs
extern crate crateresolve;
//~^ ERROR multiple candidates for `rlib` dependency `crateresolve` found
fn main() {}
```

This error can occur in several different cases -- for example, when using
`extern crate` or passing `--extern` options without crate paths. It can also be
caused by caching issues with the build directory, in which case `cargo clean`
may help.

In the above example, there are three different library files, all of which
define the same crate name. Without providing a full path, there is no way for
the compiler to know which crate it should use.

*Note that E0523 has been merged into E0464.*
7 changes: 6 additions & 1 deletion compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,12 @@ impl<'a> CrateLoader<'a> {
for (_, other) in self.cstore.iter_crate_data() {
// Same stable crate id but different SVH
if other.stable_crate_id() == root.stable_crate_id() && other.hash() != root.hash() {
return Err(CrateError::SymbolConflictsOthers(root.name()));
bug!(
"Previously returned E0523 here. \
See https://github.com/rust-lang/rust/pull/100599 for additional discussion.\
root.name() = {}.",
root.name()
);
}
}

Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_metadata/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,6 @@ pub struct SymbolConflictsCurrent {
pub crate_name: Symbol,
}

#[derive(Diagnostic)]
#[diag(metadata_symbol_conflicts_others, code = "E0523")]
pub struct SymbolConflictsOthers {
#[primary_span]
pub span: Span,
pub crate_name: Symbol,
}

#[derive(Diagnostic)]
#[diag(metadata_stable_crate_id_collision)]
pub struct StableCrateIdCollision {
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,6 @@ pub(crate) enum CrateError {
ExternLocationNotFile(Symbol, PathBuf),
MultipleCandidates(Symbol, CrateFlavor, Vec<PathBuf>),
SymbolConflictsCurrent(Symbol),
SymbolConflictsOthers(Symbol),
StableCrateIdCollision(Symbol, Symbol),
DlOpen(String),
DlSym(String),
Expand Down Expand Up @@ -989,9 +988,6 @@ impl CrateError {
CrateError::SymbolConflictsCurrent(root_name) => {
sess.emit_err(errors::SymbolConflictsCurrent { span, crate_name: root_name });
}
CrateError::SymbolConflictsOthers(root_name) => {
sess.emit_err(errors::SymbolConflictsOthers { span, crate_name: root_name });
}
CrateError::StableCrateIdCollision(crate_name0, crate_name1) => {
sess.emit_err(errors::StableCrateIdCollision { span, crate_name0, crate_name1 });
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E06

// Error codes that don't yet have a UI test. This list will eventually be removed.
const IGNORE_UI_TEST_CHECK: &[&str] =
&["E0461", "E0465", "E0476", "E0514", "E0523", "E0554", "E0640", "E0717", "E0729"];
&["E0461", "E0465", "E0476", "E0514", "E0554", "E0640", "E0717", "E0729"];

macro_rules! verbose_print {
($verbose:expr, $($fmt:tt)*) => {
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/error-codes/E0523.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// aux-build:crateresolve1-1.rs
// aux-build:crateresolve1-2.rs
// aux-build:crateresolve1-3.rs

// normalize-stderr-test: "\.nll/" -> "/"
// normalize-stderr-test: "\\\?\\" -> ""
// normalize-stderr-test: "(lib)?crateresolve1-([123])\.[a-z]+" -> "libcrateresolve1-$2.somelib"

// NOTE: This test is duplicated from `tests/ui/crate-loading/crateresolve1.rs`.

extern crate crateresolve1;
//~^ ERROR multiple candidates for `rlib` dependency `crateresolve1` found

fn main() {}
13 changes: 13 additions & 0 deletions tests/ui/error-codes/E0523.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error[E0464]: multiple candidates for `rlib` dependency `crateresolve1` found
--> $DIR/E0523.rs:11:1
|
LL | extern crate crateresolve1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: candidate #1: $TEST_BUILD_DIR/error-codes/E0523/auxiliary/libcrateresolve1-1.somelib
= note: candidate #2: $TEST_BUILD_DIR/error-codes/E0523/auxiliary/libcrateresolve1-2.somelib
= note: candidate #3: $TEST_BUILD_DIR/error-codes/E0523/auxiliary/libcrateresolve1-3.somelib

error: aborting due to previous error

For more information about this error, try `rustc --explain E0464`.

0 comments on commit 6d225bb

Please sign in to comment.