2025-06-30 00:05:58 +05:00
|
|
|
//! Arrays created with `[value; length]` syntax need the length to be known at
|
|
|
|
|
//! compile time. This test makes sure the compiler rejects runtime values like
|
|
|
|
|
//! function parameters in the length position.
|
2013-03-06 13:34:44 -08:00
|
|
|
|
|
|
|
|
fn main() {
|
2025-06-30 00:05:58 +05:00
|
|
|
fn create_array(n: usize) {
|
2015-03-30 01:23:15 +02:00
|
|
|
let _x = [0; n];
|
2016-12-21 12:32:59 +02:00
|
|
|
//~^ ERROR attempt to use a non-constant value in a constant [E0435]
|
2013-03-06 13:34:44 -08:00
|
|
|
}
|
|
|
|
|
}
|