about summary refs log tree commit diff
path: root/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs
blob: 8d928e26378201f786bd51033724e33daa96e5c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//@ compile-flags: -Zunleash-the-miri-inside-of-you

fn double(x: usize) -> usize {
    x * 2
}
const X: fn(usize) -> usize = double;

const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
    x(y)
    //~^ NOTE inside `bar`
    //~| NOTE the failure occurred here
    //~| NOTE inside `bar`
    //~| NOTE the failure occurred here
}

const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
//~^ NOTE failed inside this call
//~| ERROR calling non-const function `double`
const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
//~^ NOTE failed inside this call
//~| ERROR calling non-const function `double`

fn main() {
    assert_eq!(Y, 4);
    assert_eq!(Z, 4);
}

//~? WARN skipping const checks