Add regression test for issue 13110

This commit is contained in:
Lzu Tao 2024-07-17 18:23:40 +07:00
parent 0ee9f44568
commit c65ddb8728
3 changed files with 33 additions and 1 deletions

View file

@ -58,3 +58,13 @@ fn main() {
// as function param
drop(vec![f(); 1]);
}
macro_rules! LEN {
() => {0};
}
fn issue_13110() {
f(); let _data: [i32; 0] = [];
const LENGTH: usize = LEN!();
f(); let _data: [i32; 0] = [];
}

View file

@ -58,3 +58,13 @@ fn main() {
// as function param
drop(vec![f(); 1]);
}
macro_rules! LEN {
() => {0};
}
fn issue_13110() {
let _data = [f(); LEN!()];
const LENGTH: usize = LEN!();
let _data = [f(); LENGTH];
}

View file

@ -73,5 +73,17 @@ error: function or method calls as the initial value in zero-sized array initial
LL | [f(); N];
| ^^^^^^^^ help: consider using: `{ f(); [] as [i32; 0] }`
error: aborting due to 12 previous errors
error: function or method calls as the initial value in zero-sized array initializers may cause side effects
--> tests/ui/zero_repeat_side_effects.rs:67:5
|
LL | let _data = [f(); LEN!()];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f(); let _data: [i32; 0] = [];`
error: function or method calls as the initial value in zero-sized array initializers may cause side effects
--> tests/ui/zero_repeat_side_effects.rs:69:5
|
LL | let _data = [f(); LENGTH];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f(); let _data: [i32; 0] = [];`
error: aborting due to 14 previous errors