mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
62a82b361c
In the updated nightly version, it seems that rustfmt now supports formatting let-chains. Since we're using them a lot, it's a lot of reformatting.
36 lines
796 B
Rust
36 lines
796 B
Rust
#![warn(clippy::comparison_to_empty)]
|
|
#![allow(clippy::borrow_deref_ref, clippy::needless_if, clippy::useless_vec)]
|
|
#![feature(let_chains)]
|
|
|
|
fn main() {
|
|
// Disallow comparisons to empty
|
|
let s = String::new();
|
|
let _ = s.is_empty();
|
|
let _ = !s.is_empty();
|
|
|
|
let v = vec![0];
|
|
let _ = v.is_empty();
|
|
let _ = !v.is_empty();
|
|
if (*v).is_empty() {}
|
|
let s = [0].as_slice();
|
|
if s.is_empty() {}
|
|
if s.is_empty() {}
|
|
if s.is_empty()
|
|
&& s.is_empty()
|
|
{}
|
|
|
|
// Allow comparisons to non-empty
|
|
let s = String::new();
|
|
let _ = s == " ";
|
|
let _ = s != " ";
|
|
|
|
let v = vec![0];
|
|
let _ = v == [0];
|
|
let _ = v != [0];
|
|
if let [0] = &*v {}
|
|
let s = [0].as_slice();
|
|
if let [0] = s {}
|
|
if let [0] = &*s
|
|
&& s == [0]
|
|
{}
|
|
}
|