Auto merge of #3520 - matthiaskrgr:test_rustfmt_skip, r=phansch

add rustfmt::skip attributes to a couple of tests

part of rustfmt'ing test code
This commit is contained in:
bors 2018-12-09 18:03:53 +00:00
commit 1fbcbe4aa1
24 changed files with 817 additions and 832 deletions

View file

@ -7,13 +7,10 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![warn(clippy::absurd_extreme_comparisons)] #![warn(clippy::absurd_extreme_comparisons)]
#![allow(unused, clippy::eq_op, clippy::no_effect, clippy::unnecessary_operation, clippy::needless_pass_by_value)] #![allow(unused, clippy::eq_op, clippy::no_effect, clippy::unnecessary_operation, clippy::needless_pass_by_value)]
#[rustfmt::skip]
fn main() { fn main() {
const Z: u32 = 0; const Z: u32 = 0;
let u: u32 = 42; let u: u32 = 42;

View file

@ -1,144 +1,144 @@
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:20:5 --> $DIR/absurd-extreme-comparisons.rs:17:5
| |
20 | u <= 0; 17 | u <= 0;
| ^^^^^^ | ^^^^^^
| |
= note: `-D clippy::absurd-extreme-comparisons` implied by `-D warnings` = note: `-D clippy::absurd-extreme-comparisons` implied by `-D warnings`
= help: because 0 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 0 instead = help: because 0 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 0 instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:21:5 --> $DIR/absurd-extreme-comparisons.rs:18:5
| |
21 | u <= Z; 18 | u <= Z;
| ^^^^^^ | ^^^^^^
| |
= help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == Z instead = help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == Z instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:22:5 --> $DIR/absurd-extreme-comparisons.rs:19:5
| |
22 | u < Z; 19 | u < Z;
| ^^^^^ | ^^^^^
| |
= help: because Z is the minimum value for this type, this comparison is always false = help: because Z is the minimum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:23:5 --> $DIR/absurd-extreme-comparisons.rs:20:5
| |
23 | Z >= u; 20 | Z >= u;
| ^^^^^^ | ^^^^^^
| |
= help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using Z == u instead = help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using Z == u instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:24:5 --> $DIR/absurd-extreme-comparisons.rs:21:5
| |
24 | Z > u; 21 | Z > u;
| ^^^^^ | ^^^^^
| |
= help: because Z is the minimum value for this type, this comparison is always false = help: because Z is the minimum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:25:5 --> $DIR/absurd-extreme-comparisons.rs:22:5
| |
25 | u > std::u32::MAX; 22 | u > std::u32::MAX;
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
| |
= help: because std::u32::MAX is the maximum value for this type, this comparison is always false = help: because std::u32::MAX is the maximum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:26:5 --> $DIR/absurd-extreme-comparisons.rs:23:5
| |
26 | u >= std::u32::MAX; 23 | u >= std::u32::MAX;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
| |
= help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == std::u32::MAX instead = help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == std::u32::MAX instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:27:5 --> $DIR/absurd-extreme-comparisons.rs:24:5
| |
27 | std::u32::MAX < u; 24 | std::u32::MAX < u;
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
| |
= help: because std::u32::MAX is the maximum value for this type, this comparison is always false = help: because std::u32::MAX is the maximum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:28:5 --> $DIR/absurd-extreme-comparisons.rs:25:5
| |
28 | std::u32::MAX <= u; 25 | std::u32::MAX <= u;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
| |
= help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using std::u32::MAX == u instead = help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using std::u32::MAX == u instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:29:5 --> $DIR/absurd-extreme-comparisons.rs:26:5
| |
29 | 1-1 > u; 26 | 1-1 > u;
| ^^^^^^^ | ^^^^^^^
| |
= help: because 1-1 is the minimum value for this type, this comparison is always false = help: because 1-1 is the minimum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:30:5 --> $DIR/absurd-extreme-comparisons.rs:27:5
| |
30 | u >= !0; 27 | u >= !0;
| ^^^^^^^ | ^^^^^^^
| |
= 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 = 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
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:31:5 --> $DIR/absurd-extreme-comparisons.rs:28:5
| |
31 | u <= 12 - 2*6; 28 | u <= 12 - 2*6;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
| |
= 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 = 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
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:33:5 --> $DIR/absurd-extreme-comparisons.rs:30:5
| |
33 | i < -127 - 1; 30 | i < -127 - 1;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
| |
= help: because -127 - 1 is the minimum value for this type, this comparison is always false = help: because -127 - 1 is the minimum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:34:5 --> $DIR/absurd-extreme-comparisons.rs:31:5
| |
34 | std::i8::MAX >= i; 31 | std::i8::MAX >= i;
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
| |
= help: because std::i8::MAX is the maximum value for this type, this comparison is always true = help: because std::i8::MAX is the maximum value for this type, this comparison is always true
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:35:5 --> $DIR/absurd-extreme-comparisons.rs:32:5
| |
35 | 3-7 < std::i32::MIN; 32 | 3-7 < std::i32::MIN;
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= help: because std::i32::MIN is the minimum value for this type, this comparison is always false = help: because std::i32::MIN is the minimum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:37:5 --> $DIR/absurd-extreme-comparisons.rs:34:5
| |
37 | b >= true; 34 | b >= true;
| ^^^^^^^^^ | ^^^^^^^^^
| |
= help: because true is the maximum value for this type, the case where the two sides are not equal never occurs, consider using b == true instead = help: because true is the maximum value for this type, the case where the two sides are not equal never occurs, consider using b == true instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:38:5 --> $DIR/absurd-extreme-comparisons.rs:35:5
| |
38 | false > b; 35 | false > b;
| ^^^^^^^^^ | ^^^^^^^^^
| |
= help: because false is the minimum value for this type, this comparison is always false = help: because false is the minimum value for this type, this comparison is always false
error: <-comparison of unit values detected. This will always be false error: <-comparison of unit values detected. This will always be false
--> $DIR/absurd-extreme-comparisons.rs:41:5 --> $DIR/absurd-extreme-comparisons.rs:38:5
| |
41 | () < {}; 38 | () < {};
| ^^^^^^^ | ^^^^^^^
| |
= note: #[deny(clippy::unit_cmp)] on by default = note: #[deny(clippy::unit_cmp)] on by default

View file

@ -8,11 +8,10 @@
// except according to those terms. // except according to those terms.
#![warn(clippy::integer_arithmetic, clippy::float_arithmetic)] #![warn(clippy::integer_arithmetic, clippy::float_arithmetic)]
#![allow(unused, clippy::shadow_reuse, clippy::shadow_unrelated, clippy::no_effect, clippy::unnecessary_operation)] #![allow(unused, clippy::shadow_reuse, clippy::shadow_unrelated, clippy::no_effect, clippy::unnecessary_operation)]
#[rustfmt::skip]
fn main() { fn main() {
let i = 1i32; let i = 1i32;
1 + i; 1 + i;

View file

@ -1,72 +1,72 @@
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/arithmetic.rs:18:5 --> $DIR/arithmetic.rs:17:5
| |
18 | 1 + i; 17 | 1 + i;
| ^^^^^ | ^^^^^
| |
= note: `-D clippy::integer-arithmetic` implied by `-D warnings` = note: `-D clippy::integer-arithmetic` implied by `-D warnings`
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/arithmetic.rs:19:5 --> $DIR/arithmetic.rs:18:5
| |
19 | i * 2; 18 | i * 2;
| ^^^^^ | ^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/arithmetic.rs:20:5 --> $DIR/arithmetic.rs:19:5
| |
20 | / 1 % 19 | / 1 %
21 | | i / 2; // no error, this is part of the expression in the preceding line 20 | | i / 2; // no error, this is part of the expression in the preceding line
| |_________^ | |_________^
error: integer arithmetic detected
--> $DIR/arithmetic.rs:21:5
|
21 | i - 2 + 2 - i;
| ^^^^^^^^^^^^^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/arithmetic.rs:22:5 --> $DIR/arithmetic.rs:22:5
| |
22 | i - 2 + 2 - i; 22 | -i;
| ^^^^^^^^^^^^^
error: integer arithmetic detected
--> $DIR/arithmetic.rs:23:5
|
23 | -i;
| ^^ | ^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:33:5 --> $DIR/arithmetic.rs:32:5
| |
33 | f * 2.0; 32 | f * 2.0;
| ^^^^^^^ | ^^^^^^^
| |
= note: `-D clippy::float-arithmetic` implied by `-D warnings` = note: `-D clippy::float-arithmetic` implied by `-D warnings`
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:34:5
|
34 | 1.0 + f;
| ^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:35:5 --> $DIR/arithmetic.rs:35:5
| |
35 | 1.0 + f; 35 | f * 2.0;
| ^^^^^^^ | ^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:36:5 --> $DIR/arithmetic.rs:36:5
| |
36 | f * 2.0; 36 | f / 2.0;
| ^^^^^^^ | ^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:37:5 --> $DIR/arithmetic.rs:37:5
| |
37 | f / 2.0; 37 | f - 2.0 * 4.2;
| ^^^^^^^ | ^^^^^^^^^^^^^
error: floating-point arithmetic detected error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:38:5 --> $DIR/arithmetic.rs:38:5
| |
38 | f - 2.0 * 4.2; 38 | -f;
| ^^^^^^^^^^^^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:39:5
|
39 | -f;
| ^^ | ^^
error: aborting due to 11 previous errors error: aborting due to 11 previous errors

View file

@ -8,9 +8,7 @@
// except according to those terms. // except according to those terms.
#[rustfmt::skip]
#[warn(clippy::collapsible_if)] #[warn(clippy::collapsible_if)]
fn main() { fn main() {
let x = "hello"; let x = "hello";

View file

@ -1,259 +1,259 @@
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:18:5 --> $DIR/collapsible_if.rs:16:5
| |
18 | / if x == "hello" { 16 | / if x == "hello" {
19 | | if y == "world" { 17 | | if y == "world" {
20 | | println!("Hello world!"); 18 | | println!("Hello world!");
21 | | } 19 | | }
22 | | } 20 | | }
| |_____^ | |_____^
| |
= note: `-D clippy::collapsible-if` implied by `-D warnings` = note: `-D clippy::collapsible-if` implied by `-D warnings`
help: try help: try
| |
18 | if x == "hello" && y == "world" { 16 | if x == "hello" && y == "world" {
19 | println!("Hello world!"); 17 | println!("Hello world!");
20 | } 18 | }
| |
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:24:5 --> $DIR/collapsible_if.rs:22:5
| |
24 | / if x == "hello" || x == "world" { 22 | / if x == "hello" || x == "world" {
25 | | if y == "world" || y == "hello" { 23 | | if y == "world" || y == "hello" {
26 | | println!("Hello world!"); 24 | | println!("Hello world!");
27 | | } 25 | | }
28 | | } 26 | | }
| |_____^ | |_____^
help: try help: try
| |
24 | if (x == "hello" || x == "world") && (y == "world" || y == "hello") { 22 | if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
25 | println!("Hello world!"); 23 | println!("Hello world!");
26 | } 24 | }
| |
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:30:5 --> $DIR/collapsible_if.rs:28:5
| |
30 | / if x == "hello" && x == "world" { 28 | / if x == "hello" && x == "world" {
31 | | if y == "world" || y == "hello" { 29 | | if y == "world" || y == "hello" {
32 | | println!("Hello world!"); 30 | | println!("Hello world!");
33 | | } 31 | | }
34 | | } 32 | | }
| |_____^ | |_____^
help: try help: try
| |
30 | if x == "hello" && x == "world" && (y == "world" || y == "hello") { 28 | if x == "hello" && x == "world" && (y == "world" || y == "hello") {
31 | println!("Hello world!"); 29 | println!("Hello world!");
32 | } 30 | }
| |
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:36:5 --> $DIR/collapsible_if.rs:34:5
| |
36 | / if x == "hello" || x == "world" { 34 | / if x == "hello" || x == "world" {
37 | | if y == "world" && y == "hello" { 35 | | if y == "world" && y == "hello" {
38 | | println!("Hello world!"); 36 | | println!("Hello world!");
39 | | } 37 | | }
40 | | } 38 | | }
| |_____^ | |_____^
help: try help: try
| |
36 | if (x == "hello" || x == "world") && y == "world" && y == "hello" { 34 | if (x == "hello" || x == "world") && y == "world" && y == "hello" {
37 | println!("Hello world!"); 35 | println!("Hello world!");
38 | } 36 | }
| |
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:42:5 --> $DIR/collapsible_if.rs:40:5
| |
42 | / if x == "hello" && x == "world" { 40 | / if x == "hello" && x == "world" {
43 | | if y == "world" && y == "hello" { 41 | | if y == "world" && y == "hello" {
44 | | println!("Hello world!"); 42 | | println!("Hello world!");
45 | | } 43 | | }
46 | | } 44 | | }
| |_____^ | |_____^
help: try help: try
| |
42 | if x == "hello" && x == "world" && y == "world" && y == "hello" { 40 | if x == "hello" && x == "world" && y == "world" && y == "hello" {
43 | println!("Hello world!"); 41 | println!("Hello world!");
44 | } 42 | }
| |
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:48:5 --> $DIR/collapsible_if.rs:46:5
| |
48 | / if 42 == 1337 { 46 | / if 42 == 1337 {
49 | | if 'a' != 'A' { 47 | | if 'a' != 'A' {
50 | | println!("world!") 48 | | println!("world!")
51 | | } 49 | | }
52 | | } 50 | | }
| |_____^ | |_____^
help: try help: try
| |
48 | if 42 == 1337 && 'a' != 'A' { 46 | if 42 == 1337 && 'a' != 'A' {
49 | println!("world!") 47 | println!("world!")
50 | } 48 | }
| |
error: this `else { if .. }` block can be collapsed error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:57:12 --> $DIR/collapsible_if.rs:55:12
| |
57 | } else { 55 | } else {
| ____________^ | ____________^
58 | | if y == "world" { 56 | | if y == "world" {
59 | | println!("world!") 57 | | println!("world!")
60 | | } 58 | | }
61 | | } 59 | | }
| |_____^ | |_____^
help: try help: try
| |
57 | } else if y == "world" { 55 | } else if y == "world" {
58 | println!("world!") 56 | println!("world!")
59 | } 57 | }
| |
error: this `else { if .. }` block can be collapsed error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:65:12 --> $DIR/collapsible_if.rs:63:12
| |
65 | } else { 63 | } else {
| ____________^ | ____________^
66 | | if let Some(42) = Some(42) { 64 | | if let Some(42) = Some(42) {
67 | | println!("world!") 65 | | println!("world!")
68 | | } 66 | | }
69 | | } 67 | | }
| |_____^ | |_____^
help: try help: try
| |
65 | } else if let Some(42) = Some(42) { 63 | } else if let Some(42) = Some(42) {
66 | println!("world!") 64 | println!("world!")
67 | } 65 | }
| |
error: this `else { if .. }` block can be collapsed error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:73:12 --> $DIR/collapsible_if.rs:71:12
| |
73 | } else { 71 | } else {
| ____________^ | ____________^
74 | | if y == "world" { 72 | | if y == "world" {
75 | | println!("world") 73 | | println!("world")
76 | | } 74 | | }
... | ... |
79 | | } 77 | | }
80 | | } 78 | | }
| |_____^ | |_____^
help: try help: try
| |
73 | } else if y == "world" { 71 | } else if y == "world" {
74 | println!("world") 72 | println!("world")
75 | } 73 | }
76 | else { 74 | else {
77 | println!("!") 75 | println!("!")
78 | } 76 | }
| |
error: this `else { if .. }` block can be collapsed error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:84:12 --> $DIR/collapsible_if.rs:82:12
| |
84 | } else { 82 | } else {
| ____________^ | ____________^
85 | | if let Some(42) = Some(42) { 83 | | if let Some(42) = Some(42) {
86 | | println!("world") 84 | | println!("world")
87 | | } 85 | | }
... | ... |
90 | | } 88 | | }
91 | | } 89 | | }
| |_____^ | |_____^
help: try help: try
| |
84 | } else if let Some(42) = Some(42) { 82 | } else if let Some(42) = Some(42) {
85 | println!("world") 83 | println!("world")
86 | } 84 | }
87 | else { 85 | else {
88 | println!("!") 86 | println!("!")
89 | } 87 | }
| |
error: this `else { if .. }` block can be collapsed error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:95:12 --> $DIR/collapsible_if.rs:93:12
| |
95 | } else { 93 | } else {
| ____________^ | ____________^
96 | | if let Some(42) = Some(42) { 94 | | if let Some(42) = Some(42) {
97 | | println!("world") 95 | | println!("world")
98 | | } 96 | | }
... | ... |
101 | | } 99 | | }
102 | | } 100 | | }
| |_____^ | |_____^
help: try help: try
| |
95 | } else if let Some(42) = Some(42) { 93 | } else if let Some(42) = Some(42) {
96 | println!("world") 94 | println!("world")
97 | } 95 | }
98 | else { 96 | else {
99 | println!("!") 97 | println!("!")
100 | } 98 | }
| |
error: this `else { if .. }` block can be collapsed error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:106:12 --> $DIR/collapsible_if.rs:104:12
| |
106 | } else { 104 | } else {
| ____________^ | ____________^
107 | | if x == "hello" { 105 | | if x == "hello" {
108 | | println!("world") 106 | | println!("world")
109 | | } 107 | | }
... | ... |
112 | | } 110 | | }
113 | | } 111 | | }
| |_____^ | |_____^
help: try help: try
| |
106 | } else if x == "hello" { 104 | } else if x == "hello" {
107 | println!("world") 105 | println!("world")
108 | } 106 | }
109 | else { 107 | else {
110 | println!("!") 108 | println!("!")
111 | } 109 | }
| |
error: this `else { if .. }` block can be collapsed error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:117:12 --> $DIR/collapsible_if.rs:115:12
| |
117 | } else { 115 | } else {
| ____________^ | ____________^
118 | | if let Some(42) = Some(42) { 116 | | if let Some(42) = Some(42) {
119 | | println!("world") 117 | | println!("world")
120 | | } 118 | | }
... | ... |
123 | | } 121 | | }
124 | | } 122 | | }
| |_____^ | |_____^
help: try help: try
| |
117 | } else if let Some(42) = Some(42) { 115 | } else if let Some(42) = Some(42) {
118 | println!("world") 116 | println!("world")
119 | } 117 | }
120 | else { 118 | else {
121 | println!("!") 119 | println!("!")
122 | } 120 | }
| |
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:176:5 --> $DIR/collapsible_if.rs:174:5
| |
176 | / if x == "hello" { 174 | / if x == "hello" {
177 | | if y == "world" { // Collapsible 175 | | if y == "world" { // Collapsible
178 | | println!("Hello world!"); 176 | | println!("Hello world!");
179 | | } 177 | | }
180 | | } 178 | | }
| |_____^ | |_____^
help: try help: try
| |
176 | if x == "hello" && y == "world" { // Collapsible 174 | if x == "hello" && y == "world" { // Collapsible
177 | println!("Hello world!"); 175 | println!("Hello world!");
178 | } 176 | }
| |
error: aborting due to 14 previous errors error: aborting due to 14 previous errors

