]> git.proxmox.com Git - rustc.git/blob - tests/ui/type/type-mismatch.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / type / type-mismatch.rs
1 #![allow(non_camel_case_types)]
2
3 trait Qux {}
4 struct A;
5 struct B;
6 impl Qux for A {}
7 impl Qux for B {}
8
9 struct Foo<T, U: Qux = A, V: Qux = B>(T, U, V);
10
11 struct foo;
12 struct bar;
13
14 fn want<T>(t: T) {}
15
16 fn have_usize(f: usize) {
17 want::<foo>(f); //~ ERROR mismatched types
18 want::<bar>(f); //~ ERROR mismatched types
19 want::<Foo<usize>>(f); //~ ERROR mismatched types
20 want::<Foo<usize, B>>(f); //~ ERROR mismatched types
21 want::<Foo<foo>>(f); //~ ERROR mismatched types
22 want::<Foo<foo, B>>(f); //~ ERROR mismatched types
23 want::<Foo<bar>>(f); //~ ERROR mismatched types
24 want::<Foo<bar, B>>(f); //~ ERROR mismatched types
25 }
26
27 fn have_foo(f: foo) {
28 want::<usize>(f); //~ ERROR mismatched types
29 want::<bar>(f); //~ ERROR mismatched types
30 want::<Foo<usize>>(f); //~ ERROR mismatched types
31 want::<Foo<usize, B>>(f); //~ ERROR mismatched types
32 want::<Foo<foo>>(f); //~ ERROR mismatched types
33 want::<Foo<foo, B>>(f); //~ ERROR mismatched types
34 want::<Foo<bar>>(f); //~ ERROR mismatched types
35 want::<Foo<bar, B>>(f); //~ ERROR mismatched types
36 }
37
38 fn have_foo_foo(f: Foo<foo>) {
39 want::<usize>(f); //~ ERROR mismatched types
40 want::<foo>(f); //~ ERROR mismatched types
41 want::<bar>(f); //~ ERROR mismatched types
42 want::<Foo<usize>>(f); //~ ERROR mismatched types
43 want::<Foo<usize, B>>(f); //~ ERROR mismatched types
44 want::<Foo<foo, B>>(f); //~ ERROR mismatched types
45 want::<Foo<bar>>(f); //~ ERROR mismatched types
46 want::<Foo<bar, B>>(f); //~ ERROR mismatched types
47 want::<&Foo<foo>>(f); //~ ERROR mismatched types
48 want::<&Foo<foo, B>>(f); //~ ERROR mismatched types
49 }
50
51 fn have_foo_foo_b(f: Foo<foo, B>) {
52 want::<usize>(f); //~ ERROR mismatched types
53 want::<foo>(f); //~ ERROR mismatched types
54 want::<bar>(f); //~ ERROR mismatched types
55 want::<Foo<usize>>(f); //~ ERROR mismatched types
56 want::<Foo<usize, B>>(f); //~ ERROR mismatched types
57 want::<Foo<foo>>(f); //~ ERROR mismatched types
58 want::<Foo<bar>>(f); //~ ERROR mismatched types
59 want::<Foo<bar, B>>(f); //~ ERROR mismatched types
60 want::<&Foo<foo>>(f); //~ ERROR mismatched types
61 want::<&Foo<foo, B>>(f); //~ ERROR mismatched types
62 }
63
64 fn have_foo_foo_b_a(f: Foo<foo, B, A>) {
65 want::<usize>(f); //~ ERROR mismatched types
66 want::<foo>(f); //~ ERROR mismatched types
67 want::<bar>(f); //~ ERROR mismatched types
68 want::<Foo<usize>>(f); //~ ERROR mismatched types
69 want::<Foo<usize, B>>(f); //~ ERROR mismatched types
70 want::<Foo<foo>>(f); //~ ERROR mismatched types
71 want::<Foo<foo, B>>(f); //~ ERROR mismatched types
72 want::<Foo<bar>>(f); //~ ERROR mismatched types
73 want::<Foo<bar, B>>(f); //~ ERROR mismatched types
74 want::<&Foo<foo>>(f); //~ ERROR mismatched types
75 want::<&Foo<foo, B>>(f); //~ ERROR mismatched types
76 }
77
78 fn main() {}