Skip to content

Commit a5a01b2

Browse files
committed
Fortify clippy tests.
1 parent 0d56034 commit a5a01b2

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

Diff for: src/tools/clippy/tests/ui/erasing_op.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ impl core::ops::Mul<i32> for Vec1 {
3131

3232
#[allow(clippy::no_effect)]
3333
#[warn(clippy::erasing_op)]
34-
fn main() {
35-
let x: u8 = 0;
36-
34+
fn test(x: u8) {
3735
x * 0;
3836
0 & x;
3937
0 / x;
4038
0 * Meter; // no error: Output type is different from the non-zero argument
4139
0 * Vec1 { x: 5 };
4240
Vec1 { x: 5 } * 0;
4341
}
42+
43+
fn main() {
44+
test(0)
45+
}

Diff for: src/tools/clippy/tests/ui/erasing_op.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error: this operation will always return zero. This is likely not the intended outcome
2-
--> $DIR/erasing_op.rs:37:5
2+
--> $DIR/erasing_op.rs:35:5
33
|
44
LL | x * 0;
55
| ^^^^^
66
|
77
= note: `-D clippy::erasing-op` implied by `-D warnings`
88

99
error: this operation will always return zero. This is likely not the intended outcome
10-
--> $DIR/erasing_op.rs:38:5
10+
--> $DIR/erasing_op.rs:36:5
1111
|
1212
LL | 0 & x;
1313
| ^^^^^
1414

1515
error: this operation will always return zero. This is likely not the intended outcome
16-
--> $DIR/erasing_op.rs:39:5
16+
--> $DIR/erasing_op.rs:37:5
1717
|
1818
LL | 0 / x;
1919
| ^^^^^
2020

2121
error: this operation will always return zero. This is likely not the intended outcome
22-
--> $DIR/erasing_op.rs:41:5
22+
--> $DIR/erasing_op.rs:39:5
2323
|
2424
LL | 0 * Vec1 { x: 5 };
2525
| ^^^^^^^^^^^^^^^^^
2626

2727
error: this operation will always return zero. This is likely not the intended outcome
28-
--> $DIR/erasing_op.rs:42:5
28+
--> $DIR/erasing_op.rs:40:5
2929
|
3030
LL | Vec1 { x: 5 } * 0;
3131
| ^^^^^^^^^^^^^^^^^

Diff for: src/tools/clippy/tests/ui/integer_arithmetic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#[rustfmt::skip]
55
fn main() {
66
let mut i = 1i32;
7-
let mut var1 = 0i32;
7+
let mut var1 = 13i32;
88
let mut var2 = -1i32;
99
1 + i;
1010
i * 2;

Diff for: src/tools/clippy/tests/ui/overflow_check_conditional.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#![warn(clippy::overflow_check_conditional)]
22

3-
fn main() {
4-
let a: u32 = 1;
5-
let b: u32 = 2;
6-
let c: u32 = 3;
3+
fn test(a: u32, b: u32, c: u32) {
74
if a + b < a {}
85
if a > a + b {}
96
if a + b < b {}
@@ -23,3 +20,7 @@ fn main() {
2320
if i > i + j {}
2421
if i - j < i {}
2522
}
23+
24+
fn main() {
25+
test(1, 2, 3)
26+
}

Diff for: src/tools/clippy/tests/ui/overflow_check_conditional.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
error: you are trying to use classic C overflow conditions that will fail in Rust
2-
--> $DIR/overflow_check_conditional.rs:7:8
2+
--> $DIR/overflow_check_conditional.rs:4:8
33
|
44
LL | if a + b < a {}
55
| ^^^^^^^^^
66
|
77
= note: `-D clippy::overflow-check-conditional` implied by `-D warnings`
88

99
error: you are trying to use classic C overflow conditions that will fail in Rust
10-
--> $DIR/overflow_check_conditional.rs:8:8
10+
--> $DIR/overflow_check_conditional.rs:5:8
1111
|
1212
LL | if a > a + b {}
1313
| ^^^^^^^^^
1414

1515
error: you are trying to use classic C overflow conditions that will fail in Rust
16-
--> $DIR/overflow_check_conditional.rs:9:8
16+
--> $DIR/overflow_check_conditional.rs:6:8
1717
|
1818
LL | if a + b < b {}
1919
| ^^^^^^^^^
2020

2121
error: you are trying to use classic C overflow conditions that will fail in Rust
22-
--> $DIR/overflow_check_conditional.rs:10:8
22+
--> $DIR/overflow_check_conditional.rs:7:8
2323
|
2424
LL | if b > a + b {}
2525
| ^^^^^^^^^
2626

2727
error: you are trying to use classic C underflow conditions that will fail in Rust
28-
--> $DIR/overflow_check_conditional.rs:11:8
28+
--> $DIR/overflow_check_conditional.rs:8:8
2929
|
3030
LL | if a - b > b {}
3131
| ^^^^^^^^^
3232

3333
error: you are trying to use classic C underflow conditions that will fail in Rust
34-
--> $DIR/overflow_check_conditional.rs:12:8
34+
--> $DIR/overflow_check_conditional.rs:9:8
3535
|
3636
LL | if b < a - b {}
3737
| ^^^^^^^^^
3838

3939
error: you are trying to use classic C underflow conditions that will fail in Rust
40-
--> $DIR/overflow_check_conditional.rs:13:8
40+
--> $DIR/overflow_check_conditional.rs:10:8
4141
|
4242
LL | if a - b > a {}
4343
| ^^^^^^^^^
4444

4545
error: you are trying to use classic C underflow conditions that will fail in Rust
46-
--> $DIR/overflow_check_conditional.rs:14:8
46+
--> $DIR/overflow_check_conditional.rs:11:8
4747
|
4848
LL | if a < a - b {}
4949
| ^^^^^^^^^

0 commit comments

Comments
 (0)