]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs
Auto merge of #81132 - bugadani:map-prealloc, r=matthewjasper
[rust.git] / src / test / ui / consts / const-eval / const_fn_ptr_fail2.rs
1 // build-fail
2 // compile-flags: -Zunleash-the-miri-inside-of-you
3
4 #![feature(const_fn)]
5 #![allow(const_err)]
6
7 fn double(x: usize) -> usize {
8     x * 2
9 }
10 const X: fn(usize) -> usize = double;
11
12 const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
13     x(y)
14 }
15
16 const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
17 const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
18
19 fn main() {
20     assert_eq!(Y, 4);
21     //~^ ERROR evaluation of constant value failed
22     assert_eq!(Z, 4);
23     //~^ ERROR evaluation of constant value failed
24 }