1 // Test type checking of uses of associated types via sugary paths.
2
3 pub trait Foo {
4 type A;
5
dummy(&self)6 fn dummy(&self) { }
7 }
8
9 impl Foo for i32 {
10 type A = u32;
11 }
12
f1<T: Foo>(a: T, x: T::A)13 pub fn f1<T: Foo>(a: T, x: T::A) {}
f2<T: Foo>(a: T) -> T::A14 pub fn f2<T: Foo>(a: T) -> T::A {
15 panic!();
16 }
17
f1_int_int()18 pub fn f1_int_int() {
19 f1(2i32, 4i32);
20 //~^ ERROR mismatched types
21 //~| expected `u32`, found `i32`
22 }
23
f1_int_uint()24 pub fn f1_int_uint() {
25 f1(2i32, 4u32);
26 }
27
f1_uint_uint()28 pub fn f1_uint_uint() {
29 f1(2u32, 4u32);
30 //~^ ERROR `u32: Foo` is not satisfied
31 //~| ERROR `u32: Foo` is not satisfied
32 }
33
f1_uint_int()34 pub fn f1_uint_int() {
35 f1(2u32, 4i32);
36 //~^ ERROR `u32: Foo` is not satisfied
37 //~| ERROR `u32: Foo` is not satisfied
38 }
39
f2_int()40 pub fn f2_int() {
41 let _: i32 = f2(2i32);
42 //~^ ERROR mismatched types
43 //~| expected `i32`, found `u32`
44 }
45
main()46 pub fn main() { }
47