]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs
Rollup merge of #105843 - compiler-errors:sugg-const, r=lcnr
[rust.git] / src / test / ui / unboxed-closures / unboxed-closures-infer-arg-types-from-expected-object-type.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>(val: T, f: &dyn Fn(T)) { f(val) }
16
17 pub fn main() {
18     doit(0, &|x /*: isize*/ | { x.to_int(); });
19 }