Skip to content

Commit e97e15d

Browse files
committed
Use rmake diff output in test
1 parent 8574f37 commit e97e15d

File tree

2 files changed

+46
-13
lines changed

2 files changed

+46
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error[E0277]: the trait bound `foo::Struct: Trait` is not satisfied
2+
--> foo-current.rs:13:19
3+
|
4+
13 | check_trait::<foo::Struct>();
5+
| ^^^^^^^^^^^ the trait `Trait` is not implemented for `foo::Struct`
6+
|
7+
note: there are multiple different versions of crate `foo` in the dependency graph
8+
--> foo-current.rs:7:1
9+
|
10+
4 | extern crate foo;
11+
| ----------------- one version of crate `foo` is used here, as a direct dependency of the current crate
12+
5 |
13+
6 | pub struct Struct;
14+
| ----------------- this type implements the required trait
15+
7 | pub trait Trait {}
16+
| ^^^^^^^^^^^^^^^ this is the required trait
17+
|
18+
::: foo-prev.rs:X:Y
19+
|
20+
4 | pub struct Struct;
21+
| ----------------- this type doesn't implement the required trait
22+
5 | pub trait Trait {}
23+
| --------------- this is the found trait
24+
= note: two types coming from two different versions of the same crate are different types even if they look the same
25+
= help: you can use `cargo tree` to explore your dependency tree
26+
note: required by a bound in `check_trait`
27+
--> foo-current.rs:10:19
28+
|
29+
10 | fn check_trait<T: Trait>() {}
30+
| ^^^^^ required by this bound in `check_trait`
31+
32+
error: aborting due to 1 previous error
33+
34+
For more information about this error, try `rustc --explain E0277`.

tests/run-make/crate-loading-crate-depends-on-itself/rmake.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,25 @@
77
// and traits of the different versions are mixed, we produce diagnostic output and not an ICE.
88
// #133563
99

10-
use run_make_support::{rust_lib_name, rustc};
10+
use run_make_support::{diff, rust_lib_name, rustc};
1111

1212
fn main() {
1313
rustc().input("foo-prev.rs").run();
1414

15-
rustc()
15+
let out = rustc()
1616
.extra_filename("current")
1717
.metadata("current")
1818
.input("foo-current.rs")
1919
.extern_("foo", rust_lib_name("foo"))
2020
.run_fail()
21-
.assert_stderr_contains(r#"
22-
note: there are multiple different versions of crate `foo` in the dependency graph
23-
--> foo-current.rs:7:1
24-
|
25-
4 | extern crate foo;
26-
| ----------------- one version of crate `foo` is used here, as a direct dependency of the current crate
27-
5 |
28-
6 | pub struct Struct;
29-
| ----------------- this type implements the required trait
30-
7 | pub trait Trait {}
31-
| ^^^^^^^^^^^^^^^ this is the required trait"#);
21+
.stderr_utf8();
22+
23+
// We don't remap the path of the `foo-prev` crate, so we remap it here.
24+
let mut lines: Vec<_> = out.lines().collect();
25+
for line in &mut lines {
26+
if line.starts_with(" ::: ") {
27+
*line = " ::: foo-prev.rs:X:Y";
28+
}
29+
}
30+
diff().expected_file("foo.stderr").actual_text("(rustc)", &lines.join("\n")).run();
3231
}

0 commit comments

Comments
 (0)