]> git.lizzy.rs Git - rust.git/blob - tests/ui/typeck/typeck_type_placeholder_mismatch.rs
Auto merge of #107663 - matthiaskrgr:107423-point-at-EOF-code, r=compiler-errors
[rust.git] / tests / ui / typeck / typeck_type_placeholder_mismatch.rs
1 // This test checks that genuine type errors with partial
2 // type hints are understandable.
3
4 use std::marker::PhantomData;
5
6 struct Foo<T>(PhantomData<T>);
7 struct Bar<U>(PhantomData<U>);
8
9 pub fn main() {
10 }
11
12 fn test1() {
13     let x: Foo<_> = Bar::<usize>(PhantomData);
14     //~^ ERROR mismatched types
15     //~| expected struct `Foo<_>`
16     //~| found struct `Bar<usize>`
17     //~| expected `Foo<_>`, found `Bar<usize>`
18     let y: Foo<usize> = x;
19 }
20
21 fn test2() {
22     let x: Foo<_> = Bar::<usize>(PhantomData);
23     //~^ ERROR mismatched types
24     //~| expected struct `Foo<_>`
25     //~| found struct `Bar<usize>`
26     //~| expected `Foo<_>`, found `Bar<usize>`
27 }