33//@ ignore-wasm64
44// ignore-tidy-linelength
55
6- use run_make_support:: { rust_lib_name, rustc} ;
6+ use run_make_support:: { diff , rust_lib_name, rustc} ;
77
88fn main ( ) {
99 rustc ( ) . input ( "multiple-dep-versions-1.rs" ) . run ( ) ;
@@ -13,83 +13,26 @@ fn main() {
1313 . extern_ ( "dependency" , rust_lib_name ( "dependency2" ) )
1414 . run ( ) ;
1515
16- rustc ( )
16+ let out = rustc ( )
1717 . input ( "multiple-dep-versions.rs" )
1818 . extern_ ( "dependency" , rust_lib_name ( "dependency" ) )
1919 . extern_ ( "dep_2_reexport" , rust_lib_name ( "foo" ) )
20+ . ui_testing ( )
2021 . run_fail ( )
21- . assert_stderr_contains ( r#"error[E0277]: the trait bound `dep_2_reexport::Type: Trait` is not satisfied
22- --> multiple-dep-versions.rs:7:18
23- |
24- 7 | do_something(Type);
25- | ------------ ^^^^ the trait `Trait` is not implemented for `dep_2_reexport::Type`
26- | |
27- | required by a bound introduced by this call
28- |
29- note: there are multiple different versions of crate `dependency` in the dependency graph"# )
30- . assert_stderr_contains ( r#"
31- 3 | pub struct Type(pub i32);
32- | --------------- this type implements the required trait
33- 4 | pub trait Trait {
34- | ^^^^^^^^^^^^^^^ this is the required trait
35- "# )
36- . assert_stderr_contains ( r#"
37- 1 | extern crate dep_2_reexport;
38- | ---------------------------- one version of crate `dependency` is used here, as a dependency of crate `foo`
39- 2 | extern crate dependency;
40- | ------------------------ one version of crate `dependency` is used here, as a direct dependency of the current crate"# )
41- . assert_stderr_contains ( r#"
42- 3 | pub struct Type;
43- | --------------- this type doesn't implement the required trait
44- 4 | pub trait Trait {
45- | --------------- this is the found trait
46- = note: two types coming from two different versions of the same crate are different types even if they look the same
47- = help: you can use `cargo tree` to explore your dependency tree"# )
48- . assert_stderr_contains ( r#"note: required by a bound in `do_something`"# )
49- . assert_stderr_contains ( r#"
50- 12 | pub fn do_something<X: Trait>(_: X) {}
51- | ^^^^^ required by this bound in `do_something`"# )
52- . assert_stderr_contains ( r#"error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope
53- --> multiple-dep-versions.rs:8:10
54- |
55- 8 | Type.foo();
56- | ^^^ method not found in `Type`
57- |
58- note: there are multiple different versions of crate `dependency` in the dependency graph"# )
59- . assert_stderr_contains ( r#"
60- 4 | pub trait Trait {
61- | ^^^^^^^^^^^^^^^ this is the trait that is needed
62- 5 | fn foo(&self);
63- | -------------- the method is available for `dep_2_reexport::Type` here
64- |
65- ::: multiple-dep-versions.rs:4:18
66- |
67- 4 | use dependency::{Trait, do_something};
68- | ----- `Trait` imported here doesn't correspond to the right version of crate `dependency`"# )
69- . assert_stderr_contains ( r#"
70- 4 | pub trait Trait {
71- | --------------- this is the trait that was imported"# )
72- . assert_stderr_contains ( r#"
73- error[E0599]: no function or associated item named `bar` found for struct `dep_2_reexport::Type` in the current scope
74- --> multiple-dep-versions.rs:9:11
75- |
76- 9 | Type::bar();
77- | ^^^ function or associated item not found in `Type`
78- |
79- note: there are multiple different versions of crate `dependency` in the dependency graph"# )
80- . assert_stderr_contains ( r#"
81- 4 | pub trait Trait {
82- | ^^^^^^^^^^^^^^^ this is the trait that is needed
83- 5 | fn foo(&self);
84- 6 | fn bar();
85- | --------- the associated function is available for `dep_2_reexport::Type` here
86- |
87- ::: multiple-dep-versions.rs:4:18
88- |
89- 4 | use dependency::{Trait, do_something};
90- | ----- `Trait` imported here doesn't correspond to the right version of crate `dependency`"# )
91- . assert_stderr_contains (
92- r#"
93- 6 | pub struct OtherType;
94- | -------------------- this type doesn't implement the required trait"# ) ;
22+ . stderr_utf8 ( ) ;
23+
24+ // We don't remap all the paths, so we remap it here.
25+ let mut lines: Vec < _ > = out. lines ( ) . collect ( ) ;
26+ for line in & mut lines {
27+ if line. starts_with ( " --> " ) {
28+ * line = " --> replaced" ;
29+ }
30+ if line. starts_with ( " ::: " ) {
31+ * line = " ::: replaced" ;
32+ }
33+ }
34+ diff ( )
35+ . expected_file ( "multiple-dep-versions.stderr" )
36+ . actual_text ( "(rustc)" , & lines. join ( "\n " ) )
37+ . run ( ) ;
9538}
0 commit comments