Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend ABSURD_UNSIGNED_COMPARISONS to handle more types
- Loading branch information
Showing
5 changed files
with
183 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#![feature(plugin)] | ||
#![plugin(clippy)] | ||
|
||
#![deny(absurd_extreme_comparisons)] | ||
#![allow(unused)] | ||
fn main() { | ||
const Z: u32 = 0; | ||
|
||
let u: u32 = 42; | ||
|
||
u <= 0; //~ERROR this comparison involving the minimum or maximum element for this type contains a case that is always true or always false | ||
u <= Z; //~ERROR this comparison involving | ||
u < Z; //~ERROR this comparison involving | ||
Z >= u; //~ERROR this comparison involving | ||
Z > u; //~ERROR this comparison involving | ||
u > std::u32::MAX; //~ERROR this comparison involving | ||
u >= std::u32::MAX; //~ERROR this comparison involving | ||
std::u32::MAX < u; //~ERROR this comparison involving | ||
std::u32::MAX <= u; //~ERROR this comparison involving | ||
|
||
1-1 > u; | ||
//~^ ERROR this comparison involving | ||
//~| HELP because 1-1 is the minimum value for this type, this comparison is always false | ||
u >= !0; | ||
//~^ ERROR this comparison involving | ||
//~| HELP because !0 is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == !0 instead | ||
u <= 12 - 2*6; | ||
//~^ ERROR this comparison involving | ||
//~| HELP because 12 - 2*6 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 12 - 2*6 instead | ||
|
||
let i: i8 = 0; | ||
i < -127 - 1; //~ERROR this comparison involving | ||
std::i8::MAX >= i; //~ERROR this comparison involving | ||
3-7 < std::i32::MIN; //~ERROR this comparison involving | ||
|
||
let b = false; | ||
b >= true; //~ERROR this comparison involving | ||
false > b; //~ERROR this comparison involving | ||
|
||
u > 0; // ok | ||
|
||
// this is handled by unit_cmp | ||
() < {}; //~WARNING <-comparison of unit values detected. | ||
} |
This file was deleted.
Oops, something went wrong.