Skip to content

Commit 6e6ec81

Browse files
authored
Rollup merge of #105860 - Ezrashaw:add-long-errors-0460-0457, r=jruderman,GuillaumeGomez
Add long error docs for `E0460` and `E0457` Final docs for errors in #61137 that have UI tests, my next PRs will also add these tests. r? ``@GuillaumeGomez``
2 parents 3af45ee + 5ecac8e commit 6e6ec81

12 files changed

+118
-2
lines changed

compiler/rustc_error_codes/src/error_codes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,10 @@ E0452: include_str!("./error_codes/E0452.md"),
239239
E0453: include_str!("./error_codes/E0453.md"),
240240
E0454: include_str!("./error_codes/E0454.md"),
241241
E0455: include_str!("./error_codes/E0455.md"),
242+
E0457: include_str!("./error_codes/E0457.md"),
242243
E0458: include_str!("./error_codes/E0458.md"),
243244
E0459: include_str!("./error_codes/E0459.md"),
245+
E0460: include_str!("./error_codes/E0460.md"),
244246
E0463: include_str!("./error_codes/E0463.md"),
245247
E0464: include_str!("./error_codes/E0464.md"),
246248
E0466: include_str!("./error_codes/E0466.md"),
@@ -592,8 +594,6 @@ E0791: include_str!("./error_codes/E0791.md"),
592594
// E0421, // merged into 531
593595
// E0427, // merged into 530
594596
// E0456, // plugin `..` is not available for triple `..`
595-
E0457, // plugin `..` only found in rlib format, but must be available...
596-
E0460, // found possibly newer version of crate `..`
597597
E0461, // couldn't find crate `..` with expected target triple ..
598598
E0462, // found staticlib `..` instead of rlib or dylib
599599
E0465, // multiple .. candidates for `..` found
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Plugin `..` only found in rlib format, but must be available in dylib format.
2+
3+
Erroronous code example:
4+
5+
`rlib-plugin.rs`
6+
```ignore (needs-linkage-with-other-tests)
7+
#![crate_type = "rlib"]
8+
#![feature(rustc_private)]
9+
10+
extern crate rustc_middle;
11+
extern crate rustc_driver;
12+
13+
use rustc_driver::plugin::Registry;
14+
15+
#[no_mangle]
16+
fn __rustc_plugin_registrar(_: &mut Registry) {}
17+
```
18+
19+
`main.rs`
20+
```ignore (needs-linkage-with-other-tests)
21+
#![feature(plugin)]
22+
#![plugin(rlib_plugin)] // error: plugin `rlib_plugin` only found in rlib
23+
// format, but must be available in dylib
24+
25+
fn main() {}
26+
```
27+
28+
The compiler exposes a plugin interface to allow altering the compile process
29+
(adding lints, etc). Plugins must be defined in their own crates (similar to
30+
[proc-macro](../reference/procedural-macros.html) isolation) and then compiled
31+
and linked to another crate. Plugin crates *must* be compiled to the
32+
dynamically-linked dylib format, and not the statically-linked rlib format.
33+
Learn more about different output types in
34+
[this section](../reference/linkage.html) of the Rust reference.
35+
36+
This error is easily fixed by recompiling the plugin crate in the dylib format.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Found possibly newer version of crate `..` which `..` depends on.
2+
3+
Consider these erroneous files:
4+
5+
`a1.rs`
6+
```ignore (needs-linkage-with-other-tests)
7+
#![crate_name = "a"]
8+
9+
pub fn foo<T>() {}
10+
```
11+
12+
`a2.rs`
13+
```ignore (needs-linkage-with-other-tests)
14+
#![crate_name = "a"]
15+
16+
pub fn foo<T>() {
17+
println!("foo<T>()");
18+
}
19+
```
20+
21+
`b.rs`
22+
```ignore (needs-linkage-with-other-tests)
23+
#![crate_name = "b"]
24+
25+
extern crate a; // linked with `a1.rs`
26+
27+
pub fn foo() {
28+
a::foo::<isize>();
29+
}
30+
```
31+
32+
`main.rs`
33+
```ignore (needs-linkage-with-other-tests)
34+
extern crate a; // linked with `a2.rs`
35+
extern crate b; // error: found possibly newer version of crate `a` which `b`
36+
// depends on
37+
38+
fn main() {}
39+
```
40+
41+
The dependency graph of this program can be represented as follows:
42+
```text
43+
crate `main`
44+
|
45+
+-------------+
46+
| |
47+
| v
48+
depends: | crate `b`
49+
`a` v1 | |
50+
| | depends:
51+
| | `a` v2
52+
v |
53+
crate `a` <------+
54+
```
55+
56+
Crate `main` depends on crate `a` (version 1) and crate `b` which in turn
57+
depends on crate `a` (version 2); this discrepancy in versions cannot be
58+
reconciled. This difference in versions typically occurs when one crate is
59+
compiled and linked, then updated and linked to another crate. The crate
60+
"version" is a SVH (Strict Version Hash) of the crate in an
61+
implementation-specific way. Note that this error can *only* occur when
62+
directly compiling and linking with `rustc`; [Cargo] automatically resolves
63+
dependencies, without using the compiler's own dependency management that
64+
causes this issue.
65+
66+
This error can be fixed by:
67+
* Using [Cargo], the Rust package manager, automatically fixing this issue.
68+
* Recompiling crate `a` so that both crate `b` and `main` have a uniform
69+
version to depend on.
70+
71+
[Cargo]: ../cargo/index.html

src/test/ui-fulldeps/macro-crate-rlib.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | #![plugin(rlib_crate_test)]
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0457`.

src/test/ui/svh/changing-crates.stderr

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

1212
error: aborting due to previous error
1313

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

src/test/ui/svh/svh-change-lit.stderr

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

1212
error: aborting due to previous error
1313

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

src/test/ui/svh/svh-change-significant-cfg.stderr

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

1212
error: aborting due to previous error
1313

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

src/test/ui/svh/svh-change-trait-bound.stderr

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

1212
error: aborting due to previous error
1313

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

src/test/ui/svh/svh-change-type-arg.stderr

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

1212
error: aborting due to previous error
1313

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

src/test/ui/svh/svh-change-type-ret.stderr

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

1212
error: aborting due to previous error
1313

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

src/test/ui/svh/svh-change-type-static.stderr

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

1212
error: aborting due to previous error
1313

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

src/test/ui/svh/svh-use-trait.stderr

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

1212
error: aborting due to previous error
1313

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

0 commit comments

Comments
 (0)