rust/tests/ui/consts/const-fn-error.rs

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

19 lines
406 B
Rust
Raw Normal View History

const X : usize = 2;
const fn f(x: usize) -> usize {
2018-01-16 02:24:38 -06:00
let mut sum = 0;
2018-10-01 05:52:47 -05:00
for i in 0..x {
//~^ ERROR cannot convert
2021-07-29 16:15:53 -05:00
//~| ERROR `for` is not allowed in a `const fn`
//~| ERROR mutable references are not allowed in constant functions
//~| ERROR cannot call non-const fn
sum += i;
}
2018-01-16 02:24:38 -06:00
sum
}
#[allow(unused_variables)]
fn main() {
let a : [i32; f(X)];
}