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 16:09:38 +02: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 14:23:08 +02:00
const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
2020-04-29 09:53:22 +02:00
x(y)
2022-09-21 13:05:20 +02:00
//~^ ERROR evaluation of constant value failed
//~| ERROR evaluation of constant value failed
}
2019-09-21 16:09:38 +02: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);
}