summaryrefslogtreecommitdiffstats
path: root/tests/ui/typeck/typeck_type_placeholder_mismatch.rs
blob: 718b6deed1bb13c75ddebfde2b7cb8e5de18431d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// This test checks that genuine type errors with partial
// type hints are understandable.

use std::marker::PhantomData;

struct Foo<T>(PhantomData<T>);
struct Bar<U>(PhantomData<U>);

pub fn main() {
}

fn test1() {
    let x: Foo<_> = Bar::<usize>(PhantomData);
    //~^ ERROR mismatched types
    //~| expected struct `Foo<_>`
    //~| found struct `Bar<usize>`
    //~| expected `Foo<_>`, found `Bar<usize>`
    let y: Foo<usize> = x;
}

fn test2() {
    let x: Foo<_> = Bar::<usize>(PhantomData);
    //~^ ERROR mismatched types
    //~| expected struct `Foo<_>`
    //~| found struct `Bar<usize>`
    //~| expected `Foo<_>`, found `Bar<usize>`
}