1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that we invoking `foo()` successfully resolves to the trait `foo`
12 // (prompting the mismatched types error) but does not influence the choice
13 // of what kind of `Vec` we have, eventually leading to a type error.
16 fn foo(&self) -> isize;
19 impl foo for Vec<usize> {
20 fn foo(&self) -> isize {1}
23 impl foo for Vec<isize> {
24 fn foo(&self) -> isize {2}
27 // This is very hokey: we have heuristics to suppress messages about
28 // type annotations required. But placing these two bits of code into
29 // distinct functions, in this order, causes us to print out both
30 // errors I'd like to see.
33 // we couldn't infer the type of the vector just based on calling foo()...
34 let mut x = Vec::new();
35 //~^ ERROR unable to infer enough type information about `T` [E0282]
40 let mut x = Vec::new();
42 // ...but we still resolved `foo()` to the trait and hence know the return type.
43 let y: usize = x.foo(); //~ ERROR mismatched types