Fortify clippy tests.

This commit is contained in:
Camille GILLOT 2023-03-07 17:51:48 +00:00
parent 0d56034a25
commit a5a01b21e6
5 changed files with 24 additions and 21 deletions

View File

@ -31,9 +31,7 @@ fn mul(mut self, right: i32) -> Vec1 {
#[allow(clippy::no_effect)]
#[warn(clippy::erasing_op)]
fn main() {
let x: u8 = 0;
fn test(x: u8) {
x * 0;
0 & x;
0 / x;
@ -41,3 +39,7 @@ fn main() {
0 * Vec1 { x: 5 };
Vec1 { x: 5 } * 0;
}
fn main() {
test(0)
}

View File

@ -1,5 +1,5 @@
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/erasing_op.rs:37:5
--> $DIR/erasing_op.rs:35:5
|
LL | x * 0;
| ^^^^^
@ -7,25 +7,25 @@ LL | x * 0;
= note: `-D clippy::erasing-op` implied by `-D warnings`
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/erasing_op.rs:38:5
--> $DIR/erasing_op.rs:36:5
|
LL | 0 & x;
| ^^^^^
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/erasing_op.rs:39:5
--> $DIR/erasing_op.rs:37:5
|
LL | 0 / x;
| ^^^^^
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/erasing_op.rs:41:5
--> $DIR/erasing_op.rs:39:5
|
LL | 0 * Vec1 { x: 5 };
| ^^^^^^^^^^^^^^^^^
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/erasing_op.rs:42:5
--> $DIR/erasing_op.rs:40:5
|
LL | Vec1 { x: 5 } * 0;
| ^^^^^^^^^^^^^^^^^

View File

@ -4,7 +4,7 @@
#[rustfmt::skip]
fn main() {
let mut i = 1i32;
let mut var1 = 0i32;
let mut var1 = 13i32;
let mut var2 = -1i32;
1 + i;
i * 2;

View File

@ -1,9 +1,6 @@
#![warn(clippy::overflow_check_conditional)]
fn main() {
let a: u32 = 1;
let b: u32 = 2;
let c: u32 = 3;
fn test(a: u32, b: u32, c: u32) {
if a + b < a {}
if a > a + b {}
if a + b < b {}
@ -23,3 +20,7 @@ fn main() {
if i > i + j {}
if i - j < i {}
}
fn main() {
test(1, 2, 3)
}

View File

@ -1,5 +1,5 @@
error: you are trying to use classic C overflow conditions that will fail in Rust
--> $DIR/overflow_check_conditional.rs:7:8
--> $DIR/overflow_check_conditional.rs:4:8
|
LL | if a + b < a {}
| ^^^^^^^^^
@ -7,43 +7,43 @@ LL | if a + b < a {}
= note: `-D clippy::overflow-check-conditional` implied by `-D warnings`
error: you are trying to use classic C overflow conditions that will fail in Rust
--> $DIR/overflow_check_conditional.rs:8:8
--> $DIR/overflow_check_conditional.rs:5:8
|
LL | if a > a + b {}
| ^^^^^^^^^
error: you are trying to use classic C overflow conditions that will fail in Rust
--> $DIR/overflow_check_conditional.rs:9:8
--> $DIR/overflow_check_conditional.rs:6:8
|
LL | if a + b < b {}
| ^^^^^^^^^
error: you are trying to use classic C overflow conditions that will fail in Rust
--> $DIR/overflow_check_conditional.rs:10:8
--> $DIR/overflow_check_conditional.rs:7:8
|
LL | if b > a + b {}
| ^^^^^^^^^
error: you are trying to use classic C underflow conditions that will fail in Rust
--> $DIR/overflow_check_conditional.rs:11:8
--> $DIR/overflow_check_conditional.rs:8:8
|
LL | if a - b > b {}
| ^^^^^^^^^
error: you are trying to use classic C underflow conditions that will fail in Rust
--> $DIR/overflow_check_conditional.rs:12:8
--> $DIR/overflow_check_conditional.rs:9:8
|
LL | if b < a - b {}
| ^^^^^^^^^
error: you are trying to use classic C underflow conditions that will fail in Rust
--> $DIR/overflow_check_conditional.rs:13:8
--> $DIR/overflow_check_conditional.rs:10:8
|
LL | if a - b > a {}
| ^^^^^^^^^
error: you are trying to use classic C underflow conditions that will fail in Rust
--> $DIR/overflow_check_conditional.rs:14:8
--> $DIR/overflow_check_conditional.rs:11:8
|
LL | if a < a - b {}
| ^^^^^^^^^