]> git.lizzy.rs Git - rust.git/blob - src/test/ui/type/type-mismatch-same-crate-name.rs
Auto merge of #99443 - jam1garner:mips-virt-feature, r=nagisa
[rust.git] / src / test / ui / type / type-mismatch-same-crate-name.rs
1 // aux-build:crate_a1.rs
2 // aux-build:crate_a2.rs
3
4 // This tests the extra note reported when a type error deals with
5 // seemingly identical types.
6 // The main use case of this error is when there are two crates
7 // (generally different versions of the same crate) with the same name
8 // causing a type mismatch. Here, we simulate that error using block-scoped
9 // aliased `extern crate` declarations.
10
11 fn main() {
12     let foo2 = {extern crate crate_a2 as a; a::Foo};
13     let bar2 = {extern crate crate_a2 as a; a::bar()};
14     {
15         extern crate crate_a1 as a;
16         a::try_foo(foo2);
17         //~^ ERROR mismatched types
18         //~| perhaps two different versions of crate `crate_a1`
19         //~| expected struct `main::a::Foo`
20         a::try_bar(bar2);
21         //~^ ERROR mismatched types
22         //~| perhaps two different versions of crate `crate_a1`
23         //~| expected trait `main::a::Bar`
24         //~| expected struct `Box<(dyn main::a::Bar + 'static)>`
25         //~| found struct `Box<dyn main::a::Bar>`
26     }
27 }