diff --git a/tests/run-make/crate-loading/multiple-dep-versions-1.rs b/tests/run-make/crate-loading/multiple-dep-versions-1.rs new file mode 100644 index 00000000000..2d351633829 --- /dev/null +++ b/tests/run-make/crate-loading/multiple-dep-versions-1.rs @@ -0,0 +1,6 @@ +#![crate_name = "dependency"] +#![crate_type = "rlib"] +pub struct Type; +pub trait Trait {} +impl Trait for Type {} +pub fn do_something(_: X) {} diff --git a/tests/ui/crate-loading/auxiliary/multiple-dep-versions-2.rs b/tests/run-make/crate-loading/multiple-dep-versions-2.rs similarity index 51% rename from tests/ui/crate-loading/auxiliary/multiple-dep-versions-2.rs rename to tests/run-make/crate-loading/multiple-dep-versions-2.rs index c79157fa463..a5df3dc61ed 100644 --- a/tests/ui/crate-loading/auxiliary/multiple-dep-versions-2.rs +++ b/tests/run-make/crate-loading/multiple-dep-versions-2.rs @@ -1,6 +1,5 @@ -#![crate_name="dependency"] -//@ edition:2021 -//@ compile-flags: -C metadata=2 -C extra-filename=-2 +#![crate_name = "dependency"] +#![crate_type = "rlib"] pub struct Type(pub i32); pub trait Trait {} impl Trait for Type {} diff --git a/tests/run-make/crate-loading/multiple-dep-versions.rs b/tests/run-make/crate-loading/multiple-dep-versions.rs new file mode 100644 index 00000000000..5a6cb03aaa4 --- /dev/null +++ b/tests/run-make/crate-loading/multiple-dep-versions.rs @@ -0,0 +1,8 @@ +extern crate dep_2_reexport; +extern crate dependency; +use dep_2_reexport::do_something; +use dependency::Type; + +fn main() { + do_something(Type); +} diff --git a/tests/run-make/crate-loading/rmake.rs b/tests/run-make/crate-loading/rmake.rs new file mode 100644 index 00000000000..2aa396fd2d9 --- /dev/null +++ b/tests/run-make/crate-loading/rmake.rs @@ -0,0 +1,31 @@ +//@ only-linux +//@ ignore-wasm32 +//@ ignore-wasm64 + +use run_make_support::rfs::copy; +use run_make_support::{assert_contains, rust_lib_name, rustc}; + +fn main() { + rustc().input("multiple-dep-versions-1.rs").run(); + rustc().input("multiple-dep-versions-2.rs").extra_filename("2").metadata("2").run(); + + let out = rustc() + .input("multiple-dep-versions.rs") + .extern_("dependency", rust_lib_name("dependency")) + .extern_("dep_2_reexport", rust_lib_name("dependency2")) + .inspect(|cmd| eprintln!("{cmd:?}")) + .run_fail(); + let stderr = out.stderr_utf8(); + assert_contains( + &stderr, + "you have multiple different versions of crate `dependency` in your dependency graph", + ); + assert_contains( + &stderr, + "two types coming from two different versions of the same crate are different types even \ + if they look the same", + ); + assert_contains(&stderr, "this type doesn't implement the required trait"); + assert_contains(&stderr, "this type implements the required trait"); + assert_contains(&stderr, "this is the required trait"); +} diff --git a/tests/ui/crate-loading/auxiliary/dep-2-reexport.rs b/tests/ui/crate-loading/auxiliary/dep-2-reexport.rs deleted file mode 100644 index 3a793bbbb10..00000000000 --- a/tests/ui/crate-loading/auxiliary/dep-2-reexport.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ edition:2021 -//@ aux-build:multiple-dep-versions-2.rs -extern crate dependency; -pub use dependency::do_something; diff --git a/tests/ui/crate-loading/auxiliary/multiple-dep-versions-1.rs b/tests/ui/crate-loading/auxiliary/multiple-dep-versions-1.rs deleted file mode 100644 index b96bb6d9e64..00000000000 --- a/tests/ui/crate-loading/auxiliary/multiple-dep-versions-1.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![crate_name="dependency"] -//@ edition:2021 -//@ compile-flags: -C metadata=1 -C extra-filename=-1 -pub struct Type; -pub trait Trait {} -impl Trait for Type {} -pub fn do_something(_: X) { } diff --git a/tests/ui/crate-loading/multiple-dep-versions.rs b/tests/ui/crate-loading/multiple-dep-versions.rs deleted file mode 100644 index ceb9b57717d..00000000000 --- a/tests/ui/crate-loading/multiple-dep-versions.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ aux-build:dep-2-reexport.rs -//@ aux-build:multiple-dep-versions-1.rs -//@ edition:2021 -//@ compile-flags: --error-format=human --color=always --crate-type bin --extern dependency={{build-base}}/crate-loading/multiple-dep-versions/auxiliary/libdependency-1.so --extern dep_2_reexport={{build-base}}/crate-loading/multiple-dep-versions/auxiliary/libdep_2_reexport.so -//@ only-linux -//@ ignore-wasm32 - -extern crate dependency; -extern crate dep_2_reexport; -use dependency::Type; -use dep_2_reexport::do_something; - -fn main() { - do_something(Type); -} diff --git a/tests/ui/crate-loading/multiple-dep-versions.svg b/tests/ui/crate-loading/multiple-dep-versions.svg deleted file mode 100644 index 1cfcfab562f..00000000000 --- a/tests/ui/crate-loading/multiple-dep-versions.svg +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - error[E0277]: the trait bound `Type: dependency::Trait` is not satisfied - - --> $DIR/multiple-dep-versions.rs:14:18 - - | - - LL | do_something(Type); - - | ------------ ^^^^ the trait `dependency::Trait` is not implemented for `Type` - - | | - - | required by a bound introduced by this call - - | - - help: you have multiple different versions of crate `dependency` in your dependency graph - - --> $DIR/multiple-dep-versions.rs:8:1 - - | - - LL | extern crate dependency; - - | ^^^^^^^^^^^^^^^^^^^^^^^^ one version of crate `dependency` is used here, as a direct dependency of the current crate - - LL | extern crate dep_2_reexport; - - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one version of crate `dependency` is used here, as a dependency of crate `dep_2_reexport` - - note: two types coming from two different versions of the same crate are different types even if they look the same - - --> $DIR/auxiliary/multiple-dep-versions-1.rs:4:1 - - | - - LL | pub struct Type; - - | ^^^^^^^^^^^^^^^ this type doesn't implement the required trait - - | - - ::: $DIR/auxiliary/multiple-dep-versions-2.rs:4:1 - - | - - LL | pub struct Type(pub i32); - - | ^^^^^^^^^^^^^^^ this type implements the required trait - - LL | pub trait Trait {} - - | --------------- this is the required trait - - = help: you can use `cargo tree` to explore your dependency tree - - note: required by a bound in `dep_2_reexport::do_something` - - --> $DIR/auxiliary/multiple-dep-versions-2.rs:7:24 - - | - - LL | pub fn do_something<X: Trait>(_: X) {} - - | ^^^^^ required by this bound in `do_something` - - - - error: aborting due to 1 previous error - - - - For more information about this error, try `rustc --explain E0277`. - - - - - -