1 // run-pass 2 // Test that we are able to infer that the type of `x` is `isize` based 3 // on the expected type from the object. 4 5 // pretty-expanded FIXME #23616 6 7 pub trait ToPrimitive { to_int(&self)8 fn to_int(&self) {} 9 } 10 11 impl ToPrimitive for isize {} 12 impl ToPrimitive for i32 {} 13 impl ToPrimitive for usize {} 14 doit<T,F>(val: T, f: &F) where F : Fn(T)15fn doit<T,F>(val: T, f: &F) 16 where F : Fn(T) 17 { 18 f(val) 19 } 20 main()21pub fn main() { 22 doit(0, &|x /*: isize*/ | { x.to_int(); }); 23 } 24