rust-clippy/tests/ui/unnecessary_first_then_check.fixed
2024-09-19 21:27:39 +02:00

22 lines
538 B
Rust

#![warn(clippy::unnecessary_first_then_check)]
#![allow(clippy::useless_vec, clippy::const_is_empty)]
fn main() {
let s = [1, 2, 3];
let _: bool = !s.is_empty();
let _: bool = s.is_empty();
let v = vec![1, 2, 3];
let _: bool = !v.is_empty();
let n = [[1, 2, 3], [4, 5, 6]];
let _: bool = !n[0].is_empty();
let _: bool = n[0].is_empty();
struct Foo {
bar: &'static [i32],
}
let f = [Foo { bar: &[] }];
let _: bool = !f[0].bar.is_empty();
let _: bool = f[0].bar.is_empty();
}