]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closures-call-fn-autoderef.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / unboxed-closures / unboxed-closures-call-fn-autoderef.rs
1 // run-pass
2 #![allow(unused_imports)]
3 // Test that the call operator autoderefs when calling a bounded type parameter.
4
5 use std::ops::FnMut;
6
7 fn call_with_2(x: &fn(isize) -> isize) -> isize
8 {
9     x(2) // look ma, no `*`
10 }
11
12 fn subtract_22(x: isize) -> isize { x - 22 }
13
14 pub fn main() {
15     let subtract_22: fn(isize) -> isize = subtract_22;
16     let z = call_with_2(&subtract_22);
17     assert_eq!(z, -20);
18 }