]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs
Rollup merge of #106856 - vadorovsky:fix-atomic-annotations, r=joshtriplett
[rust.git] / tests / ui / unboxed-closures / unboxed-closures-infer-arg-types-from-expected-bound.rs
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 {
8     fn to_int(&self) {}
9 }
10
11 impl ToPrimitive for isize {}
12 impl ToPrimitive for i32 {}
13 impl ToPrimitive for usize {}
14
15 fn doit<T,F>(val: T, f: &F)
16     where F : Fn(T)
17 {
18     f(val)
19 }
20
21 pub fn main() {
22     doit(0, &|x /*: isize*/ | { x.to_int(); });
23 }