View file

@ -8,12 +8,11 @@
// except according to those terms. // except according to those terms.
#![allow(clippy::all)] #![allow(clippy::all)]
#![warn(clippy::cyclomatic_complexity)] #![warn(clippy::cyclomatic_complexity)]
#![allow(unused)] #![allow(unused)]
#[rustfmt::skip]
fn main() { fn main() {
if true { if true {
println!("a"); println!("a");
@ -362,6 +361,7 @@ fn early() -> Result<i32, &'static str> {
return Ok(5); return Ok(5);
} }
#[rustfmt::skip]
#[clippy::cyclomatic_complexity = "0"] #[clippy::cyclomatic_complexity = "0"]
fn early_ret() -> i32 { fn early_ret() -> i32 {
let a = if true { 42 } else { return 0; }; let a = if true { 42 } else { return 0; };

View file

@ -1,256 +1,256 @@
error: the function has a cyclomatic complexity of 28 error: the function has a cyclomatic complexity of 28
--> $DIR/cyclomatic_complexity.rs:17:1 --> $DIR/cyclomatic_complexity.rs:16:1
| |
17 | / fn main() { 16 | / fn main() {
18 | | if true { 17 | | if true {
19 | | println!("a"); 18 | | println!("a");
20 | | } 19 | | }
... | ... |
98 | | } 97 | | }
99 | | } 98 | | }
| |_^ | |_^
| |
= note: `-D clippy::cyclomatic-complexity` implied by `-D warnings` = note: `-D clippy::cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 7 error: the function has a cyclomatic complexity of 7
--> $DIR/cyclomatic_complexity.rs:102:1 --> $DIR/cyclomatic_complexity.rs:101:1
| |
102 | / fn kaboom() { 101 | / fn kaboom() {
103 | | let n = 0; 102 | | let n = 0;
104 | | 'a: for i in 0..20 { 103 | | 'a: for i in 0..20 {
105 | | 'b: for j in i..20 { 104 | | 'b: for j in i..20 {
... | ... |
120 | | } 119 | | }
121 | | } 120 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:148:1 --> $DIR/cyclomatic_complexity.rs:147:1
| |
148 | / fn lots_of_short_circuits() -> bool { 147 | / fn lots_of_short_circuits() -> bool {
149 | | true && false && true && false && true && false && true 148 | | true && false && true && false && true && false && true
150 | | } 149 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:153:1 --> $DIR/cyclomatic_complexity.rs:152:1
| |
153 | / fn lots_of_short_circuits2() -> bool { 152 | / fn lots_of_short_circuits2() -> bool {
154 | | true || false || true || false || true || false || true 153 | | true || false || true || false || true || false || true
155 | | } 154 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:158:1 --> $DIR/cyclomatic_complexity.rs:157:1
| |
158 | / fn baa() { 157 | / fn baa() {
159 | | let x = || match 99 { 158 | | let x = || match 99 {
160 | | 0 => 0, 159 | | 0 => 0,
161 | | 1 => 1, 160 | | 1 => 1,
... | ... |
172 | | } 171 | | }
173 | | } 172 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:159:13 --> $DIR/cyclomatic_complexity.rs:158:13
| |
159 | let x = || match 99 { 158 | let x = || match 99 {
| _____________^ | _____________^
160 | | 0 => 0, 159 | | 0 => 0,
161 | | 1 => 1, 160 | | 1 => 1,
162 | | 2 => 2, 161 | | 2 => 2,
... | ... |
166 | | _ => 42, 165 | | _ => 42,
167 | | }; 166 | | };
| |_____^ | |_____^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:176:1 --> $DIR/cyclomatic_complexity.rs:175:1
| |
176 | / fn bar() { 175 | / fn bar() {
177 | | match 99 { 176 | | match 99 {
178 | | 0 => println!("hi"), 177 | | 0 => println!("hi"),
179 | | _ => println!("bye"), 178 | | _ => println!("bye"),
180 | | } 179 | | }
181 | | } 180 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:195:1 --> $DIR/cyclomatic_complexity.rs:194:1
| |
195 | / fn barr() { 194 | / fn barr() {
196 | | match 99 { 195 | | match 99 {
197 | | 0 => println!("hi"), 196 | | 0 => println!("hi"),
198 | | 1 => println!("bla"), 197 | | 1 => println!("bla"),
... | ... |
201 | | } 200 | | }
202 | | } 201 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 3 error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity.rs:205:1 --> $DIR/cyclomatic_complexity.rs:204:1
| |
205 | / fn barr2() { 204 | / fn barr2() {
206 | | match 99 { 205 | | match 99 {
207 | | 0 => println!("hi"), 206 | | 0 => println!("hi"),
208 | | 1 => println!("bla"), 207 | | 1 => println!("bla"),
... | ... |
217 | | } 216 | | }
218 | | } 217 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:221:1 --> $DIR/cyclomatic_complexity.rs:220:1
| |
221 | / fn barrr() { 220 | / fn barrr() {
222 | | match 99 { 221 | | match 99 {
223 | | 0 => println!("hi"), 222 | | 0 => println!("hi"),
224 | | 1 => panic!("bla"), 223 | | 1 => panic!("bla"),
... | ... |
227 | | } 226 | | }
228 | | } 227 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 3 error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity.rs:231:1 --> $DIR/cyclomatic_complexity.rs:230:1
| |
231 | / fn barrr2() { 230 | / fn barrr2() {
232 | | match 99 { 231 | | match 99 {
233 | | 0 => println!("hi"), 232 | | 0 => println!("hi"),
234 | | 1 => panic!("bla"), 233 | | 1 => panic!("bla"),
... | ... |
243 | | } 242 | | }
244 | | } 243 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:247:1 --> $DIR/cyclomatic_complexity.rs:246:1
| |
247 | / fn barrrr() { 246 | / fn barrrr() {
248 | | match 99 { 247 | | match 99 {
249 | | 0 => println!("hi"), 248 | | 0 => println!("hi"),
250 | | 1 => println!("bla"), 249 | | 1 => println!("bla"),
... | ... |
253 | | } 252 | | }
254 | | } 253 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 3 error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity.rs:257:1 --> $DIR/cyclomatic_complexity.rs:256:1
| |
257 | / fn barrrr2() { 256 | / fn barrrr2() {
258 | | match 99 { 257 | | match 99 {
259 | | 0 => println!("hi"), 258 | | 0 => println!("hi"),
260 | | 1 => println!("bla"), 259 | | 1 => println!("bla"),
... | ... |
269 | | } 268 | | }
270 | | } 269 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:273:1 --> $DIR/cyclomatic_complexity.rs:272:1
| |
273 | / fn cake() { 272 | / fn cake() {
274 | | if 4 == 5 { 273 | | if 4 == 5 {
275 | | println!("yea"); 274 | | println!("yea");
276 | | } else { 275 | | } else {
... | ... |
279 | | println!("whee"); 278 | | println!("whee");
280 | | } 279 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 4 error: the function has a cyclomatic complexity of 4
--> $DIR/cyclomatic_complexity.rs:284:1 --> $DIR/cyclomatic_complexity.rs:283:1
| |
284 | / pub fn read_file(input_path: &str) -> String { 283 | / pub fn read_file(input_path: &str) -> String {
285 | | use std::fs::File; 284 | | use std::fs::File;
286 | | use std::io::{Read, Write}; 285 | | use std::io::{Read, Write};
287 | | use std::path::Path; 286 | | use std::path::Path;
... | ... |
309 | | } 308 | | }
310 | | } 309 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:315:1 --> $DIR/cyclomatic_complexity.rs:314:1
| |
315 | / fn void(void: Void) { 314 | / fn void(void: Void) {
316 | | if true { 315 | | if true {
317 | | match void { 316 | | match void {
318 | | } 317 | | }
319 | | } 318 | | }
320 | | } 319 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:329:1 --> $DIR/cyclomatic_complexity.rs:328:1
| |
329 | / fn try() -> Result<i32, &'static str> { 328 | / fn try() -> Result<i32, &'static str> {
330 | | match 5 { 329 | | match 5 {
331 | | 5 => Ok(5), 330 | | 5 => Ok(5),
332 | | _ => return Err("bla"), 331 | | _ => return Err("bla"),
333 | | } 332 | | }
334 | | } 333 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:337:1 --> $DIR/cyclomatic_complexity.rs:336:1
| |
337 | / fn try_again() -> Result<i32, &'static str> { 336 | / fn try_again() -> Result<i32, &'static str> {
338 | | let _ = try!(Ok(42)); 337 | | let _ = try!(Ok(42));
339 | | let _ = try!(Ok(43)); 338 | | let _ = try!(Ok(43));
340 | | let _ = try!(Ok(44)); 339 | | let _ = try!(Ok(44));
... | ... |
349 | | } 348 | | }
350 | | } 349 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:353:1 --> $DIR/cyclomatic_complexity.rs:352:1
| |
353 | / fn early() -> Result<i32, &'static str> { 352 | / fn early() -> Result<i32, &'static str> {
353 | | return Ok(5);
354 | | return Ok(5); 354 | | return Ok(5);
355 | | return Ok(5); 355 | | return Ok(5);
356 | | return Ok(5);
... | ... |
362 | | return Ok(5); 361 | | return Ok(5);
363 | | } 362 | | }
| |_^ | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions

View file

@ -7,13 +7,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
//! This file tests for the DOC_MARKDOWN lint //! This file tests for the DOC_MARKDOWN lint
#![allow(dead_code)] #![allow(dead_code)]
#![warn(clippy::doc_markdown)] #![warn(clippy::doc_markdown)]

View file

@ -1,183 +1,183 @@
error: you should put `DOC_MARKDOWN` between ticks in the documentation error: you should put `DOC_MARKDOWN` between ticks in the documentation
--> $DIR/doc.rs:13:29 --> $DIR/doc.rs:10:29
| |
13 | //! This file tests for the DOC_MARKDOWN lint 10 | //! This file tests for the DOC_MARKDOWN lint
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
| |
= note: `-D clippy::doc-markdown` implied by `-D warnings` = note: `-D clippy::doc-markdown` implied by `-D warnings`
error: you should put `foo_bar` between ticks in the documentation error: you should put `foo_bar` between ticks in the documentation
--> $DIR/doc.rs:20:9 --> $DIR/doc.rs:15:9
| |
20 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) 15 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
| ^^^^^^^ | ^^^^^^^
error: you should put `foo::bar` between ticks in the documentation error: you should put `foo::bar` between ticks in the documentation
--> $DIR/doc.rs:20:51 --> $DIR/doc.rs:15:51
| |
20 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) 15 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
| ^^^^^^^^ | ^^^^^^^^
error: you should put `Foo::some_fun` between ticks in the documentation error: you should put `Foo::some_fun` between ticks in the documentation
--> $DIR/doc.rs:21:84 --> $DIR/doc.rs:16:84
| |
21 | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun 16 | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: you should put `a::global:path` between ticks in the documentation error: you should put `a::global:path` between ticks in the documentation
--> $DIR/doc.rs:23:15 --> $DIR/doc.rs:18:15
| |
23 | /// Here be ::a::global:path. 18 | /// Here be ::a::global:path.
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
error: you should put `NotInCodeBlock` between ticks in the documentation error: you should put `NotInCodeBlock` between ticks in the documentation
--> $DIR/doc.rs:24:22 --> $DIR/doc.rs:19:22
| |
24 | /// That's not code ~NotInCodeBlock~. 19 | /// That's not code ~NotInCodeBlock~.
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:25:5 --> $DIR/doc.rs:20:5
| |
25 | /// be_sure_we_got_to_the_end_of_it 20 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:39:5 --> $DIR/doc.rs:34:5
| |
39 | /// be_sure_we_got_to_the_end_of_it 34 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:46:5 --> $DIR/doc.rs:41:5
| |
46 | /// be_sure_we_got_to_the_end_of_it 41 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:60:5 --> $DIR/doc.rs:55:5
| |
60 | /// be_sure_we_got_to_the_end_of_it 55 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `link_with_underscores` between ticks in the documentation error: you should put `link_with_underscores` between ticks in the documentation
--> $DIR/doc.rs:64:22 --> $DIR/doc.rs:59:22
| |
64 | /// This test has [a link_with_underscores][chunked-example] inside it. See #823. 59 | /// This test has [a link_with_underscores][chunked-example] inside it. See #823.
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
error: you should put `inline_link2` between ticks in the documentation error: you should put `inline_link2` between ticks in the documentation
--> $DIR/doc.rs:67:21 --> $DIR/doc.rs:62:21
| |
67 | /// It can also be [inline_link2]. 62 | /// It can also be [inline_link2].
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:77:5 --> $DIR/doc.rs:72:5
| |
77 | /// be_sure_we_got_to_the_end_of_it 72 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `CamelCaseThing` between ticks in the documentation error: you should put `CamelCaseThing` between ticks in the documentation
--> $DIR/doc.rs:85:8 --> $DIR/doc.rs:80:8
| |
85 | /// ## CamelCaseThing 80 | /// ## CamelCaseThing
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
error: you should put `CamelCaseThing` between ticks in the documentation error: you should put `CamelCaseThing` between ticks in the documentation
--> $DIR/doc.rs:88:7 --> $DIR/doc.rs:83:7
| |
88 | /// # CamelCaseThing 83 | /// # CamelCaseThing
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
error: you should put `CamelCaseThing` between ticks in the documentation error: you should put `CamelCaseThing` between ticks in the documentation
--> $DIR/doc.rs:90:22 --> $DIR/doc.rs:85:22
| |
90 | /// Not a title #897 CamelCaseThing 85 | /// Not a title #897 CamelCaseThing
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:91:5 --> $DIR/doc.rs:86:5
| |
91 | /// be_sure_we_got_to_the_end_of_it 86 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:98:5 --> $DIR/doc.rs:93:5
| |
98 | /// be_sure_we_got_to_the_end_of_it 93 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:111:5 --> $DIR/doc.rs:106:5
| |
111 | /// be_sure_we_got_to_the_end_of_it 106 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `FooBar` between ticks in the documentation error: you should put `FooBar` between ticks in the documentation
--> $DIR/doc.rs:122:42 --> $DIR/doc.rs:117:42
| |
122 | /** E.g. serialization of an empty list: FooBar 117 | /** E.g. serialization of an empty list: FooBar
| ^^^^^^ | ^^^^^^
error: you should put `BarQuz` between ticks in the documentation error: you should put `BarQuz` between ticks in the documentation
--> $DIR/doc.rs:127:5 --> $DIR/doc.rs:122:5
| |
127 | And BarQuz too. 122 | And BarQuz too.
| ^^^^^^ | ^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:128:1 --> $DIR/doc.rs:123:1
| |
128 | be_sure_we_got_to_the_end_of_it 123 | be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `FooBar` between ticks in the documentation error: you should put `FooBar` between ticks in the documentation
--> $DIR/doc.rs:133:42 --> $DIR/doc.rs:128:42
| |
133 | /** E.g. serialization of an empty list: FooBar 128 | /** E.g. serialization of an empty list: FooBar
| ^^^^^^ | ^^^^^^
error: you should put `BarQuz` between ticks in the documentation error: you should put `BarQuz` between ticks in the documentation
--> $DIR/doc.rs:138:5 --> $DIR/doc.rs:133:5
| |
138 | And BarQuz too. 133 | And BarQuz too.
| ^^^^^^ | ^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:139:1 --> $DIR/doc.rs:134:1
| |
139 | be_sure_we_got_to_the_end_of_it 134 | be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:150:5 --> $DIR/doc.rs:145:5
| |
150 | /// be_sure_we_got_to_the_end_of_it 145 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put bare URLs between `<`/`>` or make a proper Markdown link error: you should put bare URLs between `<`/`>` or make a proper Markdown link
--> $DIR/doc.rs:177:13 --> $DIR/doc.rs:172:13
| |
177 | /// Not ok: http://www.unicode.org 172 | /// Not ok: http://www.unicode.org
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error: you should put bare URLs between `<`/`>` or make a proper Markdown link error: you should put bare URLs between `<`/`>` or make a proper Markdown link
--> $DIR/doc.rs:178:13 --> $DIR/doc.rs:173:13
| |
178 | /// Not ok: https://www.unicode.org 173 | /// Not ok: https://www.unicode.org
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
error: you should put bare URLs between `<`/`>` or make a proper Markdown link error: you should put bare URLs between `<`/`>` or make a proper Markdown link
--> $DIR/doc.rs:179:13 --> $DIR/doc.rs:174:13
| |
179 | /// Not ok: http://www.unicode.org/ 174 | /// Not ok: http://www.unicode.org/
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error: you should put bare URLs between `<`/`>` or make a proper Markdown link error: you should put bare URLs between `<`/`>` or make a proper Markdown link
--> $DIR/doc.rs:180:13 --> $DIR/doc.rs:175:13
| |
180 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels 175 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 30 previous errors error: aborting due to 30 previous errors

View file

@ -7,13 +7,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![warn(clippy::double_parens)] #![warn(clippy::double_parens)]
#![allow(dead_code)] #![allow(dead_code)]
fn dummy_fn<T>(_: T) {} fn dummy_fn<T>(_: T) {}
struct DummyStruct; struct DummyStruct;

View file

@ -1,39 +1,39 @@
error: Consider removing unnecessary double parentheses error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:26:5 --> $DIR/double_parens.rs:21:5
| |
26 | ((0)) 21 | ((0))
| ^^^^^ | ^^^^^
| |
= note: `-D clippy::double-parens` implied by `-D warnings` = note: `-D clippy::double-parens` implied by `-D warnings`
error: Consider removing unnecessary double parentheses error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:30:14 --> $DIR/double_parens.rs:25:14
| |
30 | dummy_fn((0)); 25 | dummy_fn((0));
| ^^^ | ^^^
error: Consider removing unnecessary double parentheses error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:34:20 --> $DIR/double_parens.rs:29:20
| |
34 | x.dummy_method((0)); 29 | x.dummy_method((0));
| ^^^ | ^^^
error: Consider removing unnecessary double parentheses error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:38:5 --> $DIR/double_parens.rs:33:5
| |
38 | ((1, 2)) 33 | ((1, 2))
| ^^^^^^^^ | ^^^^^^^^
error: Consider removing unnecessary double parentheses error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:42:5 --> $DIR/double_parens.rs:37:5
| |
42 | (()) 37 | (())
| ^^^^ | ^^^^
error: Consider removing unnecessary double parentheses error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:64:16 --> $DIR/double_parens.rs:59:16
| |
64 | assert_eq!(((1, 2)), (1, 2), "Error"); 59 | assert_eq!(((1, 2)), (1, 2), "Error");
| ^^^^^^^^ | ^^^^^^^^
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View file

@ -7,8 +7,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![warn(clippy::empty_line_after_outer_attr)] #![warn(clippy::empty_line_after_outer_attr)]
// This should produce a warning // This should produce a warning

View file

@ -1,53 +1,53 @@
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:15:1 --> $DIR/empty_line_after_outer_attribute.rs:13:1
| |
15 | / #[crate_type = "lib"] 13 | / #[crate_type = "lib"]
16 | | 14 | |
17 | | /// some comment 15 | | /// some comment
18 | | fn with_one_newline_and_comment() { assert!(true) } 16 | | fn with_one_newline_and_comment() { assert!(true) }
| |_ | |_
| |
= note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings` = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings`
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:27:1 --> $DIR/empty_line_after_outer_attribute.rs:25:1
| |
27 | / #[crate_type = "lib"] 25 | / #[crate_type = "lib"]
28 | | 26 | |
29 | | fn with_one_newline() { assert!(true) } 27 | | fn with_one_newline() { assert!(true) }
| |_ | |_
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:32:1 --> $DIR/empty_line_after_outer_attribute.rs:30:1
| |
32 | / #[crate_type = "lib"] 30 | / #[crate_type = "lib"]
33 | | 31 | |
34 | | 32 | |
35 | | fn with_two_newlines() { assert!(true) } 33 | | fn with_two_newlines() { assert!(true) }
| |_ | |_
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:39:1 --> $DIR/empty_line_after_outer_attribute.rs:37:1
| |
39 | / #[crate_type = "lib"] 37 | / #[crate_type = "lib"]
40 | | 38 | |
41 | | enum Baz { 39 | | enum Baz {
| |_ | |_
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:47:1 --> $DIR/empty_line_after_outer_attribute.rs:45:1
| |
47 | / #[crate_type = "lib"] 45 | / #[crate_type = "lib"]
48 | | 46 | |
49 | | struct Foo { 47 | | struct Foo {
| |_ | |_
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:55:1 --> $DIR/empty_line_after_outer_attribute.rs:53:1
| |
55 | / #[crate_type = "lib"] 53 | / #[crate_type = "lib"]
56 | | 54 | |
57 | | mod foo { 55 | | mod foo {
| |_ | |_
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View file

@ -7,10 +7,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[rustfmt::skip]
#[warn(clippy::eq_op)] #[warn(clippy::eq_op)]
#[allow(clippy::identity_op, clippy::double_parens, clippy::many_single_char_names)] #[allow(clippy::identity_op, clippy::double_parens, clippy::many_single_char_names)]
#[allow(clippy::no_effect, unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)] #[allow(clippy::no_effect, unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)]
@ -107,6 +104,7 @@ fn main() {
const D: u32 = A / A; const D: u32 = A / A;
} }
#[rustfmt::skip]
macro_rules! check_if_named_foo { macro_rules! check_if_named_foo {
($expression:expr) => ( ($expression:expr) => (
if stringify!($expression) == "foo" { if stringify!($expression) == "foo" {

View file

@ -1,203 +1,203 @@
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/eq_op.rs:47:5 --> $DIR/eq_op.rs:44:5
| |
47 | true && true; 44 | true && true;
| ^^^^^^^^^^^^ help: try: `true` | ^^^^^^^^^^^^ help: try: `true`
| |
= note: `-D clippy::nonminimal-bool` implied by `-D warnings` = note: `-D clippy::nonminimal-bool` implied by `-D warnings`
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/eq_op.rs:49:5 --> $DIR/eq_op.rs:46:5
| |
49 | true || true; 46 | true || true;
| ^^^^^^^^^^^^ help: try: `true` | ^^^^^^^^^^^^ help: try: `true`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:52:5
|
52 | a == b && b == a;
| ^^^^^^^^^^^^^^^^ help: try: `a == b`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:53:5
|
53 | a != b && b != a;
| ^^^^^^^^^^^^^^^^ help: try: `a != b`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:54:5
|
54 | a < b && b > a;
| ^^^^^^^^^^^^^^ help: try: `a < b`
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/eq_op.rs:55:5 --> $DIR/eq_op.rs:55:5
| |
55 | a == b && b == a; 55 | a <= b && b >= a;
| ^^^^^^^^^^^^^^^^ help: try: `a == b`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:56:5
|
56 | a != b && b != a;
| ^^^^^^^^^^^^^^^^ help: try: `a != b`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:57:5
|
57 | a < b && b > a;
| ^^^^^^^^^^^^^^ help: try: `a < b`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:58:5
|
58 | a <= b && b >= a;
| ^^^^^^^^^^^^^^^^ help: try: `a <= b` | ^^^^^^^^^^^^^^^^ help: try: `a <= b`
error: equal expressions as operands to `==` error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:20:5 --> $DIR/eq_op.rs:17:5
| |
20 | 1 == 1; 17 | 1 == 1;
| ^^^^^^ | ^^^^^^
| |
= note: `-D clippy::eq-op` implied by `-D warnings` = note: `-D clippy::eq-op` implied by `-D warnings`
error: equal expressions as operands to `==` error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:21:5 --> $DIR/eq_op.rs:18:5
| |
21 | "no" == "no"; 18 | "no" == "no";
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: equal expressions as operands to `!=` error: equal expressions as operands to `!=`
--> $DIR/eq_op.rs:23:5 --> $DIR/eq_op.rs:20:5
| |
23 | false != false; 20 | false != false;
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
error: equal expressions as operands to `<` error: equal expressions as operands to `<`
--> $DIR/eq_op.rs:24:5 --> $DIR/eq_op.rs:21:5
| |
24 | 1.5 < 1.5; 21 | 1.5 < 1.5;
| ^^^^^^^^^ | ^^^^^^^^^
error: equal expressions as operands to `>=` error: equal expressions as operands to `>=`
--> $DIR/eq_op.rs:25:5 --> $DIR/eq_op.rs:22:5
| |
25 | 1u64 >= 1u64; 22 | 1u64 >= 1u64;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: equal expressions as operands to `&` error: equal expressions as operands to `&`
--> $DIR/eq_op.rs:28:5 --> $DIR/eq_op.rs:25:5
| |
28 | (1 as u64) & (1 as u64); 25 | (1 as u64) & (1 as u64);
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `^` error: equal expressions as operands to `^`
--> $DIR/eq_op.rs:29:5 --> $DIR/eq_op.rs:26:5
| |
29 | 1 ^ ((((((1)))))); 26 | 1 ^ ((((((1))))));
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `<` error: equal expressions as operands to `<`
--> $DIR/eq_op.rs:32:5 --> $DIR/eq_op.rs:29:5
| |
32 | (-(2) < -(2)); 29 | (-(2) < -(2));
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: equal expressions as operands to `==` error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:33:5 --> $DIR/eq_op.rs:30:5
| |
33 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); 30 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `&` error: equal expressions as operands to `&`
--> $DIR/eq_op.rs:33:6 --> $DIR/eq_op.rs:30:6
| |
33 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); 30 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `&` error: equal expressions as operands to `&`
--> $DIR/eq_op.rs:33:27 --> $DIR/eq_op.rs:30:27
| |
33 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); 30 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `==` error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:34:5 --> $DIR/eq_op.rs:31:5
| |
34 | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; 31 | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `!=` error: equal expressions as operands to `!=`
--> $DIR/eq_op.rs:37:5 --> $DIR/eq_op.rs:34:5
| |
37 | ([1] != [1]); 34 | ([1] != [1]);
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: equal expressions as operands to `!=` error: equal expressions as operands to `!=`
--> $DIR/eq_op.rs:38:5 --> $DIR/eq_op.rs:35:5
| |
38 | ((1, 2) != (1, 2)); 35 | ((1, 2) != (1, 2));
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `==` error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:42:5 --> $DIR/eq_op.rs:39:5
| |
42 | 1 + 1 == 2; 39 | 1 + 1 == 2;
| ^^^^^^^^^^ | ^^^^^^^^^^
error: equal expressions as operands to `==` error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:43:5 --> $DIR/eq_op.rs:40:5
| |
43 | 1 - 1 == 0; 40 | 1 - 1 == 0;
| ^^^^^^^^^^ | ^^^^^^^^^^
error: equal expressions as operands to `-` error: equal expressions as operands to `-`
--> $DIR/eq_op.rs:43:5 --> $DIR/eq_op.rs:40:5
| |
43 | 1 - 1 == 0; 40 | 1 - 1 == 0;
| ^^^^^ | ^^^^^
error: equal expressions as operands to `-` error: equal expressions as operands to `-`
--> $DIR/eq_op.rs:45:5 --> $DIR/eq_op.rs:42:5
| |
45 | 1 - 1; 42 | 1 - 1;
| ^^^^^ | ^^^^^
error: equal expressions as operands to `/` error: equal expressions as operands to `/`
--> $DIR/eq_op.rs:46:5 --> $DIR/eq_op.rs:43:5
| |
46 | 1 / 1; 43 | 1 / 1;
| ^^^^^ | ^^^^^
error: equal expressions as operands to `&&` error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:47:5 --> $DIR/eq_op.rs:44:5
| |
47 | true && true; 44 | true && true;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: equal expressions as operands to `||` error: equal expressions as operands to `||`
--> $DIR/eq_op.rs:49:5 --> $DIR/eq_op.rs:46:5
| |
49 | true || true; 46 | true || true;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:52:5
|
52 | a == b && b == a;
| ^^^^^^^^^^^^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:53:5
|
53 | a != b && b != a;
| ^^^^^^^^^^^^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:54:5
|
54 | a < b && b > a;
| ^^^^^^^^^^^^^^
error: equal expressions as operands to `&&` error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:55:5 --> $DIR/eq_op.rs:55:5
| |
55 | a == b && b == a; 55 | a <= b && b >= a;
| ^^^^^^^^^^^^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:56:5
|
56 | a != b && b != a;
| ^^^^^^^^^^^^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:57:5
|
57 | a < b && b > a;
| ^^^^^^^^^^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:58:5
|
58 | a <= b && b >= a;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: equal expressions as operands to `==` error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:61:5 --> $DIR/eq_op.rs:58:5
| |
61 | a == a; 58 | a == a;
| ^^^^^^ | ^^^^^^
error: taken reference of right operand error: taken reference of right operand
--> $DIR/eq_op.rs:99:13 --> $DIR/eq_op.rs:96:13
| |
99 | let z = x & &y; 96 | let z = x & &y;
| ^^^^-- | ^^^^--
| | | |
| help: use the right value directly: `y` | help: use the right value directly: `y`
@ -205,9 +205,9 @@ error: taken reference of right operand
= note: `-D clippy::op-ref` implied by `-D warnings` = note: `-D clippy::op-ref` implied by `-D warnings`
error: equal expressions as operands to `/` error: equal expressions as operands to `/`
--> $DIR/eq_op.rs:107:20 --> $DIR/eq_op.rs:104:20
| |
107 | const D: u32 = A / A; 104 | const D: u32 = A / A;
| ^^^^^ | ^^^^^
error: aborting due to 34 previous errors error: aborting due to 34 previous errors

View file

@ -8,7 +8,6 @@
// except according to those terms. // except according to those terms.
#![allow(clippy::print_literal)] #![allow(clippy::print_literal)]
#![warn(clippy::useless_format)] #![warn(clippy::useless_format)]

View file

@ -1,71 +1,71 @@
error: useless use of `format!` error: useless use of `format!`
--> $DIR/format.rs:22:5 --> $DIR/format.rs:21:5
| |
22 | format!("foo"); 21 | format!("foo");
| ^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()` | ^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()`
| |
= note: `-D clippy::useless-format` implied by `-D warnings` = note: `-D clippy::useless-format` implied by `-D warnings`
error: useless use of `format!` error: useless use of `format!`
--> $DIR/format.rs:24:5 --> $DIR/format.rs:23:5
| |
24 | format!("{}", "foo"); 23 | format!("{}", "foo");
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()` | ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()`
| |
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: useless use of `format!`
--> $DIR/format.rs:27:5
|
27 | format!("{:+}", "foo"); // warn when the format makes no difference
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: useless use of `format!` error: useless use of `format!`
--> $DIR/format.rs:28:5 --> $DIR/format.rs:28:5
| |
28 | format!("{:+}", "foo"); // warn when the format makes no difference 28 | format!("{:<}", "foo"); // warn when the format makes no difference
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()` | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()`
| |
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: useless use of `format!` error: useless use of `format!`
--> $DIR/format.rs:29:5 --> $DIR/format.rs:33:5
| |
29 | format!("{:<}", "foo"); // warn when the format makes no difference 33 | format!("{}", arg);
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: useless use of `format!`
--> $DIR/format.rs:34:5
|
34 | format!("{}", arg);
| ^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()` | ^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()`
| |
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: useless use of `format!`
--> $DIR/format.rs:37:5
|
37 | format!("{:+}", arg); // warn when the format makes no difference
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: useless use of `format!` error: useless use of `format!`
--> $DIR/format.rs:38:5 --> $DIR/format.rs:38:5
| |
38 | format!("{:+}", arg); // warn when the format makes no difference 38 | format!("{:<}", arg); // warn when the format makes no difference
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()` | ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()`
| |
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: useless use of `format!` error: useless use of `format!`
--> $DIR/format.rs:39:5 --> $DIR/format.rs:65:5
| |
39 | format!("{:<}", arg); // warn when the format makes no difference 65 | format!("{}", 42.to_string());
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: useless use of `format!`
--> $DIR/format.rs:66:5
|
66 | format!("{}", 42.to_string());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `to_string()` is enough: `42.to_string()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `to_string()` is enough: `42.to_string()`
| |
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: useless use of `format!` error: useless use of `format!`
--> $DIR/format.rs:68:5 --> $DIR/format.rs:67:5
| |
68 | format!("{}", x.display().to_string()); 67 | format!("{}", x.display().to_string());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `to_string()` is enough: `x.display().to_string()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `to_string()` is enough: `x.display().to_string()`
| |
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

View file

@ -7,14 +7,21 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![warn(clippy::all, clippy::pedantic, clippy::option_unwrap_used)] #![warn(clippy::all, clippy::pedantic, clippy::option_unwrap_used)]
#![allow(clippy::blacklisted_name, unused, clippy::print_stdout, clippy::non_ascii_literal, clippy::new_without_default, #![allow(
clippy::new_without_default_derive, clippy::missing_docs_in_private_items, clippy::needless_pass_by_value, clippy::blacklisted_name,
clippy::default_trait_access, clippy::use_self, clippy::new_ret_no_self, clippy::useless_format)] unused,
clippy::print_stdout,
clippy::non_ascii_literal,
clippy::new_without_default,
clippy::new_without_default_derive,
clippy::missing_docs_in_private_items,
clippy::needless_pass_by_value,
clippy::default_trait_access,
clippy::use_self,
clippy::new_ret_no_self,
clippy::useless_format
)]
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::collections::HashMap; use std::collections::HashMap;

View file

@ -1,402 +1,402 @@
error: defining a method called `add` on this type; consider implementing the `std::ops::Add` trait or choosing a less ambiguous name error: defining a method called `add` on this type; consider implementing the `std::ops::Add` trait or choosing a less ambiguous name
--> $DIR/methods.rs:31:5 --> $DIR/methods.rs:38:5
| |
31 | pub fn add(self, other: T) -> T { self } 38 | pub fn add(self, other: T) -> T { self }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: `-D clippy::should-implement-trait` implied by `-D warnings` = note: `-D clippy::should-implement-trait` implied by `-D warnings`
error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
--> $DIR/methods.rs:42:17 --> $DIR/methods.rs:49:17
| |
42 | fn into_u16(&self) -> u16 { 0 } 49 | fn into_u16(&self) -> u16 { 0 }
| ^^^^^ | ^^^^^
| |
= note: `-D clippy::wrong-self-convention` implied by `-D warnings` = note: `-D clippy::wrong-self-convention` implied by `-D warnings`
error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
--> $DIR/methods.rs:44:21 --> $DIR/methods.rs:51:21
| |
44 | fn to_something(self) -> u32 { 0 } 51 | fn to_something(self) -> u32 { 0 }
| ^^^^ | ^^^^
error: methods called `new` usually take no self; consider choosing a less ambiguous name error: methods called `new` usually take no self; consider choosing a less ambiguous name
--> $DIR/methods.rs:46:12 --> $DIR/methods.rs:53:12
| |
46 | fn new(self) -> Self { unimplemented!(); } 53 | fn new(self) -> Self { unimplemented!(); }
| ^^^^ | ^^^^
error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
--> $DIR/methods.rs:114:13 --> $DIR/methods.rs:121:13
| |
114 | let _ = opt.map(|x| x + 1) 121 | let _ = opt.map(|x| x + 1)
| _____________^ | _____________^
115 | | 122 | |
116 | | .unwrap_or(0); // should lint even though this call is on a separate line 123 | | .unwrap_or(0); // should lint even though this call is on a separate line
| |____________________________^ | |____________________________^
| |
= note: `-D clippy::option-map-unwrap-or` implied by `-D warnings` = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings`
= note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)` = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)`
error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
--> $DIR/methods.rs:118:13 --> $DIR/methods.rs:125:13
| |
118 | let _ = opt.map(|x| { 125 | let _ = opt.map(|x| {
| _____________^ | _____________^
119 | | x + 1 126 | | x + 1
120 | | } 127 | | }
121 | | ).unwrap_or(0); 128 | | ).unwrap_or(0);
| |____________________________^ | |____________________________^
error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
--> $DIR/methods.rs:122:13 --> $DIR/methods.rs:129:13
| |
122 | let _ = opt.map(|x| x + 1) 129 | let _ = opt.map(|x| x + 1)
| _____________^ | _____________^
123 | | .unwrap_or({ 130 | | .unwrap_or({
124 | | 0 131 | | 0
125 | | }); 132 | | });
| |__________________^ | |__________________^
error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
--> $DIR/methods.rs:127:13 --> $DIR/methods.rs:134:13
| |
127 | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None); 134 | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))` = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
--> $DIR/methods.rs:129:13 --> $DIR/methods.rs:136:13
| |
129 | let _ = opt.map(|x| { 136 | let _ = opt.map(|x| {
| _____________^ | _____________^
130 | | Some(x + 1) 137 | | Some(x + 1)
131 | | } 138 | | }
132 | | ).unwrap_or(None); 139 | | ).unwrap_or(None);
| |_____________________^ | |_____________________^
error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
--> $DIR/methods.rs:133:13 --> $DIR/methods.rs:140:13
| |
133 | let _ = opt 140 | let _ = opt
| _____________^ | _____________^
134 | | .map(|x| Some(x + 1)) 141 | | .map(|x| Some(x + 1))
135 | | .unwrap_or(None); 142 | | .unwrap_or(None);
| |________________________^ | |________________________^
| |
= note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))` = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
--> $DIR/methods.rs:141:13 --> $DIR/methods.rs:148:13
| |
141 | let _ = opt.map(|x| x + 1) 148 | let _ = opt.map(|x| x + 1)
| _____________^ | _____________^
142 | | 149 | |
143 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line 150 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line
| |____________________________________^ | |____________________________________^
| |
= note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings` = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings`
= note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)` = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
--> $DIR/methods.rs:145:13 --> $DIR/methods.rs:152:13
| |
145 | let _ = opt.map(|x| { 152 | let _ = opt.map(|x| {
| _____________^ | _____________^
146 | | x + 1 153 | | x + 1
147 | | } 154 | | }
148 | | ).unwrap_or_else(|| 0); 155 | | ).unwrap_or_else(|| 0);
| |____________________________________^ | |____________________________________^
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
--> $DIR/methods.rs:149:13 --> $DIR/methods.rs:156:13
| |
149 | let _ = opt.map(|x| x + 1) 156 | let _ = opt.map(|x| x + 1)
| _____________^ | _____________^
150 | | .unwrap_or_else(|| 157 | | .unwrap_or_else(||
151 | | 0 158 | | 0
152 | | ); 159 | | );
| |_________________^ | |_________________^
error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
--> $DIR/methods.rs:158:13 --> $DIR/methods.rs:165:13
| |
158 | let _ = opt.map_or(None, |x| Some(x + 1)); 165 | let _ = opt.map_or(None, |x| Some(x + 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))`
| |
= note: `-D clippy::option-map-or-none` implied by `-D warnings` = note: `-D clippy::option-map-or-none` implied by `-D warnings`
error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
--> $DIR/methods.rs:160:13 --> $DIR/methods.rs:167:13
| |
160 | let _ = opt.map_or(None, |x| { 167 | let _ = opt.map_or(None, |x| {
| _____________^ | _____________^
161 | | Some(x + 1) 168 | | Some(x + 1)
162 | | } 169 | | }
163 | | ); 170 | | );
| |_________________^ | |_________________^
help: try using and_then instead help: try using and_then instead
| |
160 | let _ = opt.and_then(|x| { 167 | let _ = opt.and_then(|x| {
161 | Some(x + 1) 168 | Some(x + 1)
162 | }); 169 | });
| |
error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead
--> $DIR/methods.rs:173:13 --> $DIR/methods.rs:180:13
| |
173 | let _ = res.map(|x| x + 1) 180 | let _ = res.map(|x| x + 1)
| _____________^ | _____________^
174 | | 181 | |
175 | | .unwrap_or_else(|e| 0); // should lint even though this call is on a separate line 182 | | .unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
| |_____________________________________^ | |_____________________________________^
| |
= note: `-D clippy::result-map-unwrap-or-else` implied by `-D warnings` = note: `-D clippy::result-map-unwrap-or-else` implied by `-D warnings`
= note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `ok().map_or_else(|e| 0, |x| x + 1)` = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `ok().map_or_else(|e| 0, |x| x + 1)`
error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead
--> $DIR/methods.rs:177:13 --> $DIR/methods.rs:184:13
| |
177 | let _ = res.map(|x| { 184 | let _ = res.map(|x| {
| _____________^ | _____________^
178 | | x + 1 185 | | x + 1
179 | | } 186 | | }
180 | | ).unwrap_or_else(|e| 0); 187 | | ).unwrap_or_else(|e| 0);
| |_____________________________________^ | |_____________________________________^
error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead
--> $DIR/methods.rs:181:13 --> $DIR/methods.rs:188:13
| |
181 | let _ = res.map(|x| x + 1) 188 | let _ = res.map(|x| x + 1)
| _____________^ | _____________^
182 | | .unwrap_or_else(|e| 189 | | .unwrap_or_else(|e|
183 | | 0 190 | | 0
184 | | ); 191 | | );
| |_________________^ | |_________________^
error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead. error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
--> $DIR/methods.rs:244:13 --> $DIR/methods.rs:251:13
| |
244 | let _ = v.iter().filter(|&x| *x < 0).next(); 251 | let _ = v.iter().filter(|&x| *x < 0).next();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: `-D clippy::filter-next` implied by `-D warnings` = note: `-D clippy::filter-next` implied by `-D warnings`
= note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)` = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead. error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
--> $DIR/methods.rs:247:13 --> $DIR/methods.rs:254:13
| |
247 | let _ = v.iter().filter(|&x| { 254 | let _ = v.iter().filter(|&x| {
| _____________^ | _____________^
248 | | *x < 0 255 | | *x < 0
249 | | } 256 | | }
250 | | ).next(); 257 | | ).next();
| |___________________________^ | |___________________________^
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`. error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
--> $DIR/methods.rs:262:13 --> $DIR/methods.rs:269:13
| |
262 | let _ = v.iter().find(|&x| *x < 0).is_some(); 269 | let _ = v.iter().find(|&x| *x < 0).is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: `-D clippy::search-is-some` implied by `-D warnings` = note: `-D clippy::search-is-some` implied by `-D warnings`
= note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)` = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)`
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`. error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
--> $DIR/methods.rs:265:13 --> $DIR/methods.rs:272:13
| |
265 | let _ = v.iter().find(|&x| { 272 | let _ = v.iter().find(|&x| {
| _____________^ | _____________^
266 | | *x < 0 273 | | *x < 0
267 | | } 274 | | }
268 | | ).is_some(); 275 | | ).is_some();
| |______________________________^ | |______________________________^
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`. error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
--> $DIR/methods.rs:271:13 --> $DIR/methods.rs:278:13
| |
271 | let _ = v.iter().position(|&x| x < 0).is_some(); 278 | let _ = v.iter().position(|&x| x < 0).is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)` = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`. error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
--> $DIR/methods.rs:274:13 --> $DIR/methods.rs:281:13
| |
274 | let _ = v.iter().position(|&x| { 281 | let _ = v.iter().position(|&x| {
| _____________^ | _____________^
275 | | x < 0 282 | | x < 0
276 | | } 283 | | }
277 | | ).is_some(); 284 | | ).is_some();
| |______________________________^ | |______________________________^
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`. error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
--> $DIR/methods.rs:280:13 --> $DIR/methods.rs:287:13
| |
280 | let _ = v.iter().rposition(|&x| x < 0).is_some(); 287 | let _ = v.iter().rposition(|&x| x < 0).is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)` = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`. error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
--> $DIR/methods.rs:283:13 --> $DIR/methods.rs:290:13
| |
283 | let _ = v.iter().rposition(|&x| { 290 | let _ = v.iter().rposition(|&x| {
| _____________^ | _____________^
284 | | x < 0 291 | | x < 0
285 | | } 292 | | }
286 | | ).is_some(); 293 | | ).is_some();
| |______________________________^ | |______________________________^
error: use of `unwrap_or` followed by a function call error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:318:22 --> $DIR/methods.rs:325:22
| |
318 | with_constructor.unwrap_or(make()); 325 | with_constructor.unwrap_or(make());
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)` | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
| |
= note: `-D clippy::or-fun-call` implied by `-D warnings` = note: `-D clippy::or-fun-call` implied by `-D warnings`
error: use of `unwrap_or` followed by a call to `new` error: use of `unwrap_or` followed by a call to `new`
--> $DIR/methods.rs:321:5 --> $DIR/methods.rs:328:5
| |
321 | with_new.unwrap_or(Vec::new()); 328 | with_new.unwrap_or(Vec::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
error: use of `unwrap_or` followed by a function call error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:324:21 --> $DIR/methods.rs:331:21
| |
324 | with_const_args.unwrap_or(Vec::with_capacity(12)); 331 | with_const_args.unwrap_or(Vec::with_capacity(12));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
error: use of `unwrap_or` followed by a function call error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:327:14 --> $DIR/methods.rs:334:14
| |
327 | with_err.unwrap_or(make()); 334 | with_err.unwrap_or(make());
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())` | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
error: use of `unwrap_or` followed by a function call error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:330:19 --> $DIR/methods.rs:337:19
| |
330 | with_err_args.unwrap_or(Vec::with_capacity(12)); 337 | with_err_args.unwrap_or(Vec::with_capacity(12));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
error: use of `unwrap_or` followed by a call to `default` error: use of `unwrap_or` followed by a call to `default`
--> $DIR/methods.rs:333:5 --> $DIR/methods.rs:340:5
| |
333 | with_default_trait.unwrap_or(Default::default()); 340 | with_default_trait.unwrap_or(Default::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
error: use of `unwrap_or` followed by a call to `default` error: use of `unwrap_or` followed by a call to `default`
--> $DIR/methods.rs:336:5 --> $DIR/methods.rs:343:5
| |
336 | with_default_type.unwrap_or(u64::default()); 343 | with_default_type.unwrap_or(u64::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
error: use of `unwrap_or` followed by a function call error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:339:14 --> $DIR/methods.rs:346:14
| |
339 | with_vec.unwrap_or(vec![]); 346 | with_vec.unwrap_or(vec![]);
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])` | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])`
error: use of `unwrap_or` followed by a function call error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:344:21 --> $DIR/methods.rs:351:21
| |
344 | without_default.unwrap_or(Foo::new()); 351 | without_default.unwrap_or(Foo::new());
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)` | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
error: use of `or_insert` followed by a function call error: use of `or_insert` followed by a function call
--> $DIR/methods.rs:347:19 --> $DIR/methods.rs:354:19
| |
347 | map.entry(42).or_insert(String::new()); 354 | map.entry(42).or_insert(String::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)` | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
error: use of `or_insert` followed by a function call error: use of `or_insert` followed by a function call
--> $DIR/methods.rs:350:21 --> $DIR/methods.rs:357:21
| |
350 | btree.entry(42).or_insert(String::new()); 357 | btree.entry(42).or_insert(String::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)` | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
error: use of `unwrap_or` followed by a function call error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:353:21 --> $DIR/methods.rs:360:21
| |
353 | let _ = stringy.unwrap_or("".to_owned()); 360 | let _ = stringy.unwrap_or("".to_owned());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())` | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
--> $DIR/methods.rs:364:23 --> $DIR/methods.rs:371:23
| |
364 | let bad_vec = some_vec.iter().nth(3); 371 | let bad_vec = some_vec.iter().nth(3);
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
| |
= note: `-D clippy::iter-nth` implied by `-D warnings` = note: `-D clippy::iter-nth` implied by `-D warnings`
error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
--> $DIR/methods.rs:365:26 --> $DIR/methods.rs:372:26
| |
365 | let bad_slice = &some_vec[..].iter().nth(3); 372 | let bad_slice = &some_vec[..].iter().nth(3);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
--> $DIR/methods.rs:366:31 --> $DIR/methods.rs:373:31
| |
366 | let bad_boxed_slice = boxed_slice.iter().nth(3); 373 | let bad_boxed_slice = boxed_slice.iter().nth(3);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
--> $DIR/methods.rs:367:29 --> $DIR/methods.rs:374:29
| |
367 | let bad_vec_deque = some_vec_deque.iter().nth(3); 374 | let bad_vec_deque = some_vec_deque.iter().nth(3);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
--> $DIR/methods.rs:372:23 --> $DIR/methods.rs:379:23
| |
372 | let bad_vec = some_vec.iter_mut().nth(3); 379 | let bad_vec = some_vec.iter_mut().nth(3);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
--> $DIR/methods.rs:375:26 --> $DIR/methods.rs:382:26
| |
375 | let bad_slice = &some_vec[..].iter_mut().nth(3); 382 | let bad_slice = &some_vec[..].iter_mut().nth(3);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
--> $DIR/methods.rs:378:29 --> $DIR/methods.rs:385:29
| |
378 | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); 385 | let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
--> $DIR/methods.rs:390:13 --> $DIR/methods.rs:397:13
| |
390 | let _ = some_vec.iter().skip(42).next(); 397 | let _ = some_vec.iter().skip(42).next();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: `-D clippy::iter-skip-next` implied by `-D warnings` = note: `-D clippy::iter-skip-next` implied by `-D warnings`
error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
--> $DIR/methods.rs:391:13 --> $DIR/methods.rs:398:13
| |
391 | let _ = some_vec.iter().cycle().skip(42).next(); 398 | let _ = some_vec.iter().cycle().skip(42).next();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
--> $DIR/methods.rs:392:13 --> $DIR/methods.rs:399:13
| |
392 | let _ = (1..10).skip(10).next(); 399 | let _ = (1..10).skip(10).next();
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
--> $DIR/methods.rs:393:14 --> $DIR/methods.rs:400:14
| |
393 | let _ = &some_vec[..].iter().skip(3).next(); 400 | let _ = &some_vec[..].iter().skip(3).next();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: used unwrap() on an Option value. If you don't want to handle the None case gracefully, consider using expect() to provide a better panic message error: used unwrap() on an Option value. If you don't want to handle the None case gracefully, consider using expect() to provide a better panic message
--> $DIR/methods.rs:402:13 --> $DIR/methods.rs:409:13
| |
402 | let _ = opt.unwrap(); 409 | let _ = opt.unwrap();
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
| |
= note: `-D clippy::option-unwrap-used` implied by `-D warnings` = note: `-D clippy::option-unwrap-used` implied by `-D warnings`

View file

@ -8,8 +8,6 @@
// except according to those terms. // except according to those terms.
#![feature(integer_atomics)] #![feature(integer_atomics)]
#![allow(clippy::blacklisted_name)] #![allow(clippy::blacklisted_name)]
#![deny(clippy::replace_consts)] #![deny(clippy::replace_consts)]
@ -17,6 +15,7 @@
use std::sync::atomic::*; use std::sync::atomic::*;
use std::sync::{ONCE_INIT, Once}; use std::sync::{ONCE_INIT, Once};
#[rustfmt::skip]
fn bad() { fn bad() {
// Once // Once
{ let foo = ONCE_INIT; }; { let foo = ONCE_INIT; };
@ -60,6 +59,7 @@ fn bad() {
{ let foo = std::u128::MAX; }; { let foo = std::u128::MAX; };
} }
#[rustfmt::skip]
fn good() { fn good() {
// Once // Once
{ let foo = Once::new(); }; { let foo = Once::new(); };

View file

@ -1,217 +1,217 @@
error: using `ATOMIC_BOOL_INIT` error: using `ATOMIC_BOOL_INIT`
--> $DIR/replace_consts.rs:24:17 --> $DIR/replace_consts.rs:23:17
| |
24 | { let foo = ATOMIC_BOOL_INIT; }; 23 | { let foo = ATOMIC_BOOL_INIT; };
| ^^^^^^^^^^^^^^^^ help: try this: `AtomicBool::new(false)` | ^^^^^^^^^^^^^^^^ help: try this: `AtomicBool::new(false)`
| |
note: lint level defined here note: lint level defined here
--> $DIR/replace_consts.rs:15:9 --> $DIR/replace_consts.rs:13:9
| |
15 | #![deny(clippy::replace_consts)] 13 | #![deny(clippy::replace_consts)]
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error: using `ATOMIC_ISIZE_INIT` error: using `ATOMIC_ISIZE_INIT`
--> $DIR/replace_consts.rs:25:17 --> $DIR/replace_consts.rs:24:17
| |
25 | { let foo = ATOMIC_ISIZE_INIT; }; 24 | { let foo = ATOMIC_ISIZE_INIT; };
| ^^^^^^^^^^^^^^^^^ help: try this: `AtomicIsize::new(0)` | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicIsize::new(0)`
error: using `ATOMIC_I8_INIT` error: using `ATOMIC_I8_INIT`
--> $DIR/replace_consts.rs:26:17 --> $DIR/replace_consts.rs:25:17
| |
26 | { let foo = ATOMIC_I8_INIT; }; 25 | { let foo = ATOMIC_I8_INIT; };
| ^^^^^^^^^^^^^^ help: try this: `AtomicI8::new(0)` | ^^^^^^^^^^^^^^ help: try this: `AtomicI8::new(0)`
error: using `ATOMIC_I16_INIT` error: using `ATOMIC_I16_INIT`
--> $DIR/replace_consts.rs:27:17 --> $DIR/replace_consts.rs:26:17
| |
27 | { let foo = ATOMIC_I16_INIT; }; 26 | { let foo = ATOMIC_I16_INIT; };
| ^^^^^^^^^^^^^^^ help: try this: `AtomicI16::new(0)` | ^^^^^^^^^^^^^^^ help: try this: `AtomicI16::new(0)`
error: using `ATOMIC_I32_INIT` error: using `ATOMIC_I32_INIT`
--> $DIR/replace_consts.rs:28:17 --> $DIR/replace_consts.rs:27:17
| |
28 | { let foo = ATOMIC_I32_INIT; }; 27 | { let foo = ATOMIC_I32_INIT; };
| ^^^^^^^^^^^^^^^ help: try this: `AtomicI32::new(0)` | ^^^^^^^^^^^^^^^ help: try this: `AtomicI32::new(0)`
error: using `ATOMIC_I64_INIT` error: using `ATOMIC_I64_INIT`
--> $DIR/replace_consts.rs:29:17 --> $DIR/replace_consts.rs:28:17
| |
29 | { let foo = ATOMIC_I64_INIT; }; 28 | { let foo = ATOMIC_I64_INIT; };
| ^^^^^^^^^^^^^^^ help: try this: `AtomicI64::new(0)` | ^^^^^^^^^^^^^^^ help: try this: `AtomicI64::new(0)`
error: using `ATOMIC_USIZE_INIT` error: using `ATOMIC_USIZE_INIT`
--> $DIR/replace_consts.rs:30:17 --> $DIR/replace_consts.rs:29:17
| |
30 | { let foo = ATOMIC_USIZE_INIT; }; 29 | { let foo = ATOMIC_USIZE_INIT; };
| ^^^^^^^^^^^^^^^^^ help: try this: `AtomicUsize::new(0)` | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicUsize::new(0)`
error: using `ATOMIC_U8_INIT` error: using `ATOMIC_U8_INIT`
--> $DIR/replace_consts.rs:31:17 --> $DIR/replace_consts.rs:30:17
| |
31 | { let foo = ATOMIC_U8_INIT; }; 30 | { let foo = ATOMIC_U8_INIT; };
| ^^^^^^^^^^^^^^ help: try this: `AtomicU8::new(0)` | ^^^^^^^^^^^^^^ help: try this: `AtomicU8::new(0)`
error: using `ATOMIC_U16_INIT` error: using `ATOMIC_U16_INIT`
--> $DIR/replace_consts.rs:32:17 --> $DIR/replace_consts.rs:31:17
| |
32 | { let foo = ATOMIC_U16_INIT; }; 31 | { let foo = ATOMIC_U16_INIT; };
| ^^^^^^^^^^^^^^^ help: try this: `AtomicU16::new(0)` | ^^^^^^^^^^^^^^^ help: try this: `AtomicU16::new(0)`
error: using `ATOMIC_U32_INIT` error: using `ATOMIC_U32_INIT`
--> $DIR/replace_consts.rs:33:17 --> $DIR/replace_consts.rs:32:17
| |
33 | { let foo = ATOMIC_U32_INIT; }; 32 | { let foo = ATOMIC_U32_INIT; };
| ^^^^^^^^^^^^^^^ help: try this: `AtomicU32::new(0)` | ^^^^^^^^^^^^^^^ help: try this: `AtomicU32::new(0)`
error: using `ATOMIC_U64_INIT` error: using `ATOMIC_U64_INIT`
--> $DIR/replace_consts.rs:34:17 --> $DIR/replace_consts.rs:33:17
| |
34 | { let foo = ATOMIC_U64_INIT; }; 33 | { let foo = ATOMIC_U64_INIT; };
| ^^^^^^^^^^^^^^^ help: try this: `AtomicU64::new(0)` | ^^^^^^^^^^^^^^^ help: try this: `AtomicU64::new(0)`
error: using `MIN`
--> $DIR/replace_consts.rs:35:17
|
35 | { let foo = std::isize::MIN; };
| ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:36:17 --> $DIR/replace_consts.rs:36:17
| |
36 | { let foo = std::isize::MIN; }; 36 | { let foo = std::i8::MIN; };
| ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()` | ^^^^^^^^^^^^ help: try this: `i8::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:37:17 --> $DIR/replace_consts.rs:37:17
| |
37 | { let foo = std::i8::MIN; }; 37 | { let foo = std::i16::MIN; };
| ^^^^^^^^^^^^ help: try this: `i8::min_value()` | ^^^^^^^^^^^^^ help: try this: `i16::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:38:17 --> $DIR/replace_consts.rs:38:17
| |
38 | { let foo = std::i16::MIN; }; 38 | { let foo = std::i32::MIN; };
| ^^^^^^^^^^^^^ help: try this: `i16::min_value()` | ^^^^^^^^^^^^^ help: try this: `i32::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:39:17 --> $DIR/replace_consts.rs:39:17
| |
39 | { let foo = std::i32::MIN; }; 39 | { let foo = std::i64::MIN; };
| ^^^^^^^^^^^^^ help: try this: `i32::min_value()` | ^^^^^^^^^^^^^ help: try this: `i64::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:40:17 --> $DIR/replace_consts.rs:40:17
| |
40 | { let foo = std::i64::MIN; }; 40 | { let foo = std::i128::MIN; };
| ^^^^^^^^^^^^^ help: try this: `i64::min_value()` | ^^^^^^^^^^^^^^ help: try this: `i128::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:41:17 --> $DIR/replace_consts.rs:41:17
| |
41 | { let foo = std::i128::MIN; }; 41 | { let foo = std::usize::MIN; };
| ^^^^^^^^^^^^^^ help: try this: `i128::min_value()` | ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:42:17 --> $DIR/replace_consts.rs:42:17
| |
42 | { let foo = std::usize::MIN; }; 42 | { let foo = std::u8::MIN; };
| ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()` | ^^^^^^^^^^^^ help: try this: `u8::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:43:17 --> $DIR/replace_consts.rs:43:17
| |
43 | { let foo = std::u8::MIN; }; 43 | { let foo = std::u16::MIN; };
| ^^^^^^^^^^^^ help: try this: `u8::min_value()` | ^^^^^^^^^^^^^ help: try this: `u16::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:44:17 --> $DIR/replace_consts.rs:44:17
| |
44 | { let foo = std::u16::MIN; }; 44 | { let foo = std::u32::MIN; };
| ^^^^^^^^^^^^^ help: try this: `u16::min_value()` | ^^^^^^^^^^^^^ help: try this: `u32::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:45:17 --> $DIR/replace_consts.rs:45:17
| |
45 | { let foo = std::u32::MIN; }; 45 | { let foo = std::u64::MIN; };
| ^^^^^^^^^^^^^ help: try this: `u32::min_value()` | ^^^^^^^^^^^^^ help: try this: `u64::min_value()`
error: using `MIN` error: using `MIN`
--> $DIR/replace_consts.rs:46:17 --> $DIR/replace_consts.rs:46:17
| |
46 | { let foo = std::u64::MIN; }; 46 | { let foo = std::u128::MIN; };
| ^^^^^^^^^^^^^ help: try this: `u64::min_value()`
error: using `MIN`
--> $DIR/replace_consts.rs:47:17
|
47 | { let foo = std::u128::MIN; };
| ^^^^^^^^^^^^^^ help: try this: `u128::min_value()` | ^^^^^^^^^^^^^^ help: try this: `u128::min_value()`
error: using `MAX`
--> $DIR/replace_consts.rs:48:17
|
48 | { let foo = std::isize::MAX; };
| ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:49:17 --> $DIR/replace_consts.rs:49:17
| |
49 | { let foo = std::isize::MAX; }; 49 | { let foo = std::i8::MAX; };
| ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()` | ^^^^^^^^^^^^ help: try this: `i8::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:50:17 --> $DIR/replace_consts.rs:50:17
| |
50 | { let foo = std::i8::MAX; }; 50 | { let foo = std::i16::MAX; };
| ^^^^^^^^^^^^ help: try this: `i8::max_value()` | ^^^^^^^^^^^^^ help: try this: `i16::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:51:17 --> $DIR/replace_consts.rs:51:17
| |
51 | { let foo = std::i16::MAX; }; 51 | { let foo = std::i32::MAX; };
| ^^^^^^^^^^^^^ help: try this: `i16::max_value()` | ^^^^^^^^^^^^^ help: try this: `i32::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:52:17 --> $DIR/replace_consts.rs:52:17
| |
52 | { let foo = std::i32::MAX; }; 52 | { let foo = std::i64::MAX; };
| ^^^^^^^^^^^^^ help: try this: `i32::max_value()` | ^^^^^^^^^^^^^ help: try this: `i64::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:53:17 --> $DIR/replace_consts.rs:53:17
| |
53 | { let foo = std::i64::MAX; }; 53 | { let foo = std::i128::MAX; };
| ^^^^^^^^^^^^^ help: try this: `i64::max_value()` | ^^^^^^^^^^^^^^ help: try this: `i128::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:54:17 --> $DIR/replace_consts.rs:54:17
| |
54 | { let foo = std::i128::MAX; }; 54 | { let foo = std::usize::MAX; };
| ^^^^^^^^^^^^^^ help: try this: `i128::max_value()` | ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:55:17 --> $DIR/replace_consts.rs:55:17
| |
55 | { let foo = std::usize::MAX; }; 55 | { let foo = std::u8::MAX; };
| ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()` | ^^^^^^^^^^^^ help: try this: `u8::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:56:17 --> $DIR/replace_consts.rs:56:17
| |
56 | { let foo = std::u8::MAX; }; 56 | { let foo = std::u16::MAX; };
| ^^^^^^^^^^^^ help: try this: `u8::max_value()` | ^^^^^^^^^^^^^ help: try this: `u16::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:57:17 --> $DIR/replace_consts.rs:57:17
| |
57 | { let foo = std::u16::MAX; }; 57 | { let foo = std::u32::MAX; };
| ^^^^^^^^^^^^^ help: try this: `u16::max_value()` | ^^^^^^^^^^^^^ help: try this: `u32::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:58:17 --> $DIR/replace_consts.rs:58:17
| |
58 | { let foo = std::u32::MAX; }; 58 | { let foo = std::u64::MAX; };
| ^^^^^^^^^^^^^ help: try this: `u32::max_value()` | ^^^^^^^^^^^^^ help: try this: `u64::max_value()`
error: using `MAX` error: using `MAX`
--> $DIR/replace_consts.rs:59:17 --> $DIR/replace_consts.rs:59:17
| |
59 | { let foo = std::u64::MAX; }; 59 | { let foo = std::u128::MAX; };
| ^^^^^^^^^^^^^ help: try this: `u64::max_value()`
error: using `MAX`
--> $DIR/replace_consts.rs:60:17
|
60 | { let foo = std::u128::MAX; };
| ^^^^^^^^^^^^^^ help: try this: `u128::max_value()` | ^^^^^^^^^^^^^^ help: try this: `u128::max_value()`
error: aborting due to 35 previous errors error: aborting due to 35 previous errors

View file

@ -16,12 +16,10 @@
// stripping away any starting or ending parenthesis characters—hence this // stripping away any starting or ending parenthesis characters—hence this
// test of the JSON error format. // test of the JSON error format.
#![deny(clippy::unused_unit)] #![deny(clippy::unused_unit)]
#![allow(clippy::needless_return)] #![allow(clippy::needless_return)]
struct Unitter; struct Unitter;
impl Unitter { impl Unitter {
// try to disorient the lint with multiple unit returns and newlines // try to disorient the lint with multiple unit returns and newlines
pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) -> pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) ->
@ -33,6 +31,7 @@ impl Unitter {
} }
impl Into<()> for Unitter { impl Into<()> for Unitter {
#[rustfmt::skip]
fn into(self) -> () { fn into(self) -> () {
() ()
} }

View file

@ -1,51 +1,51 @@
error: unneeded unit return type error: unneeded unit return type
--> $DIR/unused_unit.rs:27:59 --> $DIR/unused_unit.rs:25:59
| |
27 | pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) -> 25 | pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) ->
| ___________________________________________________________^ | ___________________________________________________________^
28 | | () 26 | | ()
| |__________^ help: remove the `-> ()` | |__________^ help: remove the `-> ()`
| |
note: lint level defined here note: lint level defined here
--> $DIR/unused_unit.rs:20:9 --> $DIR/unused_unit.rs:19:9
| |
20 | #![deny(clippy::unused_unit)] 19 | #![deny(clippy::unused_unit)]
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
error: unneeded unit return type error: unneeded unit return type
--> $DIR/unused_unit.rs:36:19 --> $DIR/unused_unit.rs:35:19
| |
36 | fn into(self) -> () { 35 | fn into(self) -> () {
| ^^^^^ help: remove the `-> ()` | ^^^^^ help: remove the `-> ()`
error: unneeded unit expression error: unneeded unit expression
--> $DIR/unused_unit.rs:37:9 --> $DIR/unused_unit.rs:36:9
| |
37 | () 36 | ()
| ^^ help: remove the final `()` | ^^ help: remove the final `()`
error: unneeded unit return type error: unneeded unit return type
--> $DIR/unused_unit.rs:41:18 --> $DIR/unused_unit.rs:40:18
| |
41 | fn return_unit() -> () { () } 40 | fn return_unit() -> () { () }
| ^^^^^ help: remove the `-> ()` | ^^^^^ help: remove the `-> ()`
error: unneeded unit expression error: unneeded unit expression
--> $DIR/unused_unit.rs:41:26 --> $DIR/unused_unit.rs:40:26
| |
41 | fn return_unit() -> () { () } 40 | fn return_unit() -> () { () }
| ^^ help: remove the final `()` | ^^ help: remove the final `()`
error: unneeded `()` error: unneeded `()`
--> $DIR/unused_unit.rs:48:14 --> $DIR/unused_unit.rs:47:14
| |
48 | break(); 47 | break();
| ^^ help: remove the `()` | ^^ help: remove the `()`
error: unneeded `()` error: unneeded `()`
--> $DIR/unused_unit.rs:50:11 --> $DIR/unused_unit.rs:49:11
| |
50 | return(); 49 | return();
| ^^ help: remove the `()` | ^^ help: remove the `()`
error: aborting due to 7 previous errors error: aborting due to 7 previous errors