Skip to content

Commit cc6a090

Browse files
committed
Add long explanation for E0464
The test is copied from `src/test/ui/crate-loading/crateresolve1.rs` and its auxiliary tests. I added it to the `compile_fail` code example check exemption list since it's hard if not impossible to reproduce this error in a standalone code example.
1 parent 2e56b6f commit cc6a090

File tree

11 files changed

+57
-3
lines changed

11 files changed

+57
-3
lines changed

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ E0455: include_str!("./error_codes/E0455.md"),
237237
E0458: include_str!("./error_codes/E0458.md"),
238238
E0459: include_str!("./error_codes/E0459.md"),
239239
E0463: include_str!("./error_codes/E0463.md"),
240+
E0464: include_str!("./error_codes/E0464.md"),
240241
E0466: include_str!("./error_codes/E0466.md"),
241242
E0468: include_str!("./error_codes/E0468.md"),
242243
E0469: include_str!("./error_codes/E0469.md"),
@@ -587,7 +588,6 @@ E0785: include_str!("./error_codes/E0785.md"),
587588
E0460, // found possibly newer version of crate `..`
588589
E0461, // couldn't find crate `..` with expected target triple ..
589590
E0462, // found staticlib `..` instead of rlib or dylib
590-
E0464, // multiple matching crates for `..`
591591
E0465, // multiple .. candidates for `..` found
592592
// E0467, removed
593593
// E0470, removed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The compiler found multiple library files with the requested crate name.
2+
3+
This error can occur in several different cases -- for example, when using
4+
`extern crate` or passing `--extern` options without crate paths. It can also be
5+
caused by caching issues with the build directory, in which case `cargo clean`
6+
may help.

src/test/ui/crate-loading/crateresolve1.rs

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// normalize-stderr-test: "\\\?\\" -> ""
77
// normalize-stderr-test: "libcrateresolve1-([123])\.[a-z]+" -> "libcrateresolve1-$1.somelib"
88

9+
// NOTE: This test is duplicated at `src/test/ui/error-codes/E0464.rs`.
10+
911
extern crate crateresolve1;
1012
//~^ ERROR multiple matching crates for `crateresolve1`
1113

src/test/ui/crate-loading/crateresolve1.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0464]: multiple matching crates for `crateresolve1`
2-
--> $DIR/crateresolve1.rs:9:1
2+
--> $DIR/crateresolve1.rs:11:1
33
|
44
LL | extern crate crateresolve1;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -11,3 +11,4 @@ LL | extern crate crateresolve1;
1111

1212
error: aborting due to previous error
1313

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

src/test/ui/crate-loading/crateresolve2.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ LL | extern crate crateresolve2;
1111

1212
error: aborting due to previous error
1313

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

src/test/ui/error-codes/E0464.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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: "libcrateresolve1-([123])\.[a-z]+" -> "libcrateresolve1-$1.somelib"
8+
9+
// NOTE: This test is duplicated from `src/test/ui/crate-loading/crateresolve1.rs`.
10+
11+
extern crate crateresolve1;
12+
//~^ ERROR multiple matching crates for `crateresolve1`
13+
14+
fn main() {
15+
}

src/test/ui/error-codes/E0464.stderr

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0464]: multiple matching crates for `crateresolve1`
2+
--> $DIR/E0464.rs:11:1
3+
|
4+
LL | extern crate crateresolve1;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: candidates:
8+
crate `crateresolve1`: $TEST_BUILD_DIR/error-codes/E0464/auxiliary/libcrateresolve1-1.somelib
9+
crate `crateresolve1`: $TEST_BUILD_DIR/error-codes/E0464/auxiliary/libcrateresolve1-2.somelib
10+
crate `crateresolve1`: $TEST_BUILD_DIR/error-codes/E0464/auxiliary/libcrateresolve1-3.somelib
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0464`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// compile-flags:-C extra-filename=-1
2+
#![crate_name = "crateresolve1"]
3+
#![crate_type = "lib"]
4+
5+
pub fn f() -> isize { 10 }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// compile-flags:-C extra-filename=-2
2+
#![crate_name = "crateresolve1"]
3+
#![crate_type = "lib"]
4+
5+
pub fn f() -> isize { 20 }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// compile-flags:-C extra-filename=-3
2+
#![crate_name = "crateresolve1"]
3+
#![crate_type = "lib"]
4+
5+
pub fn f() -> isize { 30 }

src/tools/tidy/src/error_codes_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const EXEMPTED_FROM_TEST: &[&str] = &[
1515
];
1616

1717
// Some error codes don't have any tests apparently...
18-
const IGNORE_EXPLANATION_CHECK: &[&str] = &["E0570", "E0601", "E0602", "E0729"];
18+
const IGNORE_EXPLANATION_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E0729"];
1919

2020
// If the file path contains any of these, we don't want to try to extract error codes from it.
2121
//

0 commit comments

Comments
 (0)