blob: 4c2ac3ba40a21f90d955cd89e8e54251f4e9533a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#![warn(clippy::unnecessary_first_then_check)]
#![allow(clippy::useless_vec, clippy::const_is_empty)]
fn main() {
let s = [1, 2, 3];
let _: bool = s.first().is_some();
//~^ unnecessary_first_then_check
let _: bool = s.first().is_none();
//~^ unnecessary_first_then_check
let v = vec![1, 2, 3];
let _: bool = v.first().is_some();
//~^ unnecessary_first_then_check
let n = [[1, 2, 3], [4, 5, 6]];
let _: bool = n[0].first().is_some();
//~^ unnecessary_first_then_check
let _: bool = n[0].first().is_none();
//~^ unnecessary_first_then_check
struct Foo {
bar: &'static [i32],
}
let f = [Foo { bar: &[] }];
let _: bool = f[0].bar.first().is_some();
//~^ unnecessary_first_then_check
let _: bool = f[0].bar.first().is_none();
//~^ unnecessary_first_then_check
}
|