Skip to content

Commit 61ae64b

Browse files
committed
Add test case for array false positive
1 parent ad9a7ac commit 61ae64b

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

tests/ui/vec.fixed

+9
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,12 @@ fn issue_12101() {
242242
for a in &[1, 2] {}
243243
//~^ useless_vec
244244
}
245+
246+
fn issue_14531() {
247+
// The lint used to suggest using an array rather than a reference to a slice.
248+
249+
fn requires_ref_slice(v: &[()]) {}
250+
let v = &[];
251+
//~^ useless_vec
252+
requires_ref_slice(v);
253+
}

tests/ui/vec.rs

+9
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,12 @@ fn issue_12101() {
242242
for a in &(vec![1, 2]) {}
243243
//~^ useless_vec
244244
}
245+
246+
fn issue_14531() {
247+
// The lint used to suggest using an array rather than a reference to a slice.
248+
249+
fn requires_ref_slice(v: &[()]) {}
250+
let v = &vec![];
251+
//~^ useless_vec
252+
requires_ref_slice(v);
253+
}

tests/ui/vec.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,11 @@ error: useless use of `vec!`
127127
LL | for a in &(vec![1, 2]) {}
128128
| ^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]`
129129

130-
error: aborting due to 21 previous errors
130+
error: useless use of `vec!`
131+
--> tests/ui/vec.rs:250:13
132+
|
133+
LL | let v = &vec![];
134+
| ^^^^^^^ help: you can use a slice directly: `&[]`
135+
136+
error: aborting due to 22 previous errors
131137

0 commit comments

Comments
 (0)