]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-path-2.rs
Auto merge of #57006 - GuillaumeGomez:no-crate-filter, r=QuietMisdreavus
[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 }
33
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
40 pub fn f2_int() {
41     let _: i32 = f2(2i32);
42     //~^ ERROR mismatched types
43     //~| expected i32, found u32
44 }
45
46 pub fn main() { }