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.

17 lines
268 B
Rust
Raw Normal View History

const X : usize = 2;
const fn f(x: usize) -> usize {
2018-01-16 08:24:38 +00:00
let mut sum = 0;
2018-10-01 10:52:47 +00:00
for i in 0..x {
2024-11-22 02:31:42 +00:00
//~^ ERROR cannot use `for`
//~| ERROR cannot use `for`
sum += i;
}
2018-01-16 08:24:38 +00:00
sum
}
#[allow(unused_variables)]
fn main() {
let a : [i32; f(X)];
}