summaryrefslogtreecommitdiffstats
path: root/src/test/ui/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs
blob: c3abdd8aab09eeda58ea7e50ce43a8aea00078a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// run-pass
// Test that we are able to infer that the type of `x` is `isize` based
// on the expected type from the object.

// pretty-expanded FIXME #23616

pub trait ToPrimitive {
    fn to_int(&self) {}
}

impl ToPrimitive for isize {}
impl ToPrimitive for i32 {}
impl ToPrimitive for usize {}

fn doit<T,F>(val: T, f: &F)
    where F : Fn(&T)
{
    f(&val)
}

pub fn main() {
    doit(0, &|x /*: isize*/ | { x.to_int(); });
}