about summary refs log tree commit diff
path: root/src/test/run-pass
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-05-08 22:34:52 -0400
committerGitHub <noreply@github.com>2017-05-08 22:34:52 -0400
commit2f0deec98bf360af18bead78b2d8092ba4aa6c50 (patch)
treee6a811679fe233fe1d9d51d533f60b2878294ff2 /src/test/run-pass
parent7f3070315597917c65f511a055c2b56451283eb1 (diff)
parent82e07363916146f0d6e01199ef30544e7fdd6248 (diff)
downloadrust-2f0deec98bf360af18bead78b2d8092ba4aa6c50.tar.gz
rust-2f0deec98bf360af18bead78b2d8092ba4aa6c50.zip
Rollup merge of #41838 - z1mvader:fix_fn_args_coerce_closure, r=nikomatsakis
Fixed argument inference for closures when coercing into 'fn'

This fixes https://github.com/rust-lang/rust/issues/41755. The tests  `compile-fail/closure-no-fn.rs` and `compile-fail/issue-40000.rs` were modified. A new test `run-pass/closure_to_fn_coercion-expected-types.rs` was added

r? @nikomatsakis
Diffstat (limited to 'src/test/run-pass')
-rw-r--r--src/test/run-pass/closure_to_fn_coercion-expected-types.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/run-pass/closure_to_fn_coercion-expected-types.rs b/src/test/run-pass/closure_to_fn_coercion-expected-types.rs
new file mode 100644
index 00000000000..7214ebfaf07
--- /dev/null
+++ b/src/test/run-pass/closure_to_fn_coercion-expected-types.rs
@@ -0,0 +1,17 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+// Ensure that we deduce expected argument types when a `fn()` type is expected (#41755)
+
+#![feature(closure_to_fn_coercion)]
+fn foo(f: fn(Vec<u32>) -> usize) { }
+
+fn main() {
+    foo(|x| x.len())
+}