summaryrefslogtreecommitdiffstats
path: root/src/test/ui/unboxed-closures/unboxed-closures-blanket-fn.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/unboxed-closures/unboxed-closures-blanket-fn.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/ui/unboxed-closures/unboxed-closures-blanket-fn.rs b/src/test/ui/unboxed-closures/unboxed-closures-blanket-fn.rs
new file mode 100644
index 000000000..ca1d31ca5
--- /dev/null
+++ b/src/test/ui/unboxed-closures/unboxed-closures-blanket-fn.rs
@@ -0,0 +1,27 @@
+// run-pass
+#![allow(unused_variables)]
+// Test that you can supply `&F` where `F: Fn()`.
+
+#![feature(lang_items)]
+
+fn a<F:Fn() -> i32>(f: F) -> i32 {
+ f()
+}
+
+fn b(f: &dyn Fn() -> i32) -> i32 {
+ a(f)
+}
+
+fn c<F:Fn() -> i32>(f: &F) -> i32 {
+ a(f)
+}
+
+fn main() {
+ let z: isize = 7;
+
+ let x = b(&|| 22);
+ assert_eq!(x, 22);
+
+ let x = c(&|| 22);
+ assert_eq!(x, 22);
+}