summaryrefslogtreecommitdiffstats
path: root/src/test/ui/unboxed-closures/unboxed-closures-call-fn-autoderef.rs
blob: e23a75ab334e56404baa4e692e208abfaff079cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);
}