]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/comparison_to_empty.fixed
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / comparison_to_empty.fixed
CommitLineData
f20569fa
XL
1// run-rustfix
2
3#![warn(clippy::comparison_to_empty)]
4
5fn main() {
6 // Disallow comparisons to empty
7 let s = String::new();
8 let _ = s.is_empty();
9 let _ = !s.is_empty();
10
11 let v = vec![0];
12 let _ = v.is_empty();
13 let _ = !v.is_empty();
14
15 // Allow comparisons to non-empty
16 let s = String::new();
17 let _ = s == " ";
18 let _ = s != " ";
19
20 let v = vec![0];
21 let _ = v == [0];
22 let _ = v != [0];
23}