Skip to content

Commit 6d225bb

Browse files
authored
Rollup merge of #100599 - MatthewPeterKelly:add-E0523-description-and-test, r=compiler-errors,GuillaumeGomez
Add compiler error E0523 long description and test This PR is one step towards addressing: #61137.
2 parents e4dd9ed + 2bcd4e2 commit 6d225bb

File tree

9 files changed

+75
-15
lines changed

9 files changed

+75
-15
lines changed

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ E0519: include_str!("./error_codes/E0519.md"),
286286
E0520: include_str!("./error_codes/E0520.md"),
287287
E0521: include_str!("./error_codes/E0521.md"),
288288
E0522: include_str!("./error_codes/E0522.md"),
289+
E0523: include_str!("./error_codes/E0523.md"),
289290
E0524: include_str!("./error_codes/E0524.md"),
290291
E0525: include_str!("./error_codes/E0525.md"),
291292
E0527: include_str!("./error_codes/E0527.md"),
@@ -622,7 +623,6 @@ E0793: include_str!("./error_codes/E0793.md"),
622623
// E0488, // lifetime of variable does not enclose its declaration
623624
// E0489, // type/lifetime parameter not in scope here
624625
// E0490, // removed: unreachable
625-
E0523, // two dependencies have same (crate-name, disambiguator) but different SVH
626626
// E0526, // shuffle indices are not constant
627627
// E0540, // multiple rustc_deprecated attributes
628628
// E0548, // replaced with a generic attribute input check
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
The compiler found multiple library files with the requested crate name.
22

3+
```compile_fail
4+
// aux-build:crateresolve-1.rs
5+
// aux-build:crateresolve-2.rs
6+
// aux-build:crateresolve-3.rs
7+
8+
extern crate crateresolve;
9+
//~^ ERROR multiple candidates for `rlib` dependency `crateresolve` found
10+
11+
fn main() {}
12+
```
13+
314
This error can occur in several different cases -- for example, when using
415
`extern crate` or passing `--extern` options without crate paths. It can also be
516
caused by caching issues with the build directory, in which case `cargo clean`
617
may help.
18+
19+
In the above example, there are three different library files, all of which
20+
define the same crate name. Without providing a full path, there is no way for
21+
the compiler to know which crate it should use.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
3+
The compiler found multiple library files with the requested crate name.
4+
5+
```compile_fail
6+
// aux-build:crateresolve-1.rs
7+
// aux-build:crateresolve-2.rs
8+
// aux-build:crateresolve-3.rs
9+
10+
extern crate crateresolve;
11+
//~^ ERROR multiple candidates for `rlib` dependency `crateresolve` found
12+
13+
fn main() {}
14+
```
15+
16+
This error can occur in several different cases -- for example, when using
17+
`extern crate` or passing `--extern` options without crate paths. It can also be
18+
caused by caching issues with the build directory, in which case `cargo clean`
19+
may help.
20+
21+
In the above example, there are three different library files, all of which
22+
define the same crate name. Without providing a full path, there is no way for
23+
the compiler to know which crate it should use.
24+
25+
*Note that E0523 has been merged into E0464.*

compiler/rustc_metadata/src/creader.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,12 @@ impl<'a> CrateLoader<'a> {
356356
for (_, other) in self.cstore.iter_crate_data() {
357357
// Same stable crate id but different SVH
358358
if other.stable_crate_id() == root.stable_crate_id() && other.hash() != root.hash() {
359-
return Err(CrateError::SymbolConflictsOthers(root.name()));
359+
bug!(
360+
"Previously returned E0523 here. \
361+
See https://github.com/rust-lang/rust/pull/100599 for additional discussion.\
362+
root.name() = {}.",
363+
root.name()
364+
);
360365
}
361366
}
362367

compiler/rustc_metadata/src/errors.rs

-8
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,6 @@ pub struct SymbolConflictsCurrent {
511511
pub crate_name: Symbol,
512512
}
513513

514-
#[derive(Diagnostic)]
515-
#[diag(metadata_symbol_conflicts_others, code = "E0523")]
516-
pub struct SymbolConflictsOthers {
517-
#[primary_span]
518-
pub span: Span,
519-
pub crate_name: Symbol,
520-
}
521-
522514
#[derive(Diagnostic)]
523515
#[diag(metadata_stable_crate_id_collision)]
524516
pub struct StableCrateIdCollision {

compiler/rustc_metadata/src/locator.rs

-4
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,6 @@ pub(crate) enum CrateError {
945945
ExternLocationNotFile(Symbol, PathBuf),
946946
MultipleCandidates(Symbol, CrateFlavor, Vec<PathBuf>),
947947
SymbolConflictsCurrent(Symbol),
948-
SymbolConflictsOthers(Symbol),
949948
StableCrateIdCollision(Symbol, Symbol),
950949
DlOpen(String),
951950
DlSym(String),
@@ -989,9 +988,6 @@ impl CrateError {
989988
CrateError::SymbolConflictsCurrent(root_name) => {
990989
sess.emit_err(errors::SymbolConflictsCurrent { span, crate_name: root_name });
991990
}
992-
CrateError::SymbolConflictsOthers(root_name) => {
993-
sess.emit_err(errors::SymbolConflictsOthers { span, crate_name: root_name });
994-
}
995991
CrateError::StableCrateIdCollision(crate_name0, crate_name1) => {
996992
sess.emit_err(errors::StableCrateIdCollision { span, crate_name0, crate_name1 });
997993
}

src/tools/tidy/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E06
3131

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

3636
macro_rules! verbose_print {
3737
($verbose:expr, $($fmt:tt)*) => {

tests/ui/error-codes/E0523.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// aux-build:crateresolve1-1.rs
2+
// aux-build:crateresolve1-2.rs
3+
// aux-build:crateresolve1-3.rs
4+
5+
// normalize-stderr-test: "\.nll/" -> "/"
6+
// normalize-stderr-test: "\\\?\\" -> ""
7+
// normalize-stderr-test: "(lib)?crateresolve1-([123])\.[a-z]+" -> "libcrateresolve1-$2.somelib"
8+
9+
// NOTE: This test is duplicated from `tests/ui/crate-loading/crateresolve1.rs`.
10+
11+
extern crate crateresolve1;
12+
//~^ ERROR multiple candidates for `rlib` dependency `crateresolve1` found
13+
14+
fn main() {}

tests/ui/error-codes/E0523.stderr

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0464]: multiple candidates for `rlib` dependency `crateresolve1` found
2+
--> $DIR/E0523.rs:11:1
3+
|
4+
LL | extern crate crateresolve1;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: candidate #1: $TEST_BUILD_DIR/error-codes/E0523/auxiliary/libcrateresolve1-1.somelib
8+
= note: candidate #2: $TEST_BUILD_DIR/error-codes/E0523/auxiliary/libcrateresolve1-2.somelib
9+
= note: candidate #3: $TEST_BUILD_DIR/error-codes/E0523/auxiliary/libcrateresolve1-3.somelib
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0464`.

0 commit comments

Comments
 (0)