summaryrefslogtreecommitdiffstats
path: root/src/test/ui/unboxed-closures/unboxed-closures-call-fn-autoderef.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/unboxed-closures/unboxed-closures-call-fn-autoderef.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/unboxed-closures/unboxed-closures-call-fn-autoderef.rs b/src/test/ui/unboxed-closures/unboxed-closures-call-fn-autoderef.rs
new file mode 100644
index 000000000..e23a75ab3
--- /dev/null
+++ b/src/test/ui/unboxed-closures/unboxed-closures-call-fn-autoderef.rs
@@ -0,0 +1,18 @@
+// run-pass
+#![allow(unused_imports)]
+// Test that the call operator autoderefs when calling a bounded type parameter.
+
+use std::ops::FnMut;
+
+fn call_with_2(x: &fn(isize) -> isize) -> isize
+{
+ x(2) // look ma, no `*`
+}
+
+fn subtract_22(x: isize) -> isize { x - 22 }
+
+pub fn main() {
+ let subtract_22: fn(isize) -> isize = subtract_22;
+ let z = call_with_2(&subtract_22);
+ assert_eq!(z, -20);
+}