From 7e66d451ad49aa69dd830ea22943e6ffdc92eddd Mon Sep 17 00:00:00 2001 From: Ezra Shaw Date: Sun, 18 Dec 2022 20:58:09 +1300 Subject: [PATCH 1/3] docs: add long-form error-code docs for E0460 --- compiler/rustc_error_codes/src/error_codes.rs | 2 +- .../src/error_codes/E0460.md | 71 +++++++++++++++++++ src/test/ui/svh/changing-crates.stderr | 1 + src/test/ui/svh/svh-change-lit.stderr | 1 + .../ui/svh/svh-change-significant-cfg.stderr | 1 + src/test/ui/svh/svh-change-trait-bound.stderr | 1 + src/test/ui/svh/svh-change-type-arg.stderr | 1 + src/test/ui/svh/svh-change-type-ret.stderr | 1 + src/test/ui/svh/svh-change-type-static.stderr | 1 + src/test/ui/svh/svh-use-trait.stderr | 1 + 10 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 compiler/rustc_error_codes/src/error_codes/E0460.md diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 67c512e98d68d..59f691c7ec866 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -241,6 +241,7 @@ E0454: include_str!("./error_codes/E0454.md"), E0455: include_str!("./error_codes/E0455.md"), E0458: include_str!("./error_codes/E0458.md"), E0459: include_str!("./error_codes/E0459.md"), +E0460: include_str!("./error_codes/E0460.md"), E0463: include_str!("./error_codes/E0463.md"), E0464: include_str!("./error_codes/E0464.md"), E0466: include_str!("./error_codes/E0466.md"), @@ -593,7 +594,6 @@ E0791: include_str!("./error_codes/E0791.md"), // E0427, // merged into 530 // E0456, // plugin `..` is not available for triple `..` E0457, // plugin `..` only found in rlib format, but must be available... - E0460, // found possibly newer version of crate `..` E0461, // couldn't find crate `..` with expected target triple .. E0462, // found staticlib `..` instead of rlib or dylib E0465, // multiple .. candidates for `..` found diff --git a/compiler/rustc_error_codes/src/error_codes/E0460.md b/compiler/rustc_error_codes/src/error_codes/E0460.md new file mode 100644 index 0000000000000..1687682b28ec5 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0460.md @@ -0,0 +1,71 @@ +Found possibly newer version of crate `..` which `..` depends on. + +Consider these erroneous files: + +`a1.rs` +```ignore (needs-linkage-with-other-tests) +#![crate_name = "a"] + +pub fn foo() {} +``` + +`a2.rs` +```ignore (needs-linkage-with-other-tests) +#![crate_name = "a"] + +pub fn foo() { + println!("foo()"); +} +``` + +`b.rs` +```ignore (needs-linkage-with-other-tests) +#![crate_name = "b"] + +extern crate a; // linked with `a1.rs` + +pub fn foo() { + a::foo::(); +} +``` + +`main.rs` +```ignore (needs-linkage-with-other-tests) +extern crate a; // linked with `a2.rs` +extern crate b; // error: found possibly newer version of crate `a` which `b` + // depends on + +fn main() {} +``` + +The dependency graph of this program can be represented as follows: +```text + crate `main` + | + +-------------+ + | | + | v +depends: | crate `b` + `a` v1 | | + | | depends: + | | `a` v2 + v | + crate `a` <------+ +``` + +Crate `main` depends on crate `a` (version 1) and crate `b` which in turn +depends on crate `a` (version 2); this discrepancy in versions cannot be +reconciled. This difference in versions typically occurs when one crate is +compiled and linked, then updated and linked to another crate. The crate +"version" is a SVH (Strict Version Hash) of the crate in an +implementation-specific way. Note that this error can *only* occur when +directly compiling and linking with `rustc`; [Cargo] automatically resolves +dependencies, without using the compiler's own dependency management that +causes this issue. + +This error can be fixed by: +* Using [Cargo], the Rust package manager, automatically fixing this issue. +* Recompiling crate `a` so that both crate `b` and `main` have a uniform +version to depend on. + +[Cargo]: ../cargo/index.html diff --git a/src/test/ui/svh/changing-crates.stderr b/src/test/ui/svh/changing-crates.stderr index 7244919e86d5d..caefdfc96f038 100644 --- a/src/test/ui/svh/changing-crates.stderr +++ b/src/test/ui/svh/changing-crates.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-lit.stderr b/src/test/ui/svh/svh-change-lit.stderr index 1e97e9d0557d0..5e890c6aa5795 100644 --- a/src/test/ui/svh/svh-change-lit.stderr +++ b/src/test/ui/svh/svh-change-lit.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-significant-cfg.stderr b/src/test/ui/svh/svh-change-significant-cfg.stderr index f04046f4c87bf..dcc250d5216b0 100644 --- a/src/test/ui/svh/svh-change-significant-cfg.stderr +++ b/src/test/ui/svh/svh-change-significant-cfg.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-trait-bound.stderr b/src/test/ui/svh/svh-change-trait-bound.stderr index a778c61806a50..2035993d218ec 100644 --- a/src/test/ui/svh/svh-change-trait-bound.stderr +++ b/src/test/ui/svh/svh-change-trait-bound.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-type-arg.stderr b/src/test/ui/svh/svh-change-type-arg.stderr index f09babf93fd35..eef85aa954611 100644 --- a/src/test/ui/svh/svh-change-type-arg.stderr +++ b/src/test/ui/svh/svh-change-type-arg.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-type-ret.stderr b/src/test/ui/svh/svh-change-type-ret.stderr index 0998cd4b5496e..247f74e50df60 100644 --- a/src/test/ui/svh/svh-change-type-ret.stderr +++ b/src/test/ui/svh/svh-change-type-ret.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-change-type-static.stderr b/src/test/ui/svh/svh-change-type-static.stderr index 9c48cbd30a508..78b54f227f0f0 100644 --- a/src/test/ui/svh/svh-change-type-static.stderr +++ b/src/test/ui/svh/svh-change-type-static.stderr @@ -11,3 +11,4 @@ LL | extern crate b; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. diff --git a/src/test/ui/svh/svh-use-trait.stderr b/src/test/ui/svh/svh-use-trait.stderr index 5780cfef357d6..d8a81864dcaa8 100644 --- a/src/test/ui/svh/svh-use-trait.stderr +++ b/src/test/ui/svh/svh-use-trait.stderr @@ -11,3 +11,4 @@ LL | extern crate utb; error: aborting due to previous error +For more information about this error, try `rustc --explain E0460`. From 540c3f434f25b90b6f238aa520d5532909f711db Mon Sep 17 00:00:00 2001 From: Ezra Shaw Date: Sun, 18 Dec 2022 22:00:35 +1300 Subject: [PATCH 2/3] docs: add long-form error-code docs for E0457 --- compiler/rustc_error_codes/src/error_codes.rs | 2 +- .../src/error_codes/E0457.md | 36 +++++++++++++++++++ src/test/ui-fulldeps/macro-crate-rlib.stderr | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 compiler/rustc_error_codes/src/error_codes/E0457.md diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 59f691c7ec866..883a4bbe8e823 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -239,6 +239,7 @@ E0452: include_str!("./error_codes/E0452.md"), E0453: include_str!("./error_codes/E0453.md"), E0454: include_str!("./error_codes/E0454.md"), E0455: include_str!("./error_codes/E0455.md"), +E0457: include_str!("./error_codes/E0457.md"), E0458: include_str!("./error_codes/E0458.md"), E0459: include_str!("./error_codes/E0459.md"), E0460: include_str!("./error_codes/E0460.md"), @@ -593,7 +594,6 @@ E0791: include_str!("./error_codes/E0791.md"), // E0421, // merged into 531 // E0427, // merged into 530 // E0456, // plugin `..` is not available for triple `..` - E0457, // plugin `..` only found in rlib format, but must be available... E0461, // couldn't find crate `..` with expected target triple .. E0462, // found staticlib `..` instead of rlib or dylib E0465, // multiple .. candidates for `..` found diff --git a/compiler/rustc_error_codes/src/error_codes/E0457.md b/compiler/rustc_error_codes/src/error_codes/E0457.md new file mode 100644 index 0000000000000..53d384d36c426 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0457.md @@ -0,0 +1,36 @@ +Plugin `..` only found in rlib format, but must be available in dylib format. + +Erroronous code example: + +`rlib-plugin.rs` +```ignore (needs-linkage-with-other-tests) +#![crate_type = "rlib"] +#![feature(rustc_private)] + +extern crate rustc_middle; +extern crate rustc_driver; + +use rustc_driver::plugin::Registry; + +#[no_mangle] +fn __rustc_plugin_registrar(_: &mut Registry) {} +``` + +`main.rs` +```ignore (needs-linkage-with-other-tests) +#![feature(plugin)] +#![plugin(rlib_plugin)] // error: plugin `rlib_plugin` only found in rlib + // format, but must be available in dylib + +fn main() {} +``` + +The compiler exposes a plugin interface to allow altering the compile process +(adding lints, etc). Plugins must be defined in their own crates (similar to +[proc-macro](../reference/procedural-macros.html) isolation) and then compiled +and linked to another crate. Plugin crates *must* be compiled to the +dynamically-linked dylib format, and not the statically-linked rlib format. +Learn more about different output types in +[this section](../reference/linkage.html) of the Rust reference. + +This error is easily fixed by recompiling the plugin crate in the dylib format. diff --git a/src/test/ui-fulldeps/macro-crate-rlib.stderr b/src/test/ui-fulldeps/macro-crate-rlib.stderr index 7b31f28a26e7d..9c2b992b76558 100644 --- a/src/test/ui-fulldeps/macro-crate-rlib.stderr +++ b/src/test/ui-fulldeps/macro-crate-rlib.stderr @@ -6,3 +6,4 @@ LL | #![plugin(rlib_crate_test)] error: aborting due to previous error +For more information about this error, try `rustc --explain E0457`. From 5ecac8ede670ac8045a199cd3bcd58bd940ec8d4 Mon Sep 17 00:00:00 2001 From: Ezra Shaw Date: Mon, 19 Dec 2022 22:50:31 +1300 Subject: [PATCH 3/3] more markdown list formatting Co-authored-by: Guillaume Gomez --- compiler/rustc_error_codes/src/error_codes/E0460.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0460.md b/compiler/rustc_error_codes/src/error_codes/E0460.md index 1687682b28ec5..001678a9bce06 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0460.md +++ b/compiler/rustc_error_codes/src/error_codes/E0460.md @@ -64,8 +64,8 @@ dependencies, without using the compiler's own dependency management that causes this issue. This error can be fixed by: -* Using [Cargo], the Rust package manager, automatically fixing this issue. -* Recompiling crate `a` so that both crate `b` and `main` have a uniform -version to depend on. + * Using [Cargo], the Rust package manager, automatically fixing this issue. + * Recompiling crate `a` so that both crate `b` and `main` have a uniform + version to depend on. [Cargo]: ../cargo/index.html