diff options
Diffstat (limited to 'tests/ui/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs')
-rw-r--r-- | tests/ui/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ui/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs b/tests/ui/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs new file mode 100644 index 000000000..d2eaee304 --- /dev/null +++ b/tests/ui/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs @@ -0,0 +1,19 @@ +// 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>(val: T, f: &dyn Fn(T)) { f(val) } + +pub fn main() { + doit(0, &|x /*: isize*/ | { x.to_int(); }); +} |