1 // Test that we invoking `foo()` successfully resolves to the trait `Foo`
2 // (prompting the mismatched types error) but does not influence the choice
3 // of what kind of `Vec` we have, eventually leading to a type error.
6 fn foo(&self) -> isize;
9 impl Foo for Vec<usize> {
10 fn foo(&self) -> isize {1}
13 impl Foo for Vec<isize> {
14 fn foo(&self) -> isize {2}
17 // This is very hokey: we have heuristics to suppress messages about
18 // type annotations needed. But placing these two bits of code into
19 // distinct functions, in this order, causes us to print out both
20 // errors I'd like to see.
23 // we couldn't infer the type of the vector just based on calling foo()...
24 let mut x = Vec::new();
25 //~^ ERROR type annotations needed
26 x.foo(); //~ ERROR type annotations needed
30 let mut x = Vec::new();
32 // ...but we still resolved `foo()` to the trait and hence know the return type.
33 let y: usize = x.foo(); //~ ERROR mismatched types