diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-11-29 18:31:37 +0000 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2025-01-02 14:28:32 -0800 |
| commit | 2fb0b160c051f57a9e93c33d6ed972195a009e1d (patch) | |
| tree | 01d524b3eeca7a1a9f0f811d52c00fac4a7cac57 | |
| parent | 21c75ad1ccc234b8cc2ffd23ed411b3a0da70833 (diff) | |
| download | rust-2fb0b160c051f57a9e93c33d6ed972195a009e1d.tar.gz rust-2fb0b160c051f57a9e93c33d6ed972195a009e1d.zip | |
Use rmake `diff` output in test
(cherry picked from commit e97e15dea55d61d68732bc030be1a44d8a51a1e9)
| -rw-r--r-- | tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr | 29 | ||||
| -rw-r--r-- | tests/run-make/crate-loading-crate-depends-on-itself/rmake.rs | 25 |
2 files changed, 41 insertions, 13 deletions
diff --git a/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr b/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr new file mode 100644 index 00000000000..9c2fcabe5ba --- /dev/null +++ b/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr @@ -0,0 +1,29 @@ +error[E0277]: the trait bound `foo::Struct: Trait` is not satisfied because the trait comes from a different crate version + --> foo-current.rs:13:19 + | +13 | check_trait::<foo::Struct>(); + | ^^^^^^^^^^^ the trait `Trait` is not implemented for `foo::Struct` + | +note: there are multiple different versions of crate `foo` in the dependency graph + --> foo-current.rs:7:1 + | +4 | extern crate foo; + | ----------------- one version of crate `foo` is used here, as a direct dependency of the current crate +5 | +6 | pub struct Struct; + | ----------------- this type implements the required trait +7 | pub trait Trait {} + | ^^^^^^^^^^^^^^^ this is the required trait + | + ::: foo-prev.rs:X:Y + | +4 | pub struct Struct; + | ----------------- this type doesn't implement the required trait +5 | 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: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. \ No newline at end of file diff --git a/tests/run-make/crate-loading-crate-depends-on-itself/rmake.rs b/tests/run-make/crate-loading-crate-depends-on-itself/rmake.rs index f52f3d791a7..57e0cab92f1 100644 --- a/tests/run-make/crate-loading-crate-depends-on-itself/rmake.rs +++ b/tests/run-make/crate-loading-crate-depends-on-itself/rmake.rs @@ -7,26 +7,25 @@ // and traits of the different versions are mixed, we produce diagnostic output and not an ICE. // #133563 -use run_make_support::{rust_lib_name, rustc}; +use run_make_support::{diff, rust_lib_name, rustc}; fn main() { rustc().input("foo-prev.rs").run(); - rustc() + let out = rustc() .extra_filename("current") .metadata("current") .input("foo-current.rs") .extern_("foo", rust_lib_name("foo")) .run_fail() - .assert_stderr_contains(r#" -note: there are multiple different versions of crate `foo` in the dependency graph - --> foo-current.rs:7:1 - | -4 | extern crate foo; - | ----------------- one version of crate `foo` is used here, as a direct dependency of the current crate -5 | -6 | pub struct Struct; - | ----------------- this type implements the required trait -7 | pub trait Trait {} - | ^^^^^^^^^^^^^^^ this is the required trait"#); + .stderr_utf8(); + + // We don't remap the path of the `foo-prev` crate, so we remap it here. + let mut lines: Vec<_> = out.lines().collect(); + for line in &mut lines { + if line.starts_with(" ::: ") { + *line = " ::: foo-prev.rs:X:Y"; + } + } + diff().expected_file("foo.stderr").actual_text("(rustc)", &lines.join("\n")).run(); } |
