rust/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
505 B
Rust
Raw Normal View History

2019-09-21 09:09:38 -05:00
// compile-flags: -Zunleash-the-miri-inside-of-you
fn double(x: usize) -> usize {
x * 2
}
const X: fn(usize) -> usize = double;
2020-05-03 07:23:08 -05:00
const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
2020-04-29 02:53:22 -05:00
x(y)
2022-09-21 06:05:20 -05:00
//~^ ERROR evaluation of constant value failed
//~| ERROR evaluation of constant value failed
}
2019-09-21 09:09:38 -05:00
const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
fn main() {
assert_eq!(Y, 4);
assert_eq!(Z, 4);
}