Files
rust/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs
Ralf Jung 17946c22b1 const-eval error: always say in which item the error occurred
also adjust the wording a little so that we don't say "the error occurred here" for two different spans
2025-06-07 13:42:30 +02:00

29 lines
733 B
Rust

//@ 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