mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
Add regression test for issue 13110
This commit is contained in:
parent
0ee9f44568
commit
c65ddb8728
3 changed files with 33 additions and 1 deletions
|
@ -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] = [];
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue