]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-path-2.rs
Rollup merge of #105567 - TimNN:kcfi16, r=nikic
[rust.git] / src / test / ui / associated-types / associated-types-path-2.rs
1 // Test type checking of uses of associated types via sugary paths.
2
3 pub trait Foo {
4     type A;
5
6     fn dummy(&self) { }
7 }
8
9 impl Foo for i32 {
10     type A = u32;
11 }
12
13 pub fn f1<T: Foo>(a: T, x: T::A) {}
14 pub fn f2<T: Foo>(a: T) -> T::A {
15     panic!();
16 }
17
18 pub fn f1_int_int() {
19     f1(2i32, 4i32);
20     //~^ ERROR mismatched types
21     //~| expected `u32`, found `i32`
22 }
23
24 pub fn f1_int_uint() {
25     f1(2i32, 4u32);
26 }
27
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     //~| ERROR `u32: Foo` is not satisfied
33 }
34
35 pub fn f1_uint_int() {
36     f1(2u32, 4i32);
37     //~^ ERROR `u32: Foo` is not satisfied
38     //~| ERROR `u32: Foo` is not satisfied
39     //~| ERROR `u32: Foo` is not satisfied
40 }
41
42 pub fn f2_int() {
43     let _: i32 = f2(2i32);
44     //~^ ERROR mismatched types
45     //~| expected `i32`, found `u32`
46 }
47
48 pub fn main() { }