Add a lint to suggest uint == 0 over uint <= 0
This commit is contained in:
parent
5402ef3d27
commit
e48fbba864
5 changed files with 71 additions and 2 deletions
14
tests/compile-fail/absurd_unsigned_comparisons.rs
Normal file
14
tests/compile-fail/absurd_unsigned_comparisons.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
#[deny(absurd_unsigned_comparisons)]
|
||||
fn main() {
|
||||
1u32 <= 0; //~ERROR testing whether an unsigned integer is non-positive
|
||||
1u8 <= 0; //~ERROR testing whether an unsigned integer is non-positive
|
||||
1i32 <= 0;
|
||||
0 >= 1u32; //~ERROR testing whether an unsigned integer is non-positive
|
||||
0 >= 1;
|
||||
1u32 > 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue