diff options
Diffstat (limited to 'src/test/ui/typeck/typeck_type_placeholder_mismatch.rs')
-rw-r--r-- | src/test/ui/typeck/typeck_type_placeholder_mismatch.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/ui/typeck/typeck_type_placeholder_mismatch.rs b/src/test/ui/typeck/typeck_type_placeholder_mismatch.rs new file mode 100644 index 000000000..2f9cfcf8d --- /dev/null +++ b/src/test/ui/typeck/typeck_type_placeholder_mismatch.rs @@ -0,0 +1,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 struct `Foo`, found struct `Bar` + let y: Foo<usize> = x; +} + +fn test2() { + let x: Foo<_> = Bar::<usize>(PhantomData); + //~^ ERROR mismatched types + //~| expected struct `Foo<_>` + //~| found struct `Bar<usize>` + //~| expected struct `Foo`, found struct `Bar` +} |