Move the crate-loading
test to use diff
output
(cherry picked from commit 998ff2f0cd
)
This commit is contained in:
parent
2fb0b160c0
commit
bee5d0996b
3 changed files with 138 additions and 70 deletions
|
@ -227,6 +227,12 @@ impl Rustc {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Normalize the line number in the stderr output
|
||||||
|
pub fn ui_testing(&mut self) -> &mut Self {
|
||||||
|
self.cmd.arg(format!("-Zui-testing"));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Specify the target triple, or a path to a custom target json spec file.
|
/// Specify the target triple, or a path to a custom target json spec file.
|
||||||
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
|
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
|
||||||
let target = target.as_ref();
|
let target = target.as_ref();
|
||||||
|
|
113
tests/run-make/crate-loading/multiple-dep-versions.stderr
Normal file
113
tests/run-make/crate-loading/multiple-dep-versions.stderr
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
error[E0277]: the trait bound `dep_2_reexport::Type: Trait` is not satisfied because the trait comes from a different crate version
|
||||||
|
--> replaced
|
||||||
|
|
|
||||||
|
LL | do_something(Type);
|
||||||
|
| ^^^^ the trait `Trait` is not implemented for `dep_2_reexport::Type`
|
||||||
|
|
|
||||||
|
note: there are multiple different versions of crate `dependency` in the dependency graph
|
||||||
|
--> replaced
|
||||||
|
|
|
||||||
|
LL | pub struct Type(pub i32);
|
||||||
|
| --------------- this type implements the required trait
|
||||||
|
LL | pub trait Trait {
|
||||||
|
| ^^^^^^^^^^^^^^^ this is the required trait
|
||||||
|
|
|
||||||
|
::: replaced
|
||||||
|
|
|
||||||
|
LL | extern crate dep_2_reexport;
|
||||||
|
| ---------------------------- one version of crate `dependency` is used here, as a dependency of crate `foo`
|
||||||
|
LL | extern crate dependency;
|
||||||
|
| ------------------------ one version of crate `dependency` is used here, as a direct dependency of the current crate
|
||||||
|
|
|
||||||
|
::: replaced
|
||||||
|
|
|
||||||
|
LL | pub struct Type;
|
||||||
|
| --------------- this type doesn't implement the required trait
|
||||||
|
LL | pub trait Trait {
|
||||||
|
| --------------- this is the found trait
|
||||||
|
= note: two types coming from two different versions of the same crate are different types even if they look the same
|
||||||
|
= help: you can use `cargo tree` to explore your dependency tree
|
||||||
|
|
||||||
|
error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope
|
||||||
|
--> replaced
|
||||||
|
|
|
||||||
|
LL | Type.foo();
|
||||||
|
| ^^^ method not found in `Type`
|
||||||
|
|
|
||||||
|
note: there are multiple different versions of crate `dependency` in the dependency graph
|
||||||
|
--> replaced
|
||||||
|
|
|
||||||
|
LL | pub trait Trait {
|
||||||
|
| ^^^^^^^^^^^^^^^ this is the trait that is needed
|
||||||
|
LL | fn foo(&self);
|
||||||
|
| -------------- the method is available for `dep_2_reexport::Type` here
|
||||||
|
|
|
||||||
|
::: replaced
|
||||||
|
|
|
||||||
|
LL | use dependency::{Trait, do_something};
|
||||||
|
| ----- `Trait` imported here doesn't correspond to the right version of crate `dependency`
|
||||||
|
|
|
||||||
|
::: replaced
|
||||||
|
|
|
||||||
|
LL | pub trait Trait {
|
||||||
|
| --------------- this is the trait that was imported
|
||||||
|
|
||||||
|
error[E0599]: no function or associated item named `bar` found for struct `dep_2_reexport::Type` in the current scope
|
||||||
|
--> replaced
|
||||||
|
|
|
||||||
|
LL | Type::bar();
|
||||||
|
| ^^^ function or associated item not found in `Type`
|
||||||
|
|
|
||||||
|
note: there are multiple different versions of crate `dependency` in the dependency graph
|
||||||
|
--> replaced
|
||||||
|
|
|
||||||
|
LL | pub trait Trait {
|
||||||
|
| ^^^^^^^^^^^^^^^ this is the trait that is needed
|
||||||
|
LL | fn foo(&self);
|
||||||
|
LL | fn bar();
|
||||||
|
| --------- the associated function is available for `dep_2_reexport::Type` here
|
||||||
|
|
|
||||||
|
::: replaced
|
||||||
|
|
|
||||||
|
LL | use dependency::{Trait, do_something};
|
||||||
|
| ----- `Trait` imported here doesn't correspond to the right version of crate `dependency`
|
||||||
|
|
|
||||||
|
::: replaced
|
||||||
|
|
|
||||||
|
LL | pub trait Trait {
|
||||||
|
| --------------- this is the trait that was imported
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `OtherType: Trait` is not satisfied because the trait comes from a different crate version
|
||||||
|
--> replaced
|
||||||
|
|
|
||||||
|
LL | do_something(OtherType);
|
||||||
|
| ^^^^^^^^^ the trait `Trait` is not implemented for `OtherType`
|
||||||
|
|
|
||||||
|
note: there are multiple different versions of crate `dependency` in the dependency graph
|
||||||
|
--> replaced
|
||||||
|
|
|
||||||
|
LL | pub trait Trait {
|
||||||
|
| ^^^^^^^^^^^^^^^ this is the required trait
|
||||||
|
|
|
||||||
|
::: replaced
|
||||||
|
|
|
||||||
|
LL | extern crate dep_2_reexport;
|
||||||
|
| ---------------------------- one version of crate `dependency` is used here, as a dependency of crate `foo`
|
||||||
|
LL | extern crate dependency;
|
||||||
|
| ------------------------ one version of crate `dependency` is used here, as a direct dependency of the current crate
|
||||||
|
|
|
||||||
|
::: replaced
|
||||||
|
|
|
||||||
|
LL | pub struct OtherType;
|
||||||
|
| -------------------- this type doesn't implement the required trait
|
||||||
|
|
|
||||||
|
::: replaced
|
||||||
|
|
|
||||||
|
LL | pub trait Trait {
|
||||||
|
| --------------- this is the found trait
|
||||||
|
= help: you can use `cargo tree` to explore your dependency tree
|
||||||
|
|
||||||
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0277, E0599.
|
||||||
|
For more information about an error, try `rustc --explain E0277`.
|
|
@ -3,7 +3,7 @@
|
||||||
//@ ignore-wasm64
|
//@ ignore-wasm64
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
|
|
||||||
use run_make_support::{rust_lib_name, rustc};
|
use run_make_support::{diff, rust_lib_name, rustc};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
rustc().input("multiple-dep-versions-1.rs").run();
|
rustc().input("multiple-dep-versions-1.rs").run();
|
||||||
|
@ -13,77 +13,26 @@ fn main() {
|
||||||
.extern_("dependency", rust_lib_name("dependency2"))
|
.extern_("dependency", rust_lib_name("dependency2"))
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
rustc()
|
let out = rustc()
|
||||||
.input("multiple-dep-versions.rs")
|
.input("multiple-dep-versions.rs")
|
||||||
.extern_("dependency", rust_lib_name("dependency"))
|
.extern_("dependency", rust_lib_name("dependency"))
|
||||||
.extern_("dep_2_reexport", rust_lib_name("foo"))
|
.extern_("dep_2_reexport", rust_lib_name("foo"))
|
||||||
|
.ui_testing()
|
||||||
.run_fail()
|
.run_fail()
|
||||||
.assert_stderr_contains(r#"error[E0277]: the trait bound `dep_2_reexport::Type: Trait` is not satisfied because the trait comes from a different crate version
|
.stderr_utf8();
|
||||||
--> multiple-dep-versions.rs:7:18
|
|
||||||
|
|
// We don't remap all the paths, so we remap it here.
|
||||||
7 | do_something(Type);
|
let mut lines: Vec<_> = out.lines().collect();
|
||||||
| ^^^^ the trait `Trait` is not implemented for `dep_2_reexport::Type`
|
for line in &mut lines {
|
||||||
|
|
if line.starts_with(" --> ") {
|
||||||
note: there are multiple different versions of crate `dependency` in the dependency graph"#)
|
*line = " --> replaced";
|
||||||
.assert_stderr_contains(r#"
|
}
|
||||||
3 | pub struct Type(pub i32);
|
if line.starts_with(" ::: ") {
|
||||||
| --------------- this type implements the required trait
|
*line = " ::: replaced";
|
||||||
4 | pub trait Trait {
|
}
|
||||||
| ^^^^^^^^^^^^^^^ this is the required trait
|
}
|
||||||
"#)
|
diff()
|
||||||
.assert_stderr_contains(r#"
|
.expected_file("multiple-dep-versions.stderr")
|
||||||
1 | extern crate dep_2_reexport;
|
.actual_text("(rustc)", &lines.join("\n"))
|
||||||
| ---------------------------- one version of crate `dependency` is used here, as a dependency of crate `foo`
|
.run();
|
||||||
2 | extern crate dependency;
|
|
||||||
| ------------------------ one version of crate `dependency` is used here, as a direct dependency of the current crate"#)
|
|
||||||
.assert_stderr_contains(r#"
|
|
||||||
3 | pub struct Type;
|
|
||||||
| --------------- this type doesn't implement the required trait
|
|
||||||
4 | pub trait Trait {
|
|
||||||
| --------------- this is the found trait
|
|
||||||
= note: two types coming from two different versions of the same crate are different types even if they look the same
|
|
||||||
= help: you can use `cargo tree` to explore your dependency tree"#)
|
|
||||||
.assert_stderr_contains(r#"error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope
|
|
||||||
--> multiple-dep-versions.rs:8:10
|
|
||||||
|
|
|
||||||
8 | Type.foo();
|
|
||||||
| ^^^ method not found in `Type`
|
|
||||||
|
|
|
||||||
note: there are multiple different versions of crate `dependency` in the dependency graph"#)
|
|
||||||
.assert_stderr_contains(r#"
|
|
||||||
4 | pub trait Trait {
|
|
||||||
| ^^^^^^^^^^^^^^^ this is the trait that is needed
|
|
||||||
5 | fn foo(&self);
|
|
||||||
| -------------- the method is available for `dep_2_reexport::Type` here
|
|
||||||
|
|
|
||||||
::: multiple-dep-versions.rs:4:18
|
|
||||||
|
|
|
||||||
4 | use dependency::{Trait, do_something};
|
|
||||||
| ----- `Trait` imported here doesn't correspond to the right version of crate `dependency`"#)
|
|
||||||
.assert_stderr_contains(r#"
|
|
||||||
4 | pub trait Trait {
|
|
||||||
| --------------- this is the trait that was imported"#)
|
|
||||||
.assert_stderr_contains(r#"
|
|
||||||
error[E0599]: no function or associated item named `bar` found for struct `dep_2_reexport::Type` in the current scope
|
|
||||||
--> multiple-dep-versions.rs:9:11
|
|
||||||
|
|
|
||||||
9 | Type::bar();
|
|
||||||
| ^^^ function or associated item not found in `Type`
|
|
||||||
|
|
|
||||||
note: there are multiple different versions of crate `dependency` in the dependency graph"#)
|
|
||||||
.assert_stderr_contains(r#"
|
|
||||||
4 | pub trait Trait {
|
|
||||||
| ^^^^^^^^^^^^^^^ this is the trait that is needed
|
|
||||||
5 | fn foo(&self);
|
|
||||||
6 | fn bar();
|
|
||||||
| --------- the associated function is available for `dep_2_reexport::Type` here
|
|
||||||
|
|
|
||||||
::: multiple-dep-versions.rs:4:18
|
|
||||||
|
|
|
||||||
4 | use dependency::{Trait, do_something};
|
|
||||||
| ----- `Trait` imported here doesn't correspond to the right version of crate `dependency`"#)
|
|
||||||
.assert_stderr_contains(
|
|
||||||
r#"
|
|
||||||
6 | pub struct OtherType;
|
|
||||||
| -------------------- this type doesn't implement the required trait"#);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue