2016-01-15 12:16:54 +00:00
|
|
|
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 {
|
2022-09-10 07:07:49 +00:00
|
|
|
//~^ ERROR cannot convert
|
2021-07-29 21:15:53 +00:00
|
|
|
//~| ERROR `for` is not allowed in a `const fn`
|
2022-09-10 07:07:49 +00:00
|
|
|
//~| ERROR mutable references are not allowed in constant functions
|
|
|
|
//~| ERROR cannot call non-const fn
|
2016-01-15 12:16:54 +00:00
|
|
|
sum += i;
|
|
|
|
}
|
2018-01-16 08:24:38 +00:00
|
|
|
sum
|
2016-01-15 12:16:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(unused_variables)]
|
|
|
|
fn main() {
|
2018-08-26 13:19:34 +00:00
|
|
|
let a : [i32; f(X)];
|
2016-01-15 12:16:54 +00:00
|
|
|
}
|