Make most tests an `example` so we can run them one by one

This commit is contained in:
Oliver Schneider 2017-05-17 14:19:44 +02:00
parent ed909cadd6
commit 4465bc3e3f
284 changed files with 4055 additions and 3945 deletions

3
.gitignore vendored
View File

@ -15,6 +15,7 @@ out
# Generated by Cargo
/target/
/clippy_lints/target/
/clippy_tests/target/
# We don't pin yet
Cargo.lock
@ -32,4 +33,4 @@ helper.txt
*.stdout
.vscode
.vscode

View File

@ -14,6 +14,7 @@ readme = "README.md"
license = "MPL-2.0"
keywords = ["clippy", "lint", "plugin"]
categories = ["development-tools", "development-tools::cargo-plugins"]
workspace = "clippy_tests"
[badges]
travis-ci = { repository = "Manishearth/rust-clippy" }
@ -36,6 +37,7 @@ cargo_metadata = "0.2"
[dev-dependencies]
compiletest_rs = "0.2.6"
duct = "0.8.2"
lazy_static = "0.2"
regex = "0.2"
serde_derive = "1.0"

View File

@ -14,6 +14,7 @@ repository = "https://github.com/Manishearth/rust-clippy"
readme = "README.md"
license = "MPL-2.0"
keywords = ["clippy", "lint", "plugin"]
workspace = "../clippy_tests"
[dependencies]
matches = "0.1.2"

9
clippy_tests/Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "clippy_tests"
version = "0.1.0"
authors = ["Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>"]
[dependencies]
clippy = { path = ".." }
[workspace]

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(absurd_extreme_comparisons)]
#![warn(absurd_extreme_comparisons)]
#![allow(unused, eq_op, no_effect, unnecessary_operation, needless_pass_by_value)]
fn main() {

View File

@ -1,151 +1,166 @@
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:10:5
--> examples/absurd-extreme-comparisons.rs:10:5
|
10 | u <= 0;
| ^^^^^^
|
note: lint level defined here
--> $DIR/absurd-extreme-comparisons.rs:4:9
|
4 | #![deny(absurd_extreme_comparisons)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `-D 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
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:11:5
--> examples/absurd-extreme-comparisons.rs:11:5
|
11 | u <= Z;
| ^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:12:5
--> examples/absurd-extreme-comparisons.rs:12:5
|
12 | u < Z;
| ^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:13:5
--> examples/absurd-extreme-comparisons.rs:13:5
|
13 | Z >= u;
| ^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:14:5
--> examples/absurd-extreme-comparisons.rs:14:5
|
14 | Z > u;
| ^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:15:5
--> examples/absurd-extreme-comparisons.rs:15:5
|
15 | u > std::u32::MAX;
| ^^^^^^^^^^^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:16:5
--> examples/absurd-extreme-comparisons.rs:16:5
|
16 | u >= std::u32::MAX;
| ^^^^^^^^^^^^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:17:5
--> examples/absurd-extreme-comparisons.rs:17:5
|
17 | std::u32::MAX < u;
| ^^^^^^^^^^^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:18:5
--> examples/absurd-extreme-comparisons.rs:18:5
|
18 | std::u32::MAX <= u;
| ^^^^^^^^^^^^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:19:5
--> examples/absurd-extreme-comparisons.rs:19:5
|
19 | 1-1 > u;
| ^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:20:5
--> examples/absurd-extreme-comparisons.rs:20:5
|
20 | u >= !0;
| ^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:21:5
--> examples/absurd-extreme-comparisons.rs:21:5
|
21 | u <= 12 - 2*6;
| ^^^^^^^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:23:5
--> examples/absurd-extreme-comparisons.rs:23:5
|
23 | i < -127 - 1;
| ^^^^^^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:24:5
--> examples/absurd-extreme-comparisons.rs:24:5
|
24 | std::i8::MAX >= i;
| ^^^^^^^^^^^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:25:5
--> examples/absurd-extreme-comparisons.rs:25:5
|
25 | 3-7 < std::i32::MIN;
| ^^^^^^^^^^^^^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:27:5
--> examples/absurd-extreme-comparisons.rs:27:5
|
27 | b >= true;
| ^^^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= 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
--> $DIR/absurd-extreme-comparisons.rs:28:5
--> examples/absurd-extreme-comparisons.rs:28:5
|
28 | false > b;
| ^^^^^^^^^
|
= note: `-D absurd-extreme-comparisons` implied by `-D warnings`
= help: because false is the minimum value for this type, this comparison is always false
warning: <-comparison of unit values detected. This will always be false
--> $DIR/absurd-extreme-comparisons.rs:31:5
error: <-comparison of unit values detected. This will always be false
--> examples/absurd-extreme-comparisons.rs:31:5
|
31 | () < {};
| ^^^^^^^
|
= note: #[warn(unit_cmp)] on by default
= note: `-D unit-cmp` implied by `-D warnings`
error: aborting due to 17 previous errors
error: aborting due to 18 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#[deny(approx_constant)]
#[warn(approx_constant)]
#[allow(unused, shadow_unrelated, similar_names)]
fn main() {
let my_e = 2.7182;

View File

@ -1,122 +1,157 @@
error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly
--> $DIR/approx_const.rs:7:16
--> examples/approx_const.rs:7:16
|
7 | let my_e = 2.7182;
| ^^^^^^
|
note: lint level defined here
--> $DIR/approx_const.rs:4:8
|
4 | #[deny(approx_constant)]
| ^^^^^^^^^^^^^^^
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly
--> $DIR/approx_const.rs:8:20
--> examples/approx_const.rs:8:20
|
8 | let almost_e = 2.718;
| ^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::FRAC_1_PI` found. Consider using it directly
--> $DIR/approx_const.rs:11:24
--> examples/approx_const.rs:11:24
|
11 | let my_1_frac_pi = 0.3183;
| ^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly
--> $DIR/approx_const.rs:14:28
--> examples/approx_const.rs:14:28
|
14 | let my_frac_1_sqrt_2 = 0.70710678;
| ^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly
--> $DIR/approx_const.rs:15:32
--> examples/approx_const.rs:15:32
|
15 | let almost_frac_1_sqrt_2 = 0.70711;
| ^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::FRAC_2_PI` found. Consider using it directly
--> $DIR/approx_const.rs:18:24
--> examples/approx_const.rs:18:24
|
18 | let my_frac_2_pi = 0.63661977;
| ^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found. Consider using it directly
--> $DIR/approx_const.rs:21:27
--> examples/approx_const.rs:21:27
|
21 | let my_frac_2_sq_pi = 1.128379;
| ^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::FRAC_PI_2` found. Consider using it directly
--> $DIR/approx_const.rs:24:24
--> examples/approx_const.rs:24:24
|
24 | let my_frac_pi_2 = 1.57079632679;
| ^^^^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::FRAC_PI_3` found. Consider using it directly
--> $DIR/approx_const.rs:27:24
--> examples/approx_const.rs:27:24
|
27 | let my_frac_pi_3 = 1.04719755119;
| ^^^^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::FRAC_PI_4` found. Consider using it directly
--> $DIR/approx_const.rs:30:24
--> examples/approx_const.rs:30:24
|
30 | let my_frac_pi_4 = 0.785398163397;
| ^^^^^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::FRAC_PI_6` found. Consider using it directly
--> $DIR/approx_const.rs:33:24
--> examples/approx_const.rs:33:24
|
33 | let my_frac_pi_6 = 0.523598775598;
| ^^^^^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::FRAC_PI_8` found. Consider using it directly
--> $DIR/approx_const.rs:36:24
--> examples/approx_const.rs:36:24
|
36 | let my_frac_pi_8 = 0.3926990816987;
| ^^^^^^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::LN_10` found. Consider using it directly
--> $DIR/approx_const.rs:39:20
--> examples/approx_const.rs:39:20
|
39 | let my_ln_10 = 2.302585092994046;
| ^^^^^^^^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::LN_2` found. Consider using it directly
--> $DIR/approx_const.rs:42:19
--> examples/approx_const.rs:42:19
|
42 | let my_ln_2 = 0.6931471805599453;
| ^^^^^^^^^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::LOG10_E` found. Consider using it directly
--> $DIR/approx_const.rs:45:22
--> examples/approx_const.rs:45:22
|
45 | let my_log10_e = 0.43429448190325182;
| ^^^^^^^^^^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::LOG2_E` found. Consider using it directly
--> $DIR/approx_const.rs:48:21
--> examples/approx_const.rs:48:21
|
48 | let my_log2_e = 1.4426950408889634;
| ^^^^^^^^^^^^^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly
--> $DIR/approx_const.rs:51:17
--> examples/approx_const.rs:51:17
|
51 | let my_pi = 3.1415;
| ^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly
--> $DIR/approx_const.rs:52:21
--> examples/approx_const.rs:52:21
|
52 | let almost_pi = 3.14;
| ^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it directly
--> $DIR/approx_const.rs:55:18
--> examples/approx_const.rs:55:18
|
55 | let my_sq2 = 1.4142;
| ^^^^^^
|
= note: `-D approx-constant` implied by `-D warnings`
error: aborting due to 19 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(integer_arithmetic, float_arithmetic)]
#![warn(integer_arithmetic, float_arithmetic)]
#![allow(unused, shadow_reuse, shadow_unrelated, no_effect, unnecessary_operation)]
fn main() {
let i = 1i32;

View File

@ -0,0 +1,94 @@
error: integer arithmetic detected
--> examples/arithmetic.rs:8:5
|
8 | 1 + i;
| ^^^^^
|
= note: `-D integer-arithmetic` implied by `-D warnings`
error: integer arithmetic detected
--> examples/arithmetic.rs:9:5
|
9 | i * 2;
| ^^^^^
|
= note: `-D integer-arithmetic` implied by `-D warnings`
error: integer arithmetic detected
--> examples/arithmetic.rs:10:5
|
10 | / 1 %
11 | | i / 2; // no error, this is part of the expression in the preceding line
| |_________^
|
= note: `-D integer-arithmetic` implied by `-D warnings`
error: integer arithmetic detected
--> examples/arithmetic.rs:12:5
|
12 | i - 2 + 2 - i;
| ^^^^^^^^^^^^^
|
= note: `-D integer-arithmetic` implied by `-D warnings`
error: integer arithmetic detected
--> examples/arithmetic.rs:13:5
|
13 | -i;
| ^^
|
= note: `-D integer-arithmetic` implied by `-D warnings`
error: floating-point arithmetic detected
--> examples/arithmetic.rs:23:5
|
23 | f * 2.0;
| ^^^^^^^
|
= note: `-D float-arithmetic` implied by `-D warnings`
error: floating-point arithmetic detected
--> examples/arithmetic.rs:25:5
|
25 | 1.0 + f;
| ^^^^^^^
|
= note: `-D float-arithmetic` implied by `-D warnings`
error: floating-point arithmetic detected
--> examples/arithmetic.rs:26:5
|
26 | f * 2.0;
| ^^^^^^^
|
= note: `-D float-arithmetic` implied by `-D warnings`
error: floating-point arithmetic detected
--> examples/arithmetic.rs:27:5
|
27 | f / 2.0;
| ^^^^^^^
|
= note: `-D float-arithmetic` implied by `-D warnings`
error: floating-point arithmetic detected
--> examples/arithmetic.rs:28:5
|
28 | f - 2.0 * 4.2;
| ^^^^^^^^^^^^^
|
= note: `-D float-arithmetic` implied by `-D warnings`
error: floating-point arithmetic detected
--> examples/arithmetic.rs:29:5
|
29 | -f;
| ^^
|
= note: `-D float-arithmetic` implied by `-D warnings`
error: aborting due to 11 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,8 +1,8 @@
#![feature(inclusive_range_syntax, plugin)]
#![plugin(clippy)]
#![deny(indexing_slicing)]
#![deny(out_of_bounds_indexing)]
#![warn(indexing_slicing)]
#![warn(out_of_bounds_indexing)]
#![allow(no_effect, unnecessary_operation)]
fn main() {

View File

@ -0,0 +1,157 @@
error: const index is out of bounds
--> examples/array_indexing.rs:12:5
|
12 | x[4];
| ^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: const index is out of bounds
--> examples/array_indexing.rs:13:5
|
13 | x[1 << 3];
| ^^^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:14:6
|
14 | &x[1..5];
| ^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:16:6
|
16 | &x[0...4];
| ^^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:17:6
|
17 | &x[...4];
| ^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:21:6
|
21 | &x[5..];
| ^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:23:6
|
23 | &x[..5];
| ^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: indexing may panic
--> examples/array_indexing.rs:26:5
|
26 | y[0];
| ^^^^
|
= note: `-D indexing-slicing` implied by `-D warnings`
error: slicing may panic
--> examples/array_indexing.rs:27:6
|
27 | &y[1..2];
| ^^^^^^^
|
= note: `-D indexing-slicing` implied by `-D warnings`
error: slicing may panic
--> examples/array_indexing.rs:29:6
|
29 | &y[0...4];
| ^^^^^^^^
|
= note: `-D indexing-slicing` implied by `-D warnings`
error: slicing may panic
--> examples/array_indexing.rs:30:6
|
30 | &y[...4];
| ^^^^^^^
|
= note: `-D indexing-slicing` implied by `-D warnings`
error: const index is out of bounds
--> examples/array_indexing.rs:33:5
|
33 | empty[0];
| ^^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:34:6
|
34 | &empty[1..5];
| ^^^^^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:35:6
|
35 | &empty[0...4];
| ^^^^^^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:36:6
|
36 | &empty[...4];
| ^^^^^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:40:6
|
40 | &empty[0...0];
| ^^^^^^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:41:6
|
41 | &empty[...0];
| ^^^^^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:43:6
|
43 | &empty[1..];
| ^^^^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: range is out of bounds
--> examples/array_indexing.rs:44:6
|
44 | &empty[..4];
| ^^^^^^^^^^
|
= note: `-D out-of-bounds-indexing` implied by `-D warnings`
error: aborting due to 19 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#[deny(assign_ops)]
#[warn(assign_ops)]
#[allow(unused_assignments)]
fn main() {
let mut i = 1i32;
@ -21,7 +21,7 @@ fn main() {
}
#[allow(dead_code, unused_assignments)]
#[deny(assign_op_pattern)]
#[warn(assign_op_pattern)]
fn bla() {
let mut a = 5;
a = a + 1;

View File

@ -1,140 +1,173 @@
error: assign operation detected
--> $DIR/assign_ops.rs:8:5
--> examples/assign_ops.rs:8:5
|
8 | i += 2;
| ^^^^^^ help: replace it with `i = i + 2`
|
note: lint level defined here
--> $DIR/assign_ops.rs:4:8
|
4 | #[deny(assign_ops)]
| ^^^^^^^^^^
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:9:5
--> examples/assign_ops.rs:9:5
|
9 | i += 2 + 17;
| ^^^^^^^^^^^ help: replace it with `i = i + 2 + 17`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:10:5
--> examples/assign_ops.rs:10:5
|
10 | i -= 6;
| ^^^^^^ help: replace it with `i = i - 6`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:11:5
--> examples/assign_ops.rs:11:5
|
11 | i -= 2 - 1;
| ^^^^^^^^^^ help: replace it with `i = i - (2 - 1)`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:12:5
--> examples/assign_ops.rs:12:5
|
12 | i *= 5;
| ^^^^^^ help: replace it with `i = i * 5`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:13:5
--> examples/assign_ops.rs:13:5
|
13 | i *= 1+5;
| ^^^^^^^^ help: replace it with `i = i * (1+5)`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:14:5
--> examples/assign_ops.rs:14:5
|
14 | i /= 32;
| ^^^^^^^ help: replace it with `i = i / 32`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:15:5
--> examples/assign_ops.rs:15:5
|
15 | i /= 32 | 5;
| ^^^^^^^^^^^ help: replace it with `i = i / (32 | 5)`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:16:5
--> examples/assign_ops.rs:16:5
|
16 | i /= 32 / 5;
| ^^^^^^^^^^^ help: replace it with `i = i / (32 / 5)`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:17:5
--> examples/assign_ops.rs:17:5
|
17 | i %= 42;
| ^^^^^^^ help: replace it with `i = i % 42`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:18:5
--> examples/assign_ops.rs:18:5
|
18 | i >>= i;
| ^^^^^^^ help: replace it with `i = i >> i`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:19:5
--> examples/assign_ops.rs:19:5
|
19 | i <<= 9 + 6 - 7;
| ^^^^^^^^^^^^^^^ help: replace it with `i = i << (9 + 6 - 7)`
|
= note: `-D assign-ops` implied by `-D warnings`
error: assign operation detected
--> $DIR/assign_ops.rs:20:5
--> examples/assign_ops.rs:20:5
|
20 | i += 1 << 5;
| ^^^^^^^^^^^ help: replace it with `i = i + (1 << 5)`
|
= note: `-D assign-ops` implied by `-D warnings`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:27:5
--> examples/assign_ops.rs:27:5
|
27 | a = a + 1;
| ^^^^^^^^^ help: replace it with `a += 1`
|
note: lint level defined here
--> $DIR/assign_ops.rs:24:8
|
24 | #[deny(assign_op_pattern)]
| ^^^^^^^^^^^^^^^^^
= note: `-D assign-op-pattern` implied by `-D warnings`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:28:5
--> examples/assign_ops.rs:28:5
|
28 | a = 1 + a;
| ^^^^^^^^^ help: replace it with `a += 1`
|
= note: `-D assign-op-pattern` implied by `-D warnings`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:29:5
--> examples/assign_ops.rs:29:5
|
29 | a = a - 1;
| ^^^^^^^^^ help: replace it with `a -= 1`
|
= note: `-D assign-op-pattern` implied by `-D warnings`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:30:5
--> examples/assign_ops.rs:30:5
|
30 | a = a * 99;
| ^^^^^^^^^^ help: replace it with `a *= 99`
|
= note: `-D assign-op-pattern` implied by `-D warnings`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:31:5
--> examples/assign_ops.rs:31:5
|
31 | a = 42 * a;
| ^^^^^^^^^^ help: replace it with `a *= 42`
|
= note: `-D assign-op-pattern` implied by `-D warnings`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:32:5
--> examples/assign_ops.rs:32:5
|
32 | a = a / 2;
| ^^^^^^^^^ help: replace it with `a /= 2`
|
= note: `-D assign-op-pattern` implied by `-D warnings`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:33:5
--> examples/assign_ops.rs:33:5
|
33 | a = a % 5;
| ^^^^^^^^^ help: replace it with `a %= 5`
|
= note: `-D assign-op-pattern` implied by `-D warnings`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:34:5
--> examples/assign_ops.rs:34:5
|
34 | a = a & 1;
| ^^^^^^^^^ help: replace it with `a &= 1`
|
= note: `-D assign-op-pattern` implied by `-D warnings`
error: aborting due to 21 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -2,7 +2,7 @@
#![plugin(clippy)]
#[allow(unused_assignments)]
#[deny(misrefactored_assign_op)]
#[warn(misrefactored_assign_op)]
fn main() {
let mut a = 5;
a += a + 1;

View File

@ -1,56 +1,69 @@
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:8:5
--> examples/assign_ops2.rs:8:5
|
8 | a += a + 1;
| ^^^^^^^^^^ help: replace it with `a += 1`
|
note: lint level defined here
--> $DIR/assign_ops2.rs:5:8
|
5 | #[deny(misrefactored_assign_op)]
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: `-D misrefactored-assign-op` implied by `-D warnings`
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:9:5
--> examples/assign_ops2.rs:9:5
|
9 | a += 1 + a;
| ^^^^^^^^^^ help: replace it with `a += 1`
|
= note: `-D misrefactored-assign-op` implied by `-D warnings`
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:10:5
--> examples/assign_ops2.rs:10:5
|
10 | a -= a - 1;
| ^^^^^^^^^^ help: replace it with `a -= 1`
|
= note: `-D misrefactored-assign-op` implied by `-D warnings`
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:11:5
--> examples/assign_ops2.rs:11:5
|
11 | a *= a * 99;
| ^^^^^^^^^^^ help: replace it with `a *= 99`
|
= note: `-D misrefactored-assign-op` implied by `-D warnings`
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:12:5
--> examples/assign_ops2.rs:12:5
|
12 | a *= 42 * a;
| ^^^^^^^^^^^ help: replace it with `a *= 42`
|
= note: `-D misrefactored-assign-op` implied by `-D warnings`
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:13:5
--> examples/assign_ops2.rs:13:5
|
13 | a /= a / 2;
| ^^^^^^^^^^ help: replace it with `a /= 2`
|
= note: `-D misrefactored-assign-op` implied by `-D warnings`
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:14:5
--> examples/assign_ops2.rs:14:5
|
14 | a %= a % 5;
| ^^^^^^^^^^ help: replace it with `a %= 5`
|
= note: `-D misrefactored-assign-op` implied by `-D warnings`
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:15:5
--> examples/assign_ops2.rs:15:5
|
15 | a &= a & 1;
| ^^^^^^^^^^ help: replace it with `a &= 1`
|
= note: `-D misrefactored-assign-op` implied by `-D warnings`
error: aborting due to 8 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(inline_always, deprecated_semver)]
#![warn(inline_always, deprecated_semver)]
#[inline(always)]
fn test_attr_lint() {

View File

@ -1,32 +1,29 @@
error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea
--> $DIR/attrs.rs:6:1
--> examples/attrs.rs:6:1
|
6 | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/attrs.rs:4:9
|
4 | #![deny(inline_always, deprecated_semver)]
| ^^^^^^^^^^^^^
= note: `-D inline-always` implied by `-D warnings`
error: the since field must contain a semver-compliant version
--> $DIR/attrs.rs:27:14
--> examples/attrs.rs:27:14
|
27 | #[deprecated(since = "forever")]
| ^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/attrs.rs:4:24
|
4 | #![deny(inline_always, deprecated_semver)]
| ^^^^^^^^^^^^^^^^^
= note: `-D deprecated-semver` implied by `-D warnings`
error: the since field must contain a semver-compliant version
--> $DIR/attrs.rs:30:14
--> examples/attrs.rs:30:14
|
30 | #[deprecated(since = "1")]
| ^^^^^^^^^^^
|
= note: `-D deprecated-semver` implied by `-D warnings`
error: aborting due to 3 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -4,7 +4,7 @@
const THREE_BITS : i64 = 7;
const EVEN_MORE_REDIRECTION : i64 = THREE_BITS;
#[deny(bad_bit_mask)]
#[warn(bad_bit_mask)]
#[allow(ineffective_bit_mask, identity_op, no_effect, unnecessary_operation)]
fn main() {
let x = 5;
@ -44,7 +44,7 @@ fn main() {
ineffective();
}
#[deny(ineffective_bit_mask)]
#[warn(ineffective_bit_mask)]
#[allow(bad_bit_mask, no_effect, unnecessary_operation)]
fn ineffective() {
let x = 5;

View File

@ -1,104 +1,125 @@
error: &-masking with zero
--> $DIR/bit_masks.rs:12:5
--> examples/bit_masks.rs:12:5
|
12 | x & 0 == 0;
| ^^^^^^^^^^
|
note: lint level defined here
--> $DIR/bit_masks.rs:7:8
|
7 | #[deny(bad_bit_mask)]
| ^^^^^^^^^^^^
= note: `-D bad-bit-mask` implied by `-D warnings`
error: incompatible bit mask: `_ & 2` can never be equal to `1`
--> $DIR/bit_masks.rs:15:5
--> examples/bit_masks.rs:15:5
|
15 | x & 2 == 1;
| ^^^^^^^^^^
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: incompatible bit mask: `_ | 3` can never be equal to `2`
--> $DIR/bit_masks.rs:19:5
--> examples/bit_masks.rs:19:5
|
19 | x | 3 == 2;
| ^^^^^^^^^^
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: incompatible bit mask: `_ & 1` will never be higher than `1`
--> $DIR/bit_masks.rs:21:5
--> examples/bit_masks.rs:21:5
|
21 | x & 1 > 1;
| ^^^^^^^^^
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: incompatible bit mask: `_ | 2` will always be higher than `1`
--> $DIR/bit_masks.rs:25:5
--> examples/bit_masks.rs:25:5
|
25 | x | 2 > 1;
| ^^^^^^^^^
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: incompatible bit mask: `_ & 7` can never be equal to `8`
--> $DIR/bit_masks.rs:32:5
--> examples/bit_masks.rs:32:5
|
32 | x & THREE_BITS == 8;
| ^^^^^^^^^^^^^^^^^^^
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: incompatible bit mask: `_ | 7` will never be lower than `7`
--> $DIR/bit_masks.rs:33:5
--> examples/bit_masks.rs:33:5
|
33 | x | EVEN_MORE_REDIRECTION < 7;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: &-masking with zero
--> $DIR/bit_masks.rs:35:5
--> examples/bit_masks.rs:35:5
|
35 | 0 & x == 0;
| ^^^^^^^^^^
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: incompatible bit mask: `_ | 2` will always be higher than `1`
--> $DIR/bit_masks.rs:39:5
--> examples/bit_masks.rs:39:5
|
39 | 1 < 2 | x;
| ^^^^^^^^^
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: incompatible bit mask: `_ | 3` can never be equal to `2`
--> $DIR/bit_masks.rs:40:5
--> examples/bit_masks.rs:40:5
|
40 | 2 == 3 | x;
| ^^^^^^^^^^
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: incompatible bit mask: `_ & 2` can never be equal to `1`
--> $DIR/bit_masks.rs:41:5
--> examples/bit_masks.rs:41:5
|
41 | 1 == x & 2;
| ^^^^^^^^^^
|
= note: `-D bad-bit-mask` implied by `-D warnings`
error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly
--> $DIR/bit_masks.rs:52:5
--> examples/bit_masks.rs:52:5
|
52 | x | 1 > 3;
| ^^^^^^^^^
|
note: lint level defined here
--> $DIR/bit_masks.rs:47:8
|
47 | #[deny(ineffective_bit_mask)]
| ^^^^^^^^^^^^^^^^^^^^
= note: `-D ineffective-bit-mask` implied by `-D warnings`
error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly
--> $DIR/bit_masks.rs:53:5
--> examples/bit_masks.rs:53:5
|
53 | x | 1 < 4;
| ^^^^^^^^^
|
= note: `-D ineffective-bit-mask` implied by `-D warnings`
error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly
--> $DIR/bit_masks.rs:54:5
--> examples/bit_masks.rs:54:5
|
54 | x | 1 <= 3;
| ^^^^^^^^^^
|
= note: `-D ineffective-bit-mask` implied by `-D warnings`
error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly
--> $DIR/bit_masks.rs:55:5
--> examples/bit_masks.rs:55:5
|
55 | x | 1 >= 8;
| ^^^^^^^^^^
|
= note: `-D ineffective-bit-mask` implied by `-D warnings`
error: aborting due to 15 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -2,7 +2,7 @@
#![plugin(clippy)]
#![allow(dead_code, similar_names, single_match, toplevel_ref_arg, unused_mut, unused_variables)]
#![deny(blacklisted_name)]
#![warn(blacklisted_name)]
fn test(foo: ()) {}

View File

@ -1,92 +1,117 @@
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:7:9
--> examples/blacklisted_name.rs:7:9
|
7 | fn test(foo: ()) {}
| ^^^
|
note: lint level defined here
--> $DIR/blacklisted_name.rs:5:9
|
5 | #![deny(blacklisted_name)]
| ^^^^^^^^^^^^^^^^
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:10:9
--> examples/blacklisted_name.rs:10:9
|
10 | let foo = 42;
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:11:9
--> examples/blacklisted_name.rs:11:9
|
11 | let bar = 42;
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:12:9
--> examples/blacklisted_name.rs:12:9
|
12 | let baz = 42;
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:18:10
--> examples/blacklisted_name.rs:18:10
|
18 | (foo, Some(bar), baz @ Some(_)) => (),
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:18:20
--> examples/blacklisted_name.rs:18:20
|
18 | (foo, Some(bar), baz @ Some(_)) => (),
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:18:26
--> examples/blacklisted_name.rs:18:26
|
18 | (foo, Some(bar), baz @ Some(_)) => (),
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:23:19
--> examples/blacklisted_name.rs:23:19
|
23 | fn issue_1647(mut foo: u8) {
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:24:13
--> examples/blacklisted_name.rs:24:13
|
24 | let mut bar = 0;
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:25:21
--> examples/blacklisted_name.rs:25:21
|
25 | if let Some(mut baz) = Some(42) {}
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:29:13
--> examples/blacklisted_name.rs:29:13
|
29 | let ref bar = 0;
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:30:21
--> examples/blacklisted_name.rs:30:21
|
30 | if let Some(ref baz) = Some(42) {}
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:34:17
--> examples/blacklisted_name.rs:34:17
|
34 | let ref mut bar = 0;
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:35:25
--> examples/blacklisted_name.rs:35:25
|
35 | if let Some(ref mut baz) = Some(42) {}
| ^^^
|
= note: `-D blacklisted-name` implied by `-D warnings`
error: aborting due to 14 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,8 +1,8 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(block_in_if_condition_expr)]
#![deny(block_in_if_condition_stmt)]
#![warn(block_in_if_condition_expr)]
#![warn(block_in_if_condition_stmt)]
#![allow(unused, let_and_return)]
#![warn(nonminimal_bool)]

View File

@ -1,5 +1,5 @@
error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let'
--> $DIR/block_in_if_condition.rs:30:8
--> examples/block_in_if_condition.rs:30:8
|
30 | if {
| ________^
@ -8,11 +8,7 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; inste
33 | | } {
| |_____^
|
note: lint level defined here
--> $DIR/block_in_if_condition.rs:5:9
|
5 | #![deny(block_in_if_condition_stmt)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `-D block-in-if-condition-stmt` implied by `-D warnings`
= help: try
let res = {
let x = 3;
@ -23,44 +19,43 @@ note: lint level defined here
} ...
error: omit braces around single expression condition
--> $DIR/block_in_if_condition.rs:41:8
--> examples/block_in_if_condition.rs:41:8
|
41 | if { true } {
| ^^^^^^^^
|
note: lint level defined here
--> $DIR/block_in_if_condition.rs:4:9
|
4 | #![deny(block_in_if_condition_expr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `-D block-in-if-condition-expr` implied by `-D warnings`
= help: try
if true {
6
} ...
error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let'
--> $DIR/block_in_if_condition.rs:58:49
--> examples/block_in_if_condition.rs:58:49
|
58 | if v == 3 && sky == "blue" && predicate(|x| { let target = 3; x == target }, v) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D block-in-if-condition-stmt` implied by `-D warnings`
error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let'
--> $DIR/block_in_if_condition.rs:61:22
--> examples/block_in_if_condition.rs:61:22
|
61 | if predicate(|x| { let target = 3; x == target }, v) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D block-in-if-condition-stmt` implied by `-D warnings`
warning: this boolean expression can be simplified
--> $DIR/block_in_if_condition.rs:67:8
error: this boolean expression can be simplified
--> examples/block_in_if_condition.rs:67:8
|
67 | if true && x == 3 {
| ^^^^^^^^^^^^^^ help: try `x == 3`
|
note: lint level defined here
--> $DIR/block_in_if_condition.rs:7:9
|
7 | #![warn(nonminimal_bool)]
| ^^^^^^^^^^^^^^^
= note: `-D nonminimal-bool` implied by `-D warnings`
error: aborting due to 4 previous errors
error: aborting due to 5 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#[deny(bool_comparison)]
#[warn(bool_comparison)]
fn main() {
let x = true;
if x == true { "yes" } else { "no" };

View File

@ -1,32 +1,37 @@
error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:7:8
--> examples/bool_comparison.rs:7:8
|
7 | if x == true { "yes" } else { "no" };
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
note: lint level defined here
--> $DIR/bool_comparison.rs:4:8
|
4 | #[deny(bool_comparison)]
| ^^^^^^^^^^^^^^^
= note: `-D bool-comparison` implied by `-D warnings`
error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:8:8
--> examples/bool_comparison.rs:8:8
|
8 | if x == false { "yes" } else { "no" };
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
= note: `-D bool-comparison` implied by `-D warnings`
error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:9:8
--> examples/bool_comparison.rs:9:8
|
9 | if true == x { "yes" } else { "no" };
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
= note: `-D bool-comparison` implied by `-D warnings`
error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:10:8
--> examples/bool_comparison.rs:10:8
|
10 | if false == x { "yes" } else { "no" };
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
= note: `-D bool-comparison` implied by `-D warnings`
error: aborting due to 4 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,6 +1,6 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(nonminimal_bool, logic_bug)]
#![warn(nonminimal_bool, logic_bug)]
#[allow(unused, many_single_char_names)]
fn main() {

View File

@ -1,133 +1,143 @@
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:12:13
--> examples/booleans.rs:12:13
|
12 | let _ = a && b || a;
| ^^^^^^^^^^^ help: it would look like the following `a`
|
note: lint level defined here
--> $DIR/booleans.rs:3:26
|
3 | #![deny(nonminimal_bool, logic_bug)]
| ^^^^^^^^^
= note: `-D logic-bug` implied by `-D warnings`
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:12:18
--> examples/booleans.rs:12:18
|
12 | let _ = a && b || a;
| ^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:14:13
--> examples/booleans.rs:14:13
|
14 | let _ = !true;
| ^^^^^ help: try `false`
|
note: lint level defined here
--> $DIR/booleans.rs:3:9
|
3 | #![deny(nonminimal_bool, logic_bug)]
| ^^^^^^^^^^^^^^^
= note: `-D nonminimal-bool` implied by `-D warnings`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:15:13
--> examples/booleans.rs:15:13
|
15 | let _ = !false;
| ^^^^^^ help: try `true`
|
= note: `-D nonminimal-bool` implied by `-D warnings`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:16:13
--> examples/booleans.rs:16:13
|
16 | let _ = !!a;
| ^^^ help: try `a`
|
= note: `-D nonminimal-bool` implied by `-D warnings`
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:17:13
--> examples/booleans.rs:17:13
|
17 | let _ = false && a;
| ^^^^^^^^^^ help: it would look like the following `false`
|
= note: `-D logic-bug` implied by `-D warnings`
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:17:22
--> examples/booleans.rs:17:22
|
17 | let _ = false && a;
| ^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:18:13
--> examples/booleans.rs:18:13
|
18 | let _ = false || a;
| ^^^^^^^^^^ help: try `a`
|
= note: `-D nonminimal-bool` implied by `-D warnings`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:23:13
--> examples/booleans.rs:23:13
|
23 | let _ = !(!a && b);
| ^^^^^^^^^^ help: try `!b || a`
|
= note: `-D nonminimal-bool` implied by `-D warnings`
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:33:13
--> examples/booleans.rs:33:13
|
33 | let _ = a == b && a != b;
| ^^^^^^^^^^^^^^^^ help: it would look like the following `false`
|
= note: `-D logic-bug` implied by `-D warnings`
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:33:13
--> examples/booleans.rs:33:13
|
33 | let _ = a == b && a != b;
| ^^^^^^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:34:13
--> examples/booleans.rs:34:13
|
34 | let _ = a == b && c == 5 && a == b;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D nonminimal-bool` implied by `-D warnings`
help: try
| let _ = a == b && c == 5;
| let _ = !(c != 5 || a != b);
error: this boolean expression can be simplified
--> $DIR/booleans.rs:35:13
--> examples/booleans.rs:35:13
|
35 | let _ = a == b && c == 5 && b == a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D nonminimal-bool` implied by `-D warnings`
help: try
| let _ = a == b && c == 5;
| let _ = !(c != 5 || a != b);
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:36:13
--> examples/booleans.rs:36:13
|
36 | let _ = a < b && a >= b;
| ^^^^^^^^^^^^^^^ help: it would look like the following `false`
|
= note: `-D logic-bug` implied by `-D warnings`
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:36:13
--> examples/booleans.rs:36:13
|
36 | let _ = a < b && a >= b;
| ^^^^^
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:37:13
--> examples/booleans.rs:37:13
|
37 | let _ = a > b && a <= b;
| ^^^^^^^^^^^^^^^ help: it would look like the following `false`
|
= note: `-D logic-bug` implied by `-D warnings`
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:37:13
--> examples/booleans.rs:37:13
|
37 | let _ = a > b && a <= b;
| ^^^^^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:39:13
--> examples/booleans.rs:39:13
|
39 | let _ = a != b || !(a != b || c == d);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D nonminimal-bool` implied by `-D warnings`
help: try
| let _ = c != d || a != b;
| let _ = !(a == b && c == d);
error: aborting due to 13 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(clippy)]
#![warn(clippy)]
#![allow(boxed_local, needless_pass_by_value)]
#![allow(blacklisted_name)]

View File

@ -1,16 +1,14 @@
error: you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`
--> $DIR/box_vec.rs:17:18
--> examples/box_vec.rs:17:18
|
17 | pub fn test(foo: Box<Vec<bool>>) {
| ^^^^^^^^^^^^^^
|
= note: #[deny(box_vec)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/box_vec.rs:4:9
|
4 | #![deny(clippy)]
| ^^^^^^
= note: `-D box-vec` implied by `-D warnings`
= help: `Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation.
error: aborting due to previous error
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#[deny(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap)]
#[warn(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap)]
#[allow(no_effect, unnecessary_operation)]
fn main() {
// Test cast_precision_loss

View File

@ -1,302 +1,365 @@
error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast.rs:8:5
--> examples/cast.rs:8:5
|
8 | 1i32 as f32;
| ^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/cast.rs:4:8
|
4 | #[deny(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap)]
| ^^^^^^^^^^^^^^^^^^^
= note: `-D cast-precision-loss` implied by `-D warnings`
error: casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast.rs:9:5
--> examples/cast.rs:9:5
|
9 | 1i64 as f32;
| ^^^^^^^^^^^
|
= note: `-D cast-precision-loss` implied by `-D warnings`
error: casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
--> $DIR/cast.rs:10:5
--> examples/cast.rs:10:5
|
10 | 1i64 as f64;
| ^^^^^^^^^^^
|
= note: `-D cast-precision-loss` implied by `-D warnings`
error: casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast.rs:11:5
--> examples/cast.rs:11:5
|
11 | 1u32 as f32;
| ^^^^^^^^^^^
|
= note: `-D cast-precision-loss` implied by `-D warnings`
error: casting u64 to f32 causes a loss of precision (u64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast.rs:12:5
--> examples/cast.rs:12:5
|
12 | 1u64 as f32;
| ^^^^^^^^^^^
|
= note: `-D cast-precision-loss` implied by `-D warnings`
error: casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
--> $DIR/cast.rs:13:5
--> examples/cast.rs:13:5
|
13 | 1u64 as f64;
| ^^^^^^^^^^^
|
= note: `-D cast-precision-loss` implied by `-D warnings`
error: casting f32 to i32 may truncate the value
--> $DIR/cast.rs:17:5
--> examples/cast.rs:17:5
|
17 | 1f32 as i32;
| ^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/cast.rs:4:29
|
4 | #[deny(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting f32 to u32 may truncate the value
--> $DIR/cast.rs:18:5
--> examples/cast.rs:18:5
|
18 | 1f32 as u32;
| ^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting f32 to u32 may lose the sign of the value
--> $DIR/cast.rs:18:5
--> examples/cast.rs:18:5
|
18 | 1f32 as u32;
| ^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/cast.rs:4:55
|
4 | #[deny(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap)]
| ^^^^^^^^^^^^^^
= note: `-D cast-sign-loss` implied by `-D warnings`
error: casting f64 to f32 may truncate the value
--> $DIR/cast.rs:19:5
--> examples/cast.rs:19:5
|
19 | 1f64 as f32;
| ^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting i32 to i8 may truncate the value
--> $DIR/cast.rs:20:5
--> examples/cast.rs:20:5
|
20 | 1i32 as i8;
| ^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting i32 to u8 may lose the sign of the value
--> $DIR/cast.rs:21:5
--> examples/cast.rs:21:5
|
21 | 1i32 as u8;
| ^^^^^^^^^^
|
= note: `-D cast-sign-loss` implied by `-D warnings`
error: casting i32 to u8 may truncate the value
--> $DIR/cast.rs:21:5
--> examples/cast.rs:21:5
|
21 | 1i32 as u8;
| ^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting f64 to isize may truncate the value
--> $DIR/cast.rs:22:5
--> examples/cast.rs:22:5
|
22 | 1f64 as isize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting f64 to usize may truncate the value
--> $DIR/cast.rs:23:5
--> examples/cast.rs:23:5
|
23 | 1f64 as usize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting f64 to usize may lose the sign of the value
--> $DIR/cast.rs:23:5
--> examples/cast.rs:23:5
|
23 | 1f64 as usize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-sign-loss` implied by `-D warnings`
error: casting u8 to i8 may wrap around the value
--> $DIR/cast.rs:25:5
--> examples/cast.rs:25:5
|
25 | 1u8 as i8;
| ^^^^^^^^^
|
note: lint level defined here
--> $DIR/cast.rs:4:71
|
4 | #[deny(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap)]
| ^^^^^^^^^^^^^^^^^^
= note: `-D cast-possible-wrap` implied by `-D warnings`
error: casting u16 to i16 may wrap around the value
--> $DIR/cast.rs:26:5
--> examples/cast.rs:26:5
|
26 | 1u16 as i16;
| ^^^^^^^^^^^
|
= note: `-D cast-possible-wrap` implied by `-D warnings`
error: casting u32 to i32 may wrap around the value
--> $DIR/cast.rs:27:5
--> examples/cast.rs:27:5
|
27 | 1u32 as i32;
| ^^^^^^^^^^^
|
= note: `-D cast-possible-wrap` implied by `-D warnings`
error: casting u64 to i64 may wrap around the value
--> $DIR/cast.rs:28:5
--> examples/cast.rs:28:5
|
28 | 1u64 as i64;
| ^^^^^^^^^^^
|
= note: `-D cast-possible-wrap` implied by `-D warnings`
error: casting usize to isize may wrap around the value
--> $DIR/cast.rs:29:5
--> examples/cast.rs:29:5
|
29 | 1usize as isize;
| ^^^^^^^^^^^^^^^
|
= note: `-D cast-possible-wrap` implied by `-D warnings`
error: casting i32 to u32 may lose the sign of the value
--> $DIR/cast.rs:31:5
--> examples/cast.rs:31:5
|
31 | 1i32 as u32;
| ^^^^^^^^^^^
|
= note: `-D cast-sign-loss` implied by `-D warnings`
error: casting isize to usize may lose the sign of the value
--> $DIR/cast.rs:32:5
--> examples/cast.rs:32:5
|
32 | 1isize as usize;
| ^^^^^^^^^^^^^^^
|
= note: `-D cast-sign-loss` implied by `-D warnings`
error: casting isize to i8 may truncate the value
--> $DIR/cast.rs:35:5
--> examples/cast.rs:35:5
|
35 | 1isize as i8;
| ^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide)
--> $DIR/cast.rs:36:5
--> examples/cast.rs:36:5
|
36 | 1isize as f64;
| ^^^^^^^^^^^^^
|
= note: `-D cast-precision-loss` implied by `-D warnings`
error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide)
--> $DIR/cast.rs:37:5
--> examples/cast.rs:37:5
|
37 | 1usize as f64;
| ^^^^^^^^^^^^^
|
= note: `-D cast-precision-loss` implied by `-D warnings`
error: casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast.rs:38:5
--> examples/cast.rs:38:5
|
38 | 1isize as f32;
| ^^^^^^^^^^^^^
|
= note: `-D cast-precision-loss` implied by `-D warnings`
error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast.rs:39:5
--> examples/cast.rs:39:5
|
39 | 1usize as f32;
| ^^^^^^^^^^^^^
|
= note: `-D cast-precision-loss` implied by `-D warnings`
error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast.rs:40:5
--> examples/cast.rs:40:5
|
40 | 1isize as i32;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting isize to u32 may lose the sign of the value
--> $DIR/cast.rs:41:5
--> examples/cast.rs:41:5
|
41 | 1isize as u32;
| ^^^^^^^^^^^^^
|
= note: `-D cast-sign-loss` implied by `-D warnings`
error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast.rs:41:5
--> examples/cast.rs:41:5
|
41 | 1isize as u32;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast.rs:42:5
--> examples/cast.rs:42:5
|
42 | 1usize as u32;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast.rs:43:5
--> examples/cast.rs:43:5
|
43 | 1usize as i32;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:43:5
--> examples/cast.rs:43:5
|
43 | 1usize as i32;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-wrap` implied by `-D warnings`
error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:45:5
--> examples/cast.rs:45:5
|
45 | 1i64 as isize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting i64 to usize may lose the sign of the value
--> $DIR/cast.rs:46:5
--> examples/cast.rs:46:5
|
46 | 1i64 as usize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-sign-loss` implied by `-D warnings`
error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:46:5
--> examples/cast.rs:46:5
|
46 | 1i64 as usize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:47:5
--> examples/cast.rs:47:5
|
47 | 1u64 as isize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers
--> $DIR/cast.rs:47:5
--> examples/cast.rs:47:5
|
47 | 1u64 as isize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-wrap` implied by `-D warnings`
error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:48:5
--> examples/cast.rs:48:5
|
48 | 1u64 as usize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-truncation` implied by `-D warnings`
error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:49:5
--> examples/cast.rs:49:5
|
49 | 1u32 as isize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-possible-wrap` implied by `-D warnings`
error: casting i32 to usize may lose the sign of the value
--> $DIR/cast.rs:52:5
--> examples/cast.rs:52:5
|
52 | 1i32 as usize;
| ^^^^^^^^^^^^^
|
= note: `-D cast-sign-loss` implied by `-D warnings`
warning: casting to the same type is unnecessary (`i32` -> `i32`)
--> $DIR/cast.rs:54:5
error: casting to the same type is unnecessary (`i32` -> `i32`)
--> examples/cast.rs:54:5
|
54 | 1i32 as i32;
| ^^^^^^^^^^^
|
= note: #[warn(unnecessary_cast)] on by default
= note: `-D unnecessary-cast` implied by `-D warnings`
warning: casting to the same type is unnecessary (`f32` -> `f32`)
--> $DIR/cast.rs:55:5
error: casting to the same type is unnecessary (`f32` -> `f32`)
--> examples/cast.rs:55:5
|
55 | 1f32 as f32;
| ^^^^^^^^^^^
|
= note: #[warn(unnecessary_cast)] on by default
= note: `-D unnecessary-cast` implied by `-D warnings`
warning: casting to the same type is unnecessary (`bool` -> `bool`)
--> $DIR/cast.rs:56:5
error: casting to the same type is unnecessary (`bool` -> `bool`)
--> examples/cast.rs:56:5
|
56 | false as bool;
| ^^^^^^^^^^^^^
|
= note: #[warn(unnecessary_cast)] on by default
= note: `-D unnecessary-cast` implied by `-D warnings`
error: aborting due to 42 previous errors
error: aborting due to 45 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(char_lit_as_u8)]
#![warn(char_lit_as_u8)]
#![allow(unused_variables)]
fn main() {
let c = 'a' as u8;

View File

@ -1,16 +1,15 @@
error: casting character literal to u8. `char`s are 4 bytes wide in rust, so casting to u8 truncates them
--> $DIR/char_lit_as_u8.rs:7:13
--> examples/char_lit_as_u8.rs:7:13
|
7 | let c = 'a' as u8;
| ^^^^^^^^^
|
note: lint level defined here
--> $DIR/char_lit_as_u8.rs:4:9
|
4 | #![deny(char_lit_as_u8)]
| ^^^^^^^^^^^^^^
= note: `-D char-lit-as-u8` implied by `-D warnings`
= help: Consider using a byte literal instead:
b'a'
error: aborting due to previous error
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#[deny(cmp_nan)]
#[warn(cmp_nan)]
#[allow(float_cmp, no_effect, unnecessary_operation)]
fn main() {
let x = 5f32;

View File

@ -1,98 +1,101 @@
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:8:5
--> examples/cmp_nan.rs:8:5
|
8 | x == std::f32::NAN;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:9:5
--> examples/cmp_nan.rs:9:5
|
9 | x != std::f32::NAN;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:10:5
--> examples/cmp_nan.rs:10:5
|
10 | x < std::f32::NAN;
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:11:5
--> examples/cmp_nan.rs:11:5
|
11 | x > std::f32::NAN;
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:12:5
--> examples/cmp_nan.rs:12:5
|
12 | x <= std::f32::NAN;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:13:5
--> examples/cmp_nan.rs:13:5
|
13 | x >= std::f32::NAN;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:16:5
--> examples/cmp_nan.rs:16:5
|
16 | y == std::f64::NAN;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:17:5
--> examples/cmp_nan.rs:17:5
|
17 | y != std::f64::NAN;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:18:5
--> examples/cmp_nan.rs:18:5
|
18 | y < std::f64::NAN;
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:19:5
--> examples/cmp_nan.rs:19:5
|
19 | y > std::f64::NAN;
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:20:5
--> examples/cmp_nan.rs:20:5
|
20 | y <= std::f64::NAN;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:21:5
--> examples/cmp_nan.rs:21:5
|
21 | y >= std::f64::NAN;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
= note: `-D cmp-nan` implied by `-D warnings`
error: aborting due to 12 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,6 +1,6 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(cmp_null)]
#![warn(cmp_null)]
#![allow(unused_mut)]
use std::ptr;

View File

@ -1,20 +1,21 @@
error: Comparing with null is better expressed by the .is_null() method
--> $DIR/cmp_null.rs:11:8
--> examples/cmp_null.rs:11:8
|
11 | if p == ptr::null() {
| ^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/cmp_null.rs:3:9
|
3 | #![deny(cmp_null)]
| ^^^^^^^^
= note: `-D cmp-null` implied by `-D warnings`
error: Comparing with null is better expressed by the .is_null() method
--> $DIR/cmp_null.rs:16:8
--> examples/cmp_null.rs:16:8
|
16 | if m == ptr::null_mut() {
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `-D cmp-null` implied by `-D warnings`
error: aborting due to 2 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#[deny(cmp_owned)]
#[warn(cmp_owned)]
#[allow(unnecessary_operation)]
fn main() {
fn with_to_string(x : &str) {

View File

@ -1,46 +1,53 @@
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:8:14
--> examples/cmp_owned.rs:8:14
|
8 | x != "foo".to_string();
| ^^^^^^^^^^^^^^^^^ help: try `"foo"`
|
note: lint level defined here
--> $DIR/cmp_owned.rs:4:8
|
4 | #[deny(cmp_owned)]
| ^^^^^^^^^
= note: `-D cmp-owned` implied by `-D warnings`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:10:9
--> examples/cmp_owned.rs:10:9
|
10 | "foo".to_string() != x;
| ^^^^^^^^^^^^^^^^^ help: try `"foo"`
|
= note: `-D cmp-owned` implied by `-D warnings`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:17:10
--> examples/cmp_owned.rs:17:10
|
17 | x != "foo".to_owned();
| ^^^^^^^^^^^^^^^^ help: try `"foo"`
|
= note: `-D cmp-owned` implied by `-D warnings`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:19:10
--> examples/cmp_owned.rs:19:10
|
19 | x != String::from("foo");
| ^^^^^^^^^^^^^^^^^^^ help: try `"foo"`
|
= note: `-D cmp-owned` implied by `-D warnings`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:23:5
--> examples/cmp_owned.rs:23:5
|
23 | Foo.to_owned() == Foo;
| ^^^^^^^^^^^^^^ help: try `Foo`
|
= note: `-D cmp-owned` implied by `-D warnings`
warning: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:30:9
error: this creates an owned instance just for comparison
--> examples/cmp_owned.rs:30:9
|
30 | self.to_owned() == *other
| ^^^^^^^^^^^^^^^ try calling implementing the comparison without allocating
|
= note: #[warn(cmp_owned)] on by default
= note: `-D cmp-owned` implied by `-D warnings`
error: aborting due to 5 previous errors
error: aborting due to 6 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#[deny(collapsible_if)]
#[warn(collapsible_if)]
fn main() {
let x = "hello";
let y = "world";

View File

@ -1,5 +1,5 @@
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:8:5
--> examples/collapsible_if.rs:8:5
|
8 | / if x == "hello" {
9 | | if y == "world" {
@ -8,18 +8,14 @@ error: this if statement can be collapsed
12 | | }
| |_____^
|
note: lint level defined here
--> $DIR/collapsible_if.rs:4:8
|
4 | #[deny(collapsible_if)]
| ^^^^^^^^^^^^^^
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| if x == "hello" && y == "world" {
| println!("Hello world!");
| }
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:14:5
--> examples/collapsible_if.rs:14:5
|
14 | / if x == "hello" || x == "world" {
15 | | if y == "world" || y == "hello" {
@ -28,13 +24,14 @@ error: this if statement can be collapsed
18 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
| println!("Hello world!");
| }
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:20:5
--> examples/collapsible_if.rs:20:5
|
20 | / if x == "hello" && x == "world" {
21 | | if y == "world" || y == "hello" {
@ -43,13 +40,14 @@ error: this if statement can be collapsed
24 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| if x == "hello" && x == "world" && (y == "world" || y == "hello") {
| println!("Hello world!");
| }
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:26:5
--> examples/collapsible_if.rs:26:5
|
26 | / if x == "hello" || x == "world" {
27 | | if y == "world" && y == "hello" {
@ -58,13 +56,14 @@ error: this if statement can be collapsed
30 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| if (x == "hello" || x == "world") && y == "world" && y == "hello" {
| println!("Hello world!");
| }
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:32:5
--> examples/collapsible_if.rs:32:5
|
32 | / if x == "hello" && x == "world" {
33 | | if y == "world" && y == "hello" {
@ -73,13 +72,14 @@ error: this if statement can be collapsed
36 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| if x == "hello" && x == "world" && y == "world" && y == "hello" {
| println!("Hello world!");
| }
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:38:5
--> examples/collapsible_if.rs:38:5
|
38 | / if 42 == 1337 {
39 | | if 'a' != 'A' {
@ -88,13 +88,14 @@ error: this if statement can be collapsed
42 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| if 42 == 1337 && 'a' != 'A' {
| println!("world!")
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:47:12
--> examples/collapsible_if.rs:47:12
|
47 | } else {
| ____________^
@ -104,13 +105,14 @@ error: this `else { if .. }` block can be collapsed
51 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| } else if y == "world" {
| println!("world!")
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:55:12
--> examples/collapsible_if.rs:55:12
|
55 | } else {
| ____________^
@ -120,13 +122,14 @@ error: this `else { if .. }` block can be collapsed
59 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| } else if let Some(42) = Some(42) {
| println!("world!")
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:63:12
--> examples/collapsible_if.rs:63:12
|
63 | } else {
| ____________^
@ -138,6 +141,7 @@ error: this `else { if .. }` block can be collapsed
70 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| } else if y == "world" {
| println!("world")
@ -147,7 +151,7 @@ help: try
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:74:12
--> examples/collapsible_if.rs:74:12
|
74 | } else {
| ____________^
@ -159,6 +163,7 @@ error: this `else { if .. }` block can be collapsed
81 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| } else if let Some(42) = Some(42) {
| println!("world")
@ -168,7 +173,7 @@ help: try
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:85:12
--> examples/collapsible_if.rs:85:12
|
85 | } else {
| ____________^
@ -180,6 +185,7 @@ error: this `else { if .. }` block can be collapsed
92 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| } else if let Some(42) = Some(42) {
| println!("world")
@ -189,7 +195,7 @@ help: try
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:96:12
--> examples/collapsible_if.rs:96:12
|
96 | } else {
| ____________^
@ -201,6 +207,7 @@ error: this `else { if .. }` block can be collapsed
103 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| } else if x == "hello" {
| println!("world")
@ -210,7 +217,7 @@ help: try
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:107:12
--> examples/collapsible_if.rs:107:12
|
107 | } else {
| ____________^
@ -222,6 +229,7 @@ error: this `else { if .. }` block can be collapsed
114 | | }
| |_____^
|
= note: `-D collapsible-if` implied by `-D warnings`
help: try
| } else if let Some(42) = Some(42) {
| println!("world")
@ -232,3 +240,6 @@ help: try
error: aborting due to 13 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,6 +1,6 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(clippy)]
#![warn(clippy)]
#![allow(unused, needless_pass_by_value)]
#![feature(associated_consts, associated_type_defaults)]

View File

@ -1,127 +1,125 @@
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:9:12
--> examples/complex_types.rs:9:12
|
9 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/complex_types.rs:3:9
|
3 | #![deny(clippy)]
| ^^^^^^
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:10:12
--> examples/complex_types.rs:10:12
|
10 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:13:8
--> examples/complex_types.rs:13:8
|
13 | f: Vec<Vec<Box<(u32, u32, u32, u32)>>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:16:11
--> examples/complex_types.rs:16:11
|
16 | struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:19:11
--> examples/complex_types.rs:19:11
|
19 | Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:20:17
--> examples/complex_types.rs:20:17
|
20 | Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> },
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:24:14
--> examples/complex_types.rs:24:14
|
24 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:25:30
--> examples/complex_types.rs:25:30
|
25 | fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:29:14
--> examples/complex_types.rs:29:14
|
29 | const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:30:14
--> examples/complex_types.rs:30:14
|
30 | type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:31:25
--> examples/complex_types.rs:31:25
|
31 | fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:32:29
--> examples/complex_types.rs:32:29
|
32 | fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:35:15
--> examples/complex_types.rs:35:15
|
35 | fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> { vec![] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:37:14
--> examples/complex_types.rs:37:14
|
37 | fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:40:13
--> examples/complex_types.rs:40:13
|
40 | let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
= note: `-D type-complexity` implied by `-D warnings`
error: aborting due to 15 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -24,8 +24,8 @@ pub enum Abc {
C,
}
#[deny(if_same_then_else)]
#[deny(match_same_arms)]
#[warn(if_same_then_else)]
#[warn(match_same_arms)]
fn if_same_then_else() -> Result<&'static str, ()> {
if true {
Foo { bar: 42 };
@ -350,7 +350,7 @@ fn if_same_then_else() -> Result<&'static str, ()> {
}
}
#[deny(ifs_same_cond)]
#[warn(ifs_same_cond)]
#[allow(if_same_then_else)] // all empty blocks
fn ifs_same_cond() {
let a = 0;

View File

@ -0,0 +1,41 @@
error: This else block is redundant.
--> examples/copies.rs:121:20
|
121 | } else {
| ____________________^
122 | | continue;
123 | | }
| |_____________^
|
= note: `-D needless-continue` implied by `-D warnings`
= help: Consider dropping the else clause and merging the code that follows (in the loop) with the if block, like so:
if true {
break;
// Merged code follows...
}
error: This else block is redundant.
--> examples/copies.rs:131:20
|
131 | } else {
| ____________________^
132 | | continue;
133 | | }
| |_____________^
|
= note: `-D needless-continue` implied by `-D warnings`
= help: Consider dropping the else clause and merging the code that follows (in the loop) with the if block, like so:
if true {
break;
// Merged code follows...
}
error: aborting due to 2 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin, custom_attribute)]
#![plugin(clippy)]
#![allow(clippy)]
#![deny(cyclomatic_complexity)]
#![warn(cyclomatic_complexity)]
#![allow(unused)]
fn main() {

View File

@ -1,5 +1,5 @@
error: the function has a cyclomatic complexity of 28
--> $DIR/cyclomatic_complexity.rs:7:1
--> examples/cyclomatic_complexity.rs:7:1
|
7 | / fn main() {
8 | | if true {
@ -10,15 +10,11 @@ error: the function has a cyclomatic complexity of 28
89 | | }
| |_^
|
note: lint level defined here
--> $DIR/cyclomatic_complexity.rs:4:9
|
4 | #![deny(cyclomatic_complexity)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 7
--> $DIR/cyclomatic_complexity.rs:92:1
--> examples/cyclomatic_complexity.rs:92:1
|
92 | / fn kaboom() {
93 | | let n = 0;
@ -29,30 +25,33 @@ error: the function has a cyclomatic complexity of 7
111 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:138:1
--> examples/cyclomatic_complexity.rs:138:1
|
138 | / fn lots_of_short_circuits() -> bool {
139 | | true && false && true && false && true && false && true
140 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:143:1
--> examples/cyclomatic_complexity.rs:143:1
|
143 | / fn lots_of_short_circuits2() -> bool {
144 | | true || false || true || false || true || false || true
145 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:148:1
--> examples/cyclomatic_complexity.rs:148:1
|
148 | / fn baa() {
149 | | let x = || match 99 {
@ -63,10 +62,11 @@ error: the function has a cyclomatic complexity of 2
163 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:149:13
--> examples/cyclomatic_complexity.rs:149:13
|
149 | let x = || match 99 {
| _____________^
@ -78,10 +78,11 @@ error: the function has a cyclomatic complexity of 2
157 | | };
| |_____^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:166:1
--> examples/cyclomatic_complexity.rs:166:1
|
166 | / fn bar() {
167 | | match 99 {
@ -91,10 +92,11 @@ error: the function has a cyclomatic complexity of 2
171 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:185:1
--> examples/cyclomatic_complexity.rs:185:1
|
185 | / fn barr() {
186 | | match 99 {
@ -105,10 +107,11 @@ error: the function has a cyclomatic complexity of 2
192 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity.rs:195:1
--> examples/cyclomatic_complexity.rs:195:1
|
195 | / fn barr2() {
196 | | match 99 {
@ -119,10 +122,11 @@ error: the function has a cyclomatic complexity of 3
208 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:211:1
--> examples/cyclomatic_complexity.rs:211:1
|
211 | / fn barrr() {
212 | | match 99 {
@ -133,10 +137,11 @@ error: the function has a cyclomatic complexity of 2
218 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity.rs:221:1
--> examples/cyclomatic_complexity.rs:221:1
|
221 | / fn barrr2() {
222 | | match 99 {
@ -147,10 +152,11 @@ error: the function has a cyclomatic complexity of 3
234 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:237:1
--> examples/cyclomatic_complexity.rs:237:1
|
237 | / fn barrrr() {
238 | | match 99 {
@ -161,10 +167,11 @@ error: the function has a cyclomatic complexity of 2
244 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity.rs:247:1
--> examples/cyclomatic_complexity.rs:247:1
|
247 | / fn barrrr2() {
248 | | match 99 {
@ -175,10 +182,11 @@ error: the function has a cyclomatic complexity of 3
260 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:263:1
--> examples/cyclomatic_complexity.rs:263:1
|
263 | / fn cake() {
264 | | if 4 == 5 {
@ -189,10 +197,11 @@ error: the function has a cyclomatic complexity of 2
270 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 4
--> $DIR/cyclomatic_complexity.rs:274:1
--> examples/cyclomatic_complexity.rs:274:1
|
274 | / pub fn read_file(input_path: &str) -> String {
275 | | use std::fs::File;
@ -203,10 +212,11 @@ error: the function has a cyclomatic complexity of 4
300 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:305:1
--> examples/cyclomatic_complexity.rs:305:1
|
305 | / fn void(void: Void) {
306 | | if true {
@ -216,10 +226,11 @@ error: the function has a cyclomatic complexity of 1
310 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:319:1
--> examples/cyclomatic_complexity.rs:319:1
|
319 | / fn try() -> Result<i32, &'static str> {
320 | | match 5 {
@ -229,10 +240,11 @@ error: the function has a cyclomatic complexity of 1
324 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:327:1
--> examples/cyclomatic_complexity.rs:327:1
|
327 | / fn try_again() -> Result<i32, &'static str> {
328 | | let _ = try!(Ok(42));
@ -243,10 +255,11 @@ error: the function has a cyclomatic complexity of 1
340 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:343:1
--> examples/cyclomatic_complexity.rs:343:1
|
343 | / fn early() -> Result<i32, &'static str> {
344 | | return Ok(5);
@ -257,10 +270,11 @@ error: the function has a cyclomatic complexity of 1
353 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 8
--> $DIR/cyclomatic_complexity.rs:356:1
--> examples/cyclomatic_complexity.rs:356:1
|
356 | / fn early_ret() -> i32 {
357 | | let a = if true { 42 } else { return 0; };
@ -271,7 +285,11 @@ error: the function has a cyclomatic complexity of 8
373 | | }
| |_^
|
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: aborting due to 20 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin, custom_attribute)]
#![plugin(clippy)]
#![deny(cyclomatic_complexity)]
#![deny(unused)]
#![warn(cyclomatic_complexity)]
#![warn(unused)]
fn main() {
kaboom();

View File

@ -1,5 +1,5 @@
error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity_attr_used.rs:11:1
--> examples/cyclomatic_complexity_attr_used.rs:11:1
|
11 | / fn kaboom() {
12 | | if 42 == 43 {
@ -10,12 +10,11 @@ error: the function has a cyclomatic complexity of 3
17 | | }
| |_^
|
note: lint level defined here
--> $DIR/cyclomatic_complexity_attr_used.rs:3:9
|
3 | #![deny(cyclomatic_complexity)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: `-D cyclomatic-complexity` implied by `-D warnings`
= help: you could split it up into multiple smaller functions
error: aborting due to previous error
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -3,7 +3,6 @@
#![feature(untagged_unions)]
#![deny(warnings)]
#![allow(dead_code)]
use std::hash::{Hash, Hasher};

View File

@ -0,0 +1,84 @@
error: you are deriving `Hash` but have implemented `PartialEq` explicitly
--> examples/derive.rs:17:10
|
17 | #[derive(Hash)]
| ^^^^
|
= note: `-D derive-hash-xor-eq` implied by `-D warnings`
note: `PartialEq` implemented here
--> examples/derive.rs:20:1
|
20 | / impl PartialEq for Bar {
21 | | fn eq(&self, _: &Bar) -> bool { true }
22 | | }
| |_^
error: you are deriving `Hash` but have implemented `PartialEq` explicitly
--> examples/derive.rs:24:10
|
24 | #[derive(Hash)]
| ^^^^
|
= note: `-D derive-hash-xor-eq` implied by `-D warnings`
note: `PartialEq` implemented here
--> examples/derive.rs:27:1
|
27 | / impl PartialEq<Baz> for Baz {
28 | | fn eq(&self, _: &Baz) -> bool { true }
29 | | }
| |_^
error: you are implementing `Hash` explicitly but have derived `PartialEq`
--> examples/derive.rs:34:1
|
34 | / impl Hash for Bah {
35 | | fn hash<H: Hasher>(&self, _: &mut H) {}
36 | | }
| |_^
|
= note: `-D derive-hash-xor-eq` implied by `-D warnings`
note: `PartialEq` implemented here
--> examples/derive.rs:31:10
|
31 | #[derive(PartialEq)]
| ^^^^^^^^^
error: you are implementing `Clone` explicitly on a `Copy` type
--> examples/derive.rs:41:1
|
41 | / impl Clone for Qux {
42 | | fn clone(&self) -> Self { Qux }
43 | | }
| |_^
|
= note: `-D expl-impl-clone-on-copy` implied by `-D warnings`
note: consider deriving `Clone` or removing `Copy`
--> examples/derive.rs:41:1
|
41 | / impl Clone for Qux {
42 | | fn clone(&self) -> Self { Qux }
43 | | }
| |_^
error: you are implementing `Clone` explicitly on a `Copy` type
--> examples/derive.rs:65:1
|
65 | / impl<'a> Clone for Lt<'a> {
66 | | fn clone(&self) -> Self { unimplemented!() }
67 | | }
| |_^
|
= note: `-D expl-impl-clone-on-copy` implied by `-D warnings`
note: consider deriving `Clone` or removing `Copy`
--> examples/derive.rs:65:1
|
65 | / impl<'a> Clone for Lt<'a> {
66 | | fn clone(&self) -> Self { unimplemented!() }
67 | | }
| |_^
error: aborting due to 5 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,6 +1,6 @@
#![feature(plugin, never_type)]
#![plugin(clippy)]
#![deny(diverging_sub_expression)]
#![warn(diverging_sub_expression)]
#![allow(match_same_arms, logic_bug)]
#[allow(empty_loop)]

View File

@ -0,0 +1,53 @@
error: sub-expression diverges
--> examples/diverging_sub_expression.rs:18:10
|
18 | b || diverge();
| ^^^^^^^^^
|
= note: `-D diverging-sub-expression` implied by `-D warnings`
error: sub-expression diverges
--> examples/diverging_sub_expression.rs:19:10
|
19 | b || A.foo();
| ^^^^^^^
|
= note: `-D diverging-sub-expression` implied by `-D warnings`
error: sub-expression diverges
--> examples/diverging_sub_expression.rs:28:26
|
28 | 6 => true || return,
| ^^^^^^
|
= note: `-D diverging-sub-expression` implied by `-D warnings`
error: sub-expression diverges
--> examples/diverging_sub_expression.rs:29:26
|
29 | 7 => true || continue,
| ^^^^^^^^
|
= note: `-D diverging-sub-expression` implied by `-D warnings`
error: sub-expression diverges
--> examples/diverging_sub_expression.rs:32:26
|
32 | 3 => true || diverge(),
| ^^^^^^^^^
|
= note: `-D diverging-sub-expression` implied by `-D warnings`
error: sub-expression diverges
--> examples/diverging_sub_expression.rs:37:26
|
37 | _ => true || break,
| ^^^^^
|
= note: `-D diverging-sub-expression` implied by `-D warnings`
error: aborting due to 6 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -3,7 +3,7 @@
#![feature(associated_consts)]
#![plugin(clippy)]
#![deny(clippy)]
#![warn(clippy)]
#![allow(dead_code, needless_pass_by_value)]
extern crate collections;

View File

@ -1,61 +1,59 @@
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
--> $DIR/dlist.rs:13:16
--> examples/dlist.rs:13:16
|
13 | type Baz = LinkedList<u8>;
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/dlist.rs:6:9
|
6 | #![deny(clippy)]
| ^^^^^^
= note: `-D linkedlist` implied by `-D warnings`
= help: a VecDeque might work
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
--> $DIR/dlist.rs:14:12
--> examples/dlist.rs:14:12
|
14 | fn foo(LinkedList<u8>);
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
= note: `-D linkedlist` implied by `-D warnings`
= help: a VecDeque might work
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
--> $DIR/dlist.rs:15:24
--> examples/dlist.rs:15:24
|
15 | const BAR : Option<LinkedList<u8>>;
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
= note: `-D linkedlist` implied by `-D warnings`
= help: a VecDeque might work
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
--> $DIR/dlist.rs:26:15
--> examples/dlist.rs:26:15
|
26 | fn foo(_: LinkedList<u8>) {}
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
= note: `-D linkedlist` implied by `-D warnings`
= help: a VecDeque might work
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
--> $DIR/dlist.rs:29:39
--> examples/dlist.rs:29:39
|
29 | pub fn test(my_favourite_linked_list: LinkedList<u8>) {
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
= note: `-D linkedlist` implied by `-D warnings`
= help: a VecDeque might work
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
--> $DIR/dlist.rs:33:29
--> examples/dlist.rs:33:29
|
33 | pub fn test_ret() -> Option<LinkedList<u8>> {
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
= note: `-D linkedlist` implied by `-D warnings`
= help: a VecDeque might work
error: aborting due to 6 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -3,7 +3,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(doc_markdown)]
#![warn(doc_markdown)]
/// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
/// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun

View File

@ -1,182 +1,237 @@
error: you should put `DOC_MARKDOWN` between ticks in the documentation
--> $DIR/doc.rs:1:29
--> examples/doc.rs:1:29
|
1 | //! This file tests for the DOC_MARKDOWN lint
| ^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/doc.rs:6:9
|
6 | #![deny(doc_markdown)]
| ^^^^^^^^^^^^
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `foo_bar` between ticks in the documentation
--> $DIR/doc.rs:8:9
--> examples/doc.rs:8:9
|
8 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
| ^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `foo::bar` between ticks in the documentation
--> $DIR/doc.rs:8:51
--> examples/doc.rs:8:51
|
8 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
| ^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `Foo::some_fun` between ticks in the documentation
--> $DIR/doc.rs:9:84
--> examples/doc.rs:9:84
|
9 | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun
9 | /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun
| ^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `is::a::global:path` between ticks in the documentation
--> $DIR/doc.rs:11:13
--> examples/doc.rs:11:13
|
11 | /// Here be ::is::a::global:path.
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `NotInCodeBlock` between ticks in the documentation
--> $DIR/doc.rs:12:21
--> examples/doc.rs:12:21
|
12 | /// That's not code ~NotInCodeBlock~.
| ^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:13:5
--> examples/doc.rs:13:5
|
13 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:27:5
--> examples/doc.rs:27:5
|
27 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:34:5
--> examples/doc.rs:34:5
|
34 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:48:5
--> examples/doc.rs:48:5
|
48 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `ß_foo` between ticks in the documentation
--> $DIR/doc.rs:57:5
--> examples/doc.rs:57:5
|
57 | /// ß_foo
| ^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `_foo` between ticks in the documentation
--> $DIR/doc.rs:58:5
--> examples/doc.rs:58:5
|
58 | /// _foo
| ^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `foo_ß` between ticks in the documentation
--> $DIR/doc.rs:61:5
--> examples/doc.rs:61:5
|
61 | /// foo_ß
| ^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `foo_` between ticks in the documentation
--> $DIR/doc.rs:62:5
--> examples/doc.rs:62:5
|
62 | /// foo_
| ^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:77:5
--> examples/doc.rs:77:5
|
77 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `link_with_underscores` between ticks in the documentation
--> $DIR/doc.rs:81:22
--> examples/doc.rs:81:22
|
81 | /// This test has [a link_with_underscores][chunked-example] inside it. See #823.
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `inline_link2` between ticks in the documentation
--> $DIR/doc.rs:84:21
--> examples/doc.rs:84:21
|
84 | /// It can also be [inline_link2].
| ^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:94:5
--> examples/doc.rs:94:5
|
94 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `CamelCaseThing` between ticks in the documentation
--> $DIR/doc.rs:107:22
--> examples/doc.rs:107:22
|
107 | /// Not a title #897 CamelCaseThing
| ^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:108:5
--> examples/doc.rs:108:5
|
108 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:115:5
--> examples/doc.rs:115:5
|
115 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:128:5
--> examples/doc.rs:128:5
|
128 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `FooBar` between ticks in the documentation
--> $DIR/doc.rs:139:42
--> examples/doc.rs:139:42
|
139 | /** E.g. serialization of an empty list: FooBar
| ^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `BarQuz` between ticks in the documentation
--> $DIR/doc.rs:144:5
--> examples/doc.rs:144:5
|
144 | And BarQuz too.
| ^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:145:1
--> examples/doc.rs:145:1
|
145 | be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `FooBar` between ticks in the documentation
--> $DIR/doc.rs:150:42
--> examples/doc.rs:150:42
|
150 | /** E.g. serialization of an empty list: FooBar
| ^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `BarQuz` between ticks in the documentation
--> $DIR/doc.rs:155:5
--> examples/doc.rs:155:5
|
155 | And BarQuz too.
| ^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:156:1
--> examples/doc.rs:156:1
|
156 | be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:167:5
--> examples/doc.rs:167:5
|
167 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D doc-markdown` implied by `-D warnings`
error: aborting due to 29 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#[deny(double_neg)]
#[warn(double_neg)]
fn main() {
let x = 1;
-x;

View File

@ -0,0 +1,13 @@
error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op
--> examples/double_neg.rs:9:5
|
9 | --x;
| ^^^
|
= note: `-D double-neg` implied by `-D warnings`
error: aborting due to previous error
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(double_parens)]
#![warn(double_parens)]
#![allow(dead_code)]
fn dummy_fn<T>(_: T) {}

View File

@ -0,0 +1,45 @@
error: Consider removing unnecessary double parentheses
--> examples/double_parens.rs:16:5
|
16 | ((0))
| ^^^^^
|
= note: `-D double-parens` implied by `-D warnings`
error: Consider removing unnecessary double parentheses
--> examples/double_parens.rs:20:14
|
20 | dummy_fn((0));
| ^^^
|
= note: `-D double-parens` implied by `-D warnings`
error: Consider removing unnecessary double parentheses
--> examples/double_parens.rs:24:20
|
24 | x.dummy_method((0));
| ^^^
|
= note: `-D double-parens` implied by `-D warnings`
error: Consider removing unnecessary double parentheses
--> examples/double_parens.rs:28:5
|
28 | ((1, 2))
| ^^^^^^^^
|
= note: `-D double-parens` implied by `-D warnings`
error: Consider removing unnecessary double parentheses
--> examples/double_parens.rs:32:5
|
32 | (())
| ^^^^
|
= note: `-D double-parens` implied by `-D warnings`
error: aborting due to 5 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(drop_copy, forget_copy)]
#![warn(drop_copy, forget_copy)]
#![allow(toplevel_ref_arg, drop_ref, forget_ref, unused_mut)]
use std::mem::{drop, forget};

View File

@ -1,84 +1,83 @@
error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:33:5
--> examples/drop_forget_copy.rs:33:5
|
33 | drop(s1);
| ^^^^^^^^
|
note: lint level defined here
--> $DIR/drop_forget_copy.rs:4:9
|
4 | #![deny(drop_copy, forget_copy)]
| ^^^^^^^^^
= note: `-D drop-copy` implied by `-D warnings`
note: argument has type SomeStruct
--> $DIR/drop_forget_copy.rs:33:10
--> examples/drop_forget_copy.rs:33:10
|
33 | drop(s1);
| ^^
error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:34:5
--> examples/drop_forget_copy.rs:34:5
|
34 | drop(s2);
| ^^^^^^^^
|
= note: `-D drop-copy` implied by `-D warnings`
note: argument has type SomeStruct
--> $DIR/drop_forget_copy.rs:34:10
--> examples/drop_forget_copy.rs:34:10
|
34 | drop(s2);
| ^^
error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:36:5
--> examples/drop_forget_copy.rs:36:5
|
36 | drop(s4);
| ^^^^^^^^
|
= note: `-D drop-copy` implied by `-D warnings`
note: argument has type SomeStruct
--> $DIR/drop_forget_copy.rs:36:10
--> examples/drop_forget_copy.rs:36:10
|
36 | drop(s4);
| ^^
error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:39:5
--> examples/drop_forget_copy.rs:39:5
|
39 | forget(s1);
| ^^^^^^^^^^
|
note: lint level defined here
--> $DIR/drop_forget_copy.rs:4:20
|
4 | #![deny(drop_copy, forget_copy)]
| ^^^^^^^^^^^
= note: `-D forget-copy` implied by `-D warnings`
note: argument has type SomeStruct
--> $DIR/drop_forget_copy.rs:39:12
--> examples/drop_forget_copy.rs:39:12
|
39 | forget(s1);
| ^^
error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:40:5
--> examples/drop_forget_copy.rs:40:5
|
40 | forget(s2);
| ^^^^^^^^^^
|
= note: `-D forget-copy` implied by `-D warnings`
note: argument has type SomeStruct
--> $DIR/drop_forget_copy.rs:40:12
--> examples/drop_forget_copy.rs:40:12
|
40 | forget(s2);
| ^^
error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:42:5
--> examples/drop_forget_copy.rs:42:5
|
42 | forget(s4);
| ^^^^^^^^^^
|
= note: `-D forget-copy` implied by `-D warnings`
note: argument has type SomeStruct
--> $DIR/drop_forget_copy.rs:42:12
--> examples/drop_forget_copy.rs:42:12
|
42 | forget(s4);
| ^^
error: aborting due to 6 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(drop_ref, forget_ref)]
#![warn(drop_ref, forget_ref)]
#![allow(toplevel_ref_arg, similar_names, needless_pass_by_value)]
use std::mem::{drop, forget};

View File

@ -1,228 +1,239 @@
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> $DIR/drop_forget_ref.rs:12:5
--> examples/drop_forget_ref.rs:12:5
|
12 | drop(&SomeStruct);
| ^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/drop_forget_ref.rs:4:9
|
4 | #![deny(drop_ref, forget_ref)]
| ^^^^^^^^
= note: `-D drop-ref` implied by `-D warnings`
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:12:10
--> examples/drop_forget_ref.rs:12:10
|
12 | drop(&SomeStruct);
| ^^^^^^^^^^^
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/drop_forget_ref.rs:13:5
--> examples/drop_forget_ref.rs:13:5
|
13 | forget(&SomeStruct);
| ^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/drop_forget_ref.rs:4:19
|
4 | #![deny(drop_ref, forget_ref)]
| ^^^^^^^^^^
= note: `-D forget-ref` implied by `-D warnings`
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:13:12
--> examples/drop_forget_ref.rs:13:12
|
13 | forget(&SomeStruct);
| ^^^^^^^^^^^
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> $DIR/drop_forget_ref.rs:16:5
--> examples/drop_forget_ref.rs:16:5
|
16 | drop(&owned1);
| ^^^^^^^^^^^^^
|
= note: `-D drop-ref` implied by `-D warnings`
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:16:10
--> examples/drop_forget_ref.rs:16:10
|
16 | drop(&owned1);
| ^^^^^^^
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> $DIR/drop_forget_ref.rs:17:5
--> examples/drop_forget_ref.rs:17:5
|
17 | drop(&&owned1);
| ^^^^^^^^^^^^^^
|
= note: `-D drop-ref` implied by `-D warnings`
note: argument has type &&SomeStruct
--> $DIR/drop_forget_ref.rs:17:10
--> examples/drop_forget_ref.rs:17:10
|
17 | drop(&&owned1);
| ^^^^^^^^
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> $DIR/drop_forget_ref.rs:18:5
--> examples/drop_forget_ref.rs:18:5
|
18 | drop(&mut owned1);
| ^^^^^^^^^^^^^^^^^
|
= note: `-D drop-ref` implied by `-D warnings`
note: argument has type &mut SomeStruct
--> $DIR/drop_forget_ref.rs:18:10
--> examples/drop_forget_ref.rs:18:10
|
18 | drop(&mut owned1);
| ^^^^^^^^^^^
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/drop_forget_ref.rs:21:5
--> examples/drop_forget_ref.rs:21:5
|
21 | forget(&owned2);
| ^^^^^^^^^^^^^^^
|
= note: `-D forget-ref` implied by `-D warnings`
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:21:12
--> examples/drop_forget_ref.rs:21:12
|
21 | forget(&owned2);
| ^^^^^^^
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/drop_forget_ref.rs:22:5
--> examples/drop_forget_ref.rs:22:5
|
22 | forget(&&owned2);
| ^^^^^^^^^^^^^^^^
|
= note: `-D forget-ref` implied by `-D warnings`
note: argument has type &&SomeStruct
--> $DIR/drop_forget_ref.rs:22:12
--> examples/drop_forget_ref.rs:22:12
|
22 | forget(&&owned2);
| ^^^^^^^^
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/drop_forget_ref.rs:23:5
--> examples/drop_forget_ref.rs:23:5
|
23 | forget(&mut owned2);
| ^^^^^^^^^^^^^^^^^^^
|
= note: `-D forget-ref` implied by `-D warnings`
note: argument has type &mut SomeStruct
--> $DIR/drop_forget_ref.rs:23:12
--> examples/drop_forget_ref.rs:23:12
|
23 | forget(&mut owned2);
| ^^^^^^^^^^^
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> $DIR/drop_forget_ref.rs:27:5
--> examples/drop_forget_ref.rs:27:5
|
27 | drop(reference1);
| ^^^^^^^^^^^^^^^^
|
= note: `-D drop-ref` implied by `-D warnings`
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:27:10
--> examples/drop_forget_ref.rs:27:10
|
27 | drop(reference1);
| ^^^^^^^^^^
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/drop_forget_ref.rs:28:5
--> examples/drop_forget_ref.rs:28:5
|
28 | forget(&*reference1);
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `-D forget-ref` implied by `-D warnings`
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:28:12
--> examples/drop_forget_ref.rs:28:12
|
28 | forget(&*reference1);
| ^^^^^^^^^^^^
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> $DIR/drop_forget_ref.rs:31:5
--> examples/drop_forget_ref.rs:31:5
|
31 | drop(reference2);
| ^^^^^^^^^^^^^^^^
|
= note: `-D drop-ref` implied by `-D warnings`
note: argument has type &mut SomeStruct
--> $DIR/drop_forget_ref.rs:31:10
--> examples/drop_forget_ref.rs:31:10
|
31 | drop(reference2);
| ^^^^^^^^^^
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/drop_forget_ref.rs:33:5
--> examples/drop_forget_ref.rs:33:5
|
33 | forget(reference3);
| ^^^^^^^^^^^^^^^^^^
|
= note: `-D forget-ref` implied by `-D warnings`
note: argument has type &mut SomeStruct
--> $DIR/drop_forget_ref.rs:33:12
--> examples/drop_forget_ref.rs:33:12
|
33 | forget(reference3);
| ^^^^^^^^^^
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> $DIR/drop_forget_ref.rs:36:5
--> examples/drop_forget_ref.rs:36:5
|
36 | drop(reference4);
| ^^^^^^^^^^^^^^^^
|
= note: `-D drop-ref` implied by `-D warnings`
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:36:10
--> examples/drop_forget_ref.rs:36:10
|
36 | drop(reference4);
| ^^^^^^^^^^
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/drop_forget_ref.rs:37:5
--> examples/drop_forget_ref.rs:37:5
|
37 | forget(reference4);
| ^^^^^^^^^^^^^^^^^^
|
= note: `-D forget-ref` implied by `-D warnings`
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:37:12
--> examples/drop_forget_ref.rs:37:12
|
37 | forget(reference4);
| ^^^^^^^^^^
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> $DIR/drop_forget_ref.rs:42:5
--> examples/drop_forget_ref.rs:42:5
|
42 | drop(&val);
| ^^^^^^^^^^
|
= note: `-D drop-ref` implied by `-D warnings`
note: argument has type &T
--> $DIR/drop_forget_ref.rs:42:10
--> examples/drop_forget_ref.rs:42:10
|
42 | drop(&val);
| ^^^^
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/drop_forget_ref.rs:48:5
--> examples/drop_forget_ref.rs:48:5
|
48 | forget(&val);
| ^^^^^^^^^^^^
|
= note: `-D forget-ref` implied by `-D warnings`
note: argument has type &T
--> $DIR/drop_forget_ref.rs:48:12
--> examples/drop_forget_ref.rs:48:12
|
48 | forget(&val);
| ^^^^
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> $DIR/drop_forget_ref.rs:56:5
--> examples/drop_forget_ref.rs:56:5
|
56 | std::mem::drop(&SomeStruct);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D drop-ref` implied by `-D warnings`
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:56:20
--> examples/drop_forget_ref.rs:56:20
|
56 | std::mem::drop(&SomeStruct);
| ^^^^^^^^^^^
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing.
--> $DIR/drop_forget_ref.rs:59:5
--> examples/drop_forget_ref.rs:59:5
|
59 | std::mem::forget(&SomeStruct);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D forget-ref` implied by `-D warnings`
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:59:22
--> examples/drop_forget_ref.rs:59:22
|
59 | std::mem::forget(&SomeStruct);
| ^^^^^^^^^^^
error: aborting due to 18 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(duplicate_underscore_argument)]
#![warn(duplicate_underscore_argument)]
#[allow(dead_code, unused)]
fn join_the_dark_side(darth: i32, _darth: i32) {}

View File

@ -1,14 +1,13 @@
error: `darth` already exists, having another argument having almost the same name makes code comprehension and documentation more difficult
--> $DIR/duplicate_underscore_argument.rs:7:23
--> examples/duplicate_underscore_argument.rs:7:23
|
7 | fn join_the_dark_side(darth: i32, _darth: i32) {}
| ^^^^^
|
note: lint level defined here
--> $DIR/duplicate_underscore_argument.rs:4:9
|
4 | #![deny(duplicate_underscore_argument)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `-D duplicate-underscore-argument` implied by `-D warnings`
error: aborting due to previous error
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -2,7 +2,7 @@
#![plugin(clippy)]
#![allow(dead_code)]
#![deny(empty_enum)]
#![warn(empty_enum)]
enum Empty {}

View File

@ -1,19 +1,18 @@
error: enum with no variants
--> $DIR/empty_enum.rs:7:1
--> examples/empty_enum.rs:7:1
|
7 | enum Empty {}
| ^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/empty_enum.rs:5:9
|
5 | #![deny(empty_enum)]
| ^^^^^^^^^^
= note: `-D empty-enum` implied by `-D warnings`
help: consider using the uninhabited type `!` or a wrapper around it
--> $DIR/empty_enum.rs:7:1
--> examples/empty_enum.rs:7:1
|
7 | enum Empty {}
| ^^^^^^^^^^^^^
error: aborting due to previous error
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -2,7 +2,7 @@
#![plugin(clippy)]
#![allow(unused, needless_pass_by_value)]
#![deny(map_entry)]
#![warn(map_entry)]
use std::collections::{BTreeMap, HashMap};
use std::hash::Hash;

View File

@ -1,50 +1,61 @@
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:13:5
--> examples/entry.rs:13:5
|
13 | if !m.contains_key(&k) { m.insert(k, v); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k).or_insert(v)`
|
note: lint level defined here
--> $DIR/entry.rs:5:9
|
5 | #![deny(map_entry)]
| ^^^^^^^^^
= note: `-D map-entry` implied by `-D warnings`
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:17:5
--> examples/entry.rs:17:5
|
17 | if !m.contains_key(&k) { foo(); m.insert(k, v); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)`
|
= note: `-D map-entry` implied by `-D warnings`
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:21:5
--> examples/entry.rs:21:5
|
21 | if !m.contains_key(&k) { m.insert(k, v) } else { None };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)`
|
= note: `-D map-entry` implied by `-D warnings`
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:25:5
--> examples/entry.rs:25:5
|
25 | if m.contains_key(&k) { None } else { m.insert(k, v) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)`
|
= note: `-D map-entry` implied by `-D warnings`
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:29:5
--> examples/entry.rs:29:5
|
29 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)`
|
= note: `-D map-entry` implied by `-D warnings`
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:33:5
--> examples/entry.rs:33:5
|
33 | if m.contains_key(&k) { None } else { foo(); m.insert(k, v) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)`
|
= note: `-D map-entry` implied by `-D warnings`
error: usage of `contains_key` followed by `insert` on a `BTreeMap`
--> $DIR/entry.rs:37:5
--> examples/entry.rs:37:5
|
37 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)`
|
= note: `-D map-entry` implied by `-D warnings`
error: aborting due to 7 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,6 +1,6 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(clippy, clippy_pedantic)]
#![warn(clippy, clippy_pedantic)]
#![allow(unused_imports, dead_code, missing_docs_in_private_items)]
use std::cmp::Ordering::*;

View File

@ -0,0 +1,21 @@
error: don't use glob imports for enum variants
--> examples/enum_glob_use.rs:6:1
|
6 | use std::cmp::Ordering::*;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D enum-glob-use` implied by `-D warnings`
error: don't use glob imports for enum variants
--> examples/enum_glob_use.rs:12:1
|
12 | use self::Enum::*;
| ^^^^^^^^^^^^^^^^^^
|
= note: `-D enum-glob-use` implied by `-D warnings`
error: aborting due to 2 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,6 +1,6 @@
#![feature(plugin, non_ascii_idents)]
#![plugin(clippy)]
#![deny(clippy, pub_enum_variant_names)]
#![warn(clippy, pub_enum_variant_names)]
enum FakeCallType {
CALL, CREATE

View File

@ -1,42 +1,37 @@
error: Variant name ends with the enum's name
--> $DIR/enum_variants.rs:14:5
--> examples/enum_variants.rs:14:5
|
14 | cFoo,
| ^^^^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/enum_variants.rs:3:9
|
3 | #![deny(clippy, pub_enum_variant_names)]
| ^^^^^^
= note: `-D enum-variant-names` implied by `-D warnings`
error: Variant name starts with the enum's name
--> $DIR/enum_variants.rs:25:5
--> examples/enum_variants.rs:25:5
|
25 | FoodGood,
| ^^^^^^^^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= note: `-D enum-variant-names` implied by `-D warnings`
error: Variant name starts with the enum's name
--> $DIR/enum_variants.rs:26:5
--> examples/enum_variants.rs:26:5
|
26 | FoodMiddle,
| ^^^^^^^^^^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= note: `-D enum-variant-names` implied by `-D warnings`
error: Variant name starts with the enum's name
--> $DIR/enum_variants.rs:27:5
--> examples/enum_variants.rs:27:5
|
27 | FoodBad,
| ^^^^^^^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= note: `-D enum-variant-names` implied by `-D warnings`
error: All variants have the same prefix: `Food`
--> $DIR/enum_variants.rs:24:1
--> examples/enum_variants.rs:24:1
|
24 | / enum Food {
25 | | FoodGood,
@ -45,11 +40,11 @@ error: All variants have the same prefix: `Food`
28 | | }
| |_^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= note: `-D enum-variant-names` implied by `-D warnings`
= help: remove the prefixes and use full paths to the variants instead of glob imports
error: All variants have the same prefix: `CallType`
--> $DIR/enum_variants.rs:34:1
--> examples/enum_variants.rs:34:1
|
34 | / enum BadCallType {
35 | | CallTypeCall,
@ -58,11 +53,11 @@ error: All variants have the same prefix: `CallType`
38 | | }
| |_^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= note: `-D enum-variant-names` implied by `-D warnings`
= help: remove the prefixes and use full paths to the variants instead of glob imports
error: All variants have the same prefix: `Constant`
--> $DIR/enum_variants.rs:45:1
--> examples/enum_variants.rs:45:1
|
45 | / enum Consts {
46 | | ConstantInt,
@ -71,11 +66,11 @@ error: All variants have the same prefix: `Constant`
49 | | }
| |_^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= note: `-D enum-variant-names` implied by `-D warnings`
= help: remove the prefixes and use full paths to the variants instead of glob imports
error: All variants have the same prefix: `With`
--> $DIR/enum_variants.rs:78:1
--> examples/enum_variants.rs:78:1
|
78 | / enum Seallll {
79 | | WithOutCake,
@ -84,11 +79,11 @@ error: All variants have the same prefix: `With`
82 | | }
| |_^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= note: `-D enum-variant-names` implied by `-D warnings`
= help: remove the prefixes and use full paths to the variants instead of glob imports
error: All variants have the same prefix: `Prefix`
--> $DIR/enum_variants.rs:84:1
--> examples/enum_variants.rs:84:1
|
84 | / enum NonCaps {
85 | | Prefix的,
@ -97,11 +92,11 @@ error: All variants have the same prefix: `Prefix`
88 | | }
| |_^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= note: `-D enum-variant-names` implied by `-D warnings`
= help: remove the prefixes and use full paths to the variants instead of glob imports
error: All variants have the same prefix: `With`
--> $DIR/enum_variants.rs:90:1
--> examples/enum_variants.rs:90:1
|
90 | / pub enum PubSeall {
91 | | WithOutCake,
@ -110,12 +105,11 @@ error: All variants have the same prefix: `With`
94 | | }
| |_^
|
note: lint level defined here
--> $DIR/enum_variants.rs:3:17
|
3 | #![deny(clippy, pub_enum_variant_names)]
| ^^^^^^^^^^^^^^^^^^^^^^
= note: `-D pub-enum-variant-names` implied by `-D warnings`
= help: remove the prefixes and use full paths to the variants instead of glob imports
error: aborting due to 10 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
// ignore-x86
#![feature(plugin, associated_consts)]
#![plugin(clippy)]
#![deny(clippy)]
#![warn(clippy)]
#![allow(unused)]

View File

@ -1,71 +1,69 @@
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:10:5
--> examples/enums_clike.rs:10:5
|
10 | X = 0x1_0000_0000,
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/enums_clike.rs:4:9
|
4 | #![deny(clippy)]
| ^^^^^^
= note: `-D enum-clike-unportable-variant` implied by `-D warnings`
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:17:5
--> examples/enums_clike.rs:17:5
|
17 | X = 0x1_0000_0000,
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
= note: `-D enum-clike-unportable-variant` implied by `-D warnings`
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:20:5
--> examples/enums_clike.rs:20:5
|
20 | A = 0xFFFF_FFFF,
| ^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
= note: `-D enum-clike-unportable-variant` implied by `-D warnings`
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:27:5
--> examples/enums_clike.rs:27:5
|
27 | Z = 0xFFFF_FFFF,
| ^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
= note: `-D enum-clike-unportable-variant` implied by `-D warnings`
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:28:5
--> examples/enums_clike.rs:28:5
|
28 | A = 0x1_0000_0000,
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
= note: `-D enum-clike-unportable-variant` implied by `-D warnings`
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:30:5
--> examples/enums_clike.rs:30:5
|
30 | C = (std::i32::MIN as isize) - 1,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
= note: `-D enum-clike-unportable-variant` implied by `-D warnings`
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:36:5
--> examples/enums_clike.rs:36:5
|
36 | Z = 0xFFFF_FFFF,
| ^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
= note: `-D enum-clike-unportable-variant` implied by `-D warnings`
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:37:5
--> examples/enums_clike.rs:37:5
|
37 | A = 0x1_0000_0000,
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
= note: `-D enum-clike-unportable-variant` implied by `-D warnings`
error: aborting due to 8 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,10 +1,10 @@
#![feature(plugin)]
#![plugin(clippy)]
#[deny(eq_op)]
#[warn(eq_op)]
#[allow(identity_op, double_parens, many_single_char_names)]
#[allow(no_effect, unused_variables, unnecessary_operation, short_circuit_statement)]
#[deny(nonminimal_bool)]
#[warn(nonminimal_bool)]
fn main() {
// simple values and comparisons
1 == 1;

View File

@ -1,216 +1,271 @@
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:37:5
--> examples/eq_op.rs:37:5
|
37 | true && true;
| ^^^^^^^^^^^^ help: try `true`
|
note: lint level defined here
--> $DIR/eq_op.rs:7:8
|
7 | #[deny(nonminimal_bool)]
| ^^^^^^^^^^^^^^^
= note: `-D nonminimal-bool` implied by `-D warnings`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:39:5
--> examples/eq_op.rs:39:5
|
39 | true || true;
| ^^^^^^^^^^^^ help: try `true`
|
= note: `-D nonminimal-bool` implied by `-D warnings`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:45:5
--> examples/eq_op.rs:45:5
|
45 | a == b && b == a;
| ^^^^^^^^^^^^^^^^ help: try `a == b`
|
= note: `-D nonminimal-bool` implied by `-D warnings`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:46:5
--> examples/eq_op.rs:46:5
|
46 | a != b && b != a;
| ^^^^^^^^^^^^^^^^ help: try `a != b`
|
= note: `-D nonminimal-bool` implied by `-D warnings`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:47:5
--> examples/eq_op.rs:47:5
|
47 | a < b && b > a;
| ^^^^^^^^^^^^^^ help: try `a < b`
|
= note: `-D nonminimal-bool` implied by `-D warnings`
error: this boolean expression can be simplified
--> $DIR/eq_op.rs:48:5
--> examples/eq_op.rs:48:5
|
48 | a <= b && b >= a;
| ^^^^^^^^^^^^^^^^ help: try `a <= b`
|
= note: `-D nonminimal-bool` implied by `-D warnings`
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:10:5
--> examples/eq_op.rs:10:5
|
10 | 1 == 1;
| ^^^^^^
|
note: lint level defined here
--> $DIR/eq_op.rs:4:8
|
4 | #[deny(eq_op)]
| ^^^^^
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:11:5
--> examples/eq_op.rs:11:5
|
11 | "no" == "no";
| ^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `!=`
--> $DIR/eq_op.rs:13:5
--> examples/eq_op.rs:13:5
|
13 | false != false;
| ^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `<`
--> $DIR/eq_op.rs:14:5
--> examples/eq_op.rs:14:5
|
14 | 1.5 < 1.5;
| ^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `>=`
--> $DIR/eq_op.rs:15:5
--> examples/eq_op.rs:15:5
|
15 | 1u64 >= 1u64;
| ^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `&`
--> $DIR/eq_op.rs:18:5
--> examples/eq_op.rs:18:5
|
18 | (1 as u64) & (1 as u64);
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `^`
--> $DIR/eq_op.rs:19:5
--> examples/eq_op.rs:19:5
|
19 | 1 ^ ((((((1))))));
| ^^^^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `<`
--> $DIR/eq_op.rs:22:5
--> examples/eq_op.rs:22:5
|
22 | (-(2) < -(2));
| ^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:23:5
--> examples/eq_op.rs:23:5
|
23 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `&`
--> $DIR/eq_op.rs:23:6
--> examples/eq_op.rs:23:6
|
23 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
| ^^^^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `&`
--> $DIR/eq_op.rs:23:27
--> examples/eq_op.rs:23:27
|
23 | ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
| ^^^^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:24:5
--> examples/eq_op.rs:24:5
|
24 | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `!=`
--> $DIR/eq_op.rs:27:5
--> examples/eq_op.rs:27:5
|
27 | ([1] != [1]);
| ^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `!=`
--> $DIR/eq_op.rs:28:5
--> examples/eq_op.rs:28:5
|
28 | ((1, 2) != (1, 2));
| ^^^^^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:32:5
--> examples/eq_op.rs:32:5
|
32 | 1 + 1 == 2;
| ^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:33:5
--> examples/eq_op.rs:33:5
|
33 | 1 - 1 == 0;
| ^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `-`
--> $DIR/eq_op.rs:33:5
--> examples/eq_op.rs:33:5
|
33 | 1 - 1 == 0;
| ^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `-`
--> $DIR/eq_op.rs:35:5
--> examples/eq_op.rs:35:5
|
35 | 1 - 1;
| ^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `/`
--> $DIR/eq_op.rs:36:5
--> examples/eq_op.rs:36:5
|
36 | 1 / 1;
| ^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:37:5
--> examples/eq_op.rs:37:5
|
37 | true && true;
| ^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `||`
--> $DIR/eq_op.rs:39:5
--> examples/eq_op.rs:39:5
|
39 | true || true;
| ^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:45:5
--> examples/eq_op.rs:45:5
|
45 | a == b && b == a;
| ^^^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:46:5
--> examples/eq_op.rs:46:5
|
46 | a != b && b != a;
| ^^^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:47:5
--> examples/eq_op.rs:47:5
|
47 | a < b && b > a;
| ^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:48:5
--> examples/eq_op.rs:48:5
|
48 | a <= b && b >= a;
| ^^^^^^^^^^^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:51:5
--> examples/eq_op.rs:51:5
|
51 | a == a;
| ^^^^^^
|
= note: `-D eq-op` implied by `-D warnings`
warning: taken reference of right operand
--> $DIR/eq_op.rs:89:13
error: taken reference of right operand
--> examples/eq_op.rs:89:13
|
89 | let z = x & &y;
| ^^^^--
| |
| help: use the right value directly `y`
|
= note: #[warn(op_ref)] on by default
= note: `-D op-ref` implied by `-D warnings`
error: aborting due to 32 previous errors
error: aborting due to 33 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -2,7 +2,7 @@
#![plugin(clippy)]
#![allow(warnings, clippy)]
#![deny(boxed_local)]
#![warn(boxed_local)]
#[derive(Clone)]
struct A;

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![allow(unknown_lints, unused, no_effect, redundant_closure_call, many_single_char_names, needless_pass_by_value)]
#![deny(redundant_closure)]
#![warn(redundant_closure)]
fn main() {
let a = Some(1u8).map(|a| foo(a));

View File

@ -1,40 +1,45 @@
error: redundant closure found
--> $DIR/eta.rs:7:27
--> examples/eta.rs:7:27
|
7 | let a = Some(1u8).map(|a| foo(a));
| ^^^^^^^^^^ help: remove closure as shown: `foo`
|
note: lint level defined here
--> $DIR/eta.rs:4:9
|
4 | #![deny(redundant_closure)]
| ^^^^^^^^^^^^^^^^^
= note: `-D redundant-closure` implied by `-D warnings`
error: redundant closure found
--> $DIR/eta.rs:8:10
--> examples/eta.rs:8:10
|
8 | meta(|a| foo(a));
| ^^^^^^^^^^ help: remove closure as shown: `foo`
|
= note: `-D redundant-closure` implied by `-D warnings`
error: redundant closure found
--> $DIR/eta.rs:9:27
--> examples/eta.rs:9:27
|
9 | let c = Some(1u8).map(|a| {1+2; foo}(a));
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}`
|
= note: `-D redundant-closure` implied by `-D warnings`
warning: this expression borrows a reference that is immediately dereferenced by the compiler
--> $DIR/eta.rs:11:21
error: this expression borrows a reference that is immediately dereferenced by the compiler
--> examples/eta.rs:11:21
|
11 | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
| ^^^
|
= note: #[warn(needless_borrow)] on by default
= note: `-D needless-borrow` implied by `-D warnings`
error: redundant closure found
--> $DIR/eta.rs:18:27
--> examples/eta.rs:18:27
|
18 | let e = Some(1u8).map(|a| generic(a));
| ^^^^^^^^^^^^^^ help: remove closure as shown: `generic`
|
= note: `-D redundant-closure` implied by `-D warnings`
error: aborting due to 4 previous errors
error: aborting due to 5 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#[deny(eval_order_dependence)]
#[warn(eval_order_dependence)]
#[allow(unused_assignments, unused_variables, many_single_char_names, no_effect, dead_code, blacklisted_name)]
fn main() {
let mut x = 0;

View File

@ -1,55 +1,57 @@
error: unsequenced read of a variable
--> $DIR/eval_order_dependence.rs:8:28
--> examples/eval_order_dependence.rs:8:28
|
8 | let a = { x = 1; 1 } + x;
| ^
|
note: lint level defined here
--> $DIR/eval_order_dependence.rs:4:8
|
4 | #[deny(eval_order_dependence)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: `-D eval-order-dependence` implied by `-D warnings`
note: whether read occurs before this write depends on evaluation order
--> $DIR/eval_order_dependence.rs:8:15
--> examples/eval_order_dependence.rs:8:15
|
8 | let a = { x = 1; 1 } + x;
| ^^^^^
error: unsequenced read of a variable
--> $DIR/eval_order_dependence.rs:11:5
--> examples/eval_order_dependence.rs:11:5
|
11 | x += { x = 20; 2 };
| ^
|
= note: `-D eval-order-dependence` implied by `-D warnings`
note: whether read occurs before this write depends on evaluation order
--> $DIR/eval_order_dependence.rs:11:12
--> examples/eval_order_dependence.rs:11:12
|
11 | x += { x = 20; 2 };
| ^^^^^^
error: unsequenced read of a variable
--> $DIR/eval_order_dependence.rs:17:24
--> examples/eval_order_dependence.rs:17:24
|
17 | let foo = Foo { a: x, .. { x = 6; base } };
| ^
|
= note: `-D eval-order-dependence` implied by `-D warnings`
note: whether read occurs before this write depends on evaluation order
--> $DIR/eval_order_dependence.rs:17:32
--> examples/eval_order_dependence.rs:17:32
|
17 | let foo = Foo { a: x, .. { x = 6; base } };
| ^^^^^
error: unsequenced read of a variable
--> $DIR/eval_order_dependence.rs:21:9
--> examples/eval_order_dependence.rs:21:9
|
21 | x += { x = 20; 2 };
| ^
|
= note: `-D eval-order-dependence` implied by `-D warnings`
note: whether read occurs before this write depends on evaluation order
--> $DIR/eval_order_dependence.rs:21:16
--> examples/eval_order_dependence.rs:21:16
|
21 | x += { x = 20; 2 };
| ^^^^^^
error: aborting due to 4 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(clippy, clippy_pedantic)]
#![warn(clippy, clippy_pedantic)]
#![allow(missing_docs_in_private_items)]
fn main() {

View File

@ -1,5 +1,5 @@
error: called `filter(p).map(q)` on an `Iterator`. This is more succinctly expressed by calling `.filter_map(..)` instead.
--> $DIR/filter_methods.rs:8:21
--> examples/filter_methods.rs:8:21
|
8 | let _: Vec<_> = vec![5; 6].into_iter()
| _____________________^
@ -7,15 +7,10 @@ error: called `filter(p).map(q)` on an `Iterator`. This is more succinctly expre
10 | | .map(|x| x * 2)
| |_____________________________________________^
|
= note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)]
note: lint level defined here
--> $DIR/filter_methods.rs:4:17
|
4 | #![deny(clippy, clippy_pedantic)]
| ^^^^^^^^^^^^^^^
= note: `-D filter-map` implied by `-D warnings`
error: called `filter(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator.
--> $DIR/filter_methods.rs:13:21
--> examples/filter_methods.rs:13:21
|
13 | let _: Vec<_> = vec![5_i8; 6].into_iter()
| _____________________^
@ -23,10 +18,10 @@ error: called `filter(p).flat_map(q)` on an `Iterator`. This is more succinctly
15 | | .flat_map(|x| x.checked_mul(2))
| |_______________________________________________________________^
|
= note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)]
= note: `-D filter-map` implied by `-D warnings`
error: called `filter_map(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator.
--> $DIR/filter_methods.rs:18:21
--> examples/filter_methods.rs:18:21
|
18 | let _: Vec<_> = vec![5_i8; 6].into_iter()
| _____________________^
@ -34,10 +29,10 @@ error: called `filter_map(p).flat_map(q)` on an `Iterator`. This is more succinc
20 | | .flat_map(|x| x.checked_mul(2))
| |_______________________________________________________________^
|
= note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)]
= note: `-D filter-map` implied by `-D warnings`
error: called `filter_map(p).map(q)` on an `Iterator`. This is more succinctly expressed by only calling `.filter_map(..)` instead.
--> $DIR/filter_methods.rs:23:21
--> examples/filter_methods.rs:23:21
|
23 | let _: Vec<_> = vec![5_i8; 6].into_iter()
| _____________________^
@ -45,7 +40,10 @@ error: called `filter_map(p).map(q)` on an `Iterator`. This is more succinctly e
25 | | .map(|x| x.checked_mul(2))
| |__________________________________________________________^
|
= note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)]
= note: `-D filter-map` implied by `-D warnings`
error: aborting due to 4 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(float_cmp)]
#![warn(float_cmp)]
#![allow(unused, no_effect, unnecessary_operation)]
use std::ops::Add;

View File

@ -1,103 +1,109 @@
error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:43:5
--> examples/float_cmp.rs:43:5
|
43 | ONE == 1f32;
| ^^^^^^^^^^^ help: consider comparing them within some error `(ONE - 1f32).abs() < error`
|
note: lint level defined here
--> $DIR/float_cmp.rs:4:9
|
4 | #![deny(float_cmp)]
| ^^^^^^^^^
= note: `-D float-cmp` implied by `-D warnings`
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:43:5
--> examples/float_cmp.rs:43:5
|
43 | ONE == 1f32;
| ^^^^^^^^^^^
error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:44:5
--> examples/float_cmp.rs:44:5
|
44 | ONE == 1.0 + 0.0;
| ^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(ONE - (1.0 + 0.0)).abs() < error`
|
= note: `-D float-cmp` implied by `-D warnings`
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:44:5
--> examples/float_cmp.rs:44:5
|
44 | ONE == 1.0 + 0.0;
| ^^^^^^^^^^^^^^^^
error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:45:5
--> examples/float_cmp.rs:45:5
|
45 | ONE + ONE == ZERO + ONE + ONE;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(ONE + ONE - (ZERO + ONE + ONE)).abs() < error`
|
= note: `-D float-cmp` implied by `-D warnings`
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:45:5
--> examples/float_cmp.rs:45:5
|
45 | ONE + ONE == ZERO + ONE + ONE;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:46:5
--> examples/float_cmp.rs:46:5
|
46 | ONE != 2.0;
| ^^^^^^^^^^ help: consider comparing them within some error `(ONE - 2.0).abs() < error`
|
= note: `-D float-cmp` implied by `-D warnings`
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:46:5
--> examples/float_cmp.rs:46:5
|
46 | ONE != 2.0;
| ^^^^^^^^^^
error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:48:5
--> examples/float_cmp.rs:48:5
|
48 | twice(ONE) != ONE;
| ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(twice(ONE) - ONE).abs() < error`
|
= note: `-D float-cmp` implied by `-D warnings`
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:48:5
--> examples/float_cmp.rs:48:5
|
48 | twice(ONE) != ONE;
| ^^^^^^^^^^^^^^^^^
error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:49:5
--> examples/float_cmp.rs:49:5
|
49 | ONE as f64 != 2.0;
| ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(ONE as f64 - 2.0).abs() < error`
|
= note: `-D float-cmp` implied by `-D warnings`
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:49:5
--> examples/float_cmp.rs:49:5
|
49 | ONE as f64 != 2.0;
| ^^^^^^^^^^^^^^^^^
error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:54:5
--> examples/float_cmp.rs:54:5
|
54 | x == 1.0;
| ^^^^^^^^ help: consider comparing them within some error `(x - 1.0).abs() < error`
|
= note: `-D float-cmp` implied by `-D warnings`
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:54:5
--> examples/float_cmp.rs:54:5
|
54 | x == 1.0;
| ^^^^^^^^
error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:57:5
--> examples/float_cmp.rs:57:5
|
57 | twice(x) != twice(ONE as f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(twice(x) - twice(ONE as f64)).abs() < error`
|
= note: `-D float-cmp` implied by `-D warnings`
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:57:5
--> examples/float_cmp.rs:57:5
|
57 | twice(x) != twice(ONE as f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -7,7 +7,7 @@ use std::rc::Rc;
static STATIC: [usize; 4] = [ 0, 1, 8, 16 ];
const CONST: [usize; 4] = [ 0, 1, 8, 16 ];
#[deny(clippy)]
#[warn(clippy)]
fn for_loop_over_option_and_result() {
let option = Some(1);
let result = option.ok_or("x not found");
@ -72,8 +72,8 @@ impl Unrelated {
}
}
#[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
#[deny(unused_collect)]
#[warn(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
#[warn(unused_collect)]
#[allow(linkedlist, shadow_unrelated, unnecessary_mut_passed, cyclomatic_complexity, similar_names)]
#[allow(many_single_char_names)]
fn main() {

View File

@ -1,453 +1,450 @@
error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement.
--> $DIR/for_loop.rs:17:14
--> examples/for_loop.rs:17:14
|
17 | for x in option {
| ^^^^^^
|
= note: #[deny(for_loop_over_option)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/for_loop.rs:10:8
|
10 | #[deny(clippy)]
| ^^^^^^
= note: `-D for-loop-over-option` implied by `-D warnings`
= help: consider replacing `for x in option` with `if let Some(x) = option`
error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement.
--> $DIR/for_loop.rs:22:14
--> examples/for_loop.rs:22:14
|
22 | for x in result {
| ^^^^^^
|
= note: #[deny(for_loop_over_result)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/for_loop.rs:10:8
|
10 | #[deny(clippy)]
| ^^^^^^
= note: `-D for-loop-over-result` implied by `-D warnings`
= help: consider replacing `for x in result` with `if let Ok(x) = result`
error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement.
--> $DIR/for_loop.rs:26:14
--> examples/for_loop.rs:26:14
|
26 | for x in option.ok_or("x not found") {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(for_loop_over_result)] implied by #[deny(clippy)]
= note: `-D for-loop-over-result` implied by `-D warnings`
= help: consider replacing `for x in option.ok_or("x not found")` with `if let Ok(x) = option.ok_or("x not found")`
error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
--> $DIR/for_loop.rs:31:5
--> examples/for_loop.rs:31:5
|
31 | / for x in v.iter().next() {
32 | | println!("{}", x);
33 | | }
| |_____^
|
= note: #[deny(iter_next_loop)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/for_loop.rs:10:8
|
10 | #[deny(clippy)]
| ^^^^^^
= note: `-D iter-next-loop` implied by `-D warnings`
error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement.
--> $DIR/for_loop.rs:36:14
--> examples/for_loop.rs:36:14
|
36 | for x in v.iter().next().and(Some(0)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(for_loop_over_option)] implied by #[deny(clippy)]
= note: `-D for-loop-over-option` implied by `-D warnings`
= help: consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))`
error: for loop over `v.iter().next().ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement.
--> $DIR/for_loop.rs:40:14
--> examples/for_loop.rs:40:14
|
40 | for x in v.iter().next().ok_or("x not found") {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(for_loop_over_result)] implied by #[deny(clippy)]
= note: `-D for-loop-over-result` implied by `-D warnings`
= help: consider replacing `for x in v.iter().next().ok_or("x not found")` with `if let Ok(x) = v.iter().next().ok_or("x not found")`
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:84:5
--> examples/for_loop.rs:84:5
|
84 | / for i in 0..vec.len() {
85 | | println!("{}", vec[i]);
86 | | }
| |_____^
|
note: lint level defined here
--> $DIR/for_loop.rs:75:8
|
75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^^
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for <item> in &vec {
warning: unused variable: `i`
--> $DIR/for_loop.rs:88:9
error: unused variable: `i`
--> examples/for_loop.rs:88:9
|
88 | for i in 0..vec.len() {
| ^
|
= note: #[warn(unused_variables)] on by default
= note: `-D unused-variables` implied by `-D warnings`
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:93:5
--> examples/for_loop.rs:93:5
|
93 | for i in 0..vec.len() { let _ = vec[i]; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for <item> in &vec { let _ = vec[i]; }
error: the loop variable `j` is only used to index `STATIC`.
--> $DIR/for_loop.rs:96:5
--> examples/for_loop.rs:96:5
|
96 | / for j in 0..4 {
97 | | println!("{:?}", STATIC[j]);
98 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for <item> in STATIC.iter().take(4) {
error: the loop variable `j` is only used to index `CONST`.
--> $DIR/for_loop.rs:100:5
--> examples/for_loop.rs:100:5
|
100 | / for j in 0..4 {
101 | | println!("{:?}", CONST[j]);
102 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for <item> in CONST.iter().take(4) {
error: the loop variable `i` is used to index `vec`
--> $DIR/for_loop.rs:104:5
--> examples/for_loop.rs:104:5
|
104 | / for i in 0..vec.len() {
105 | | println!("{} {}", vec[i], i);
106 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for (i, <item>) in vec.iter().enumerate() {
error: the loop variable `i` is only used to index `vec2`.
--> $DIR/for_loop.rs:111:5
--> examples/for_loop.rs:111:5
|
111 | / for i in 0..vec.len() {
112 | | println!("{}", vec2[i]);
113 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for <item> in vec2.iter().take(vec.len()) {
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:115:5
--> examples/for_loop.rs:115:5
|
115 | / for i in 5..vec.len() {
116 | | println!("{}", vec[i]);
117 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for <item> in vec.iter().skip(5) {
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:119:5
--> examples/for_loop.rs:119:5
|
119 | / for i in 0..MAX_LEN {
120 | | println!("{}", vec[i]);
121 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for <item> in vec.iter().take(MAX_LEN) {
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:123:5
--> examples/for_loop.rs:123:5
|
123 | / for i in 0...MAX_LEN {
124 | | println!("{}", vec[i]);
125 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for <item> in vec.iter().take(MAX_LEN + 1) {
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:127:5
--> examples/for_loop.rs:127:5
|
127 | / for i in 5..10 {
128 | | println!("{}", vec[i]);
129 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for <item> in vec.iter().take(10).skip(5) {
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:131:5
--> examples/for_loop.rs:131:5
|
131 | / for i in 5...10 {
132 | | println!("{}", vec[i]);
133 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for <item> in vec.iter().take(10 + 1).skip(5) {
error: the loop variable `i` is used to index `vec`
--> $DIR/for_loop.rs:135:5
--> examples/for_loop.rs:135:5
|
135 | / for i in 5..vec.len() {
136 | | println!("{} {}", vec[i], i);
137 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for (i, <item>) in vec.iter().enumerate().skip(5) {
error: the loop variable `i` is used to index `vec`
--> $DIR/for_loop.rs:139:5
--> examples/for_loop.rs:139:5
|
139 | / for i in 5..10 {
140 | | println!("{} {}", vec[i], i);
141 | | }
| |_____^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
| for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:143:5
--> examples/for_loop.rs:143:5
|
143 | / for i in 10..0 {
144 | | println!("{}", i);
145 | | }
| |_____^
|
note: lint level defined here
--> $DIR/for_loop.rs:75:90
|
75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^
= note: `-D reverse-range-loop` implied by `-D warnings`
help: consider using the following if you are attempting to iterate over this range in reverse
| for i in (0..10).rev() {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:147:5
--> examples/for_loop.rs:147:5
|
147 | / for i in 10...0 {
148 | | println!("{}", i);
149 | | }
| |_____^
|
= note: `-D reverse-range-loop` implied by `-D warnings`
help: consider using the following if you are attempting to iterate over this range in reverse
| for i in (0...10).rev() {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:151:5
--> examples/for_loop.rs:151:5
|
151 | / for i in MAX_LEN..0 {
152 | | println!("{}", i);
153 | | }
| |_____^
|
= note: `-D reverse-range-loop` implied by `-D warnings`
help: consider using the following if you are attempting to iterate over this range in reverse
| for i in (0..MAX_LEN).rev() {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:155:5
--> examples/for_loop.rs:155:5
|
155 | / for i in 5..5 {
156 | | println!("{}", i);
157 | | }
| |_____^
|
= note: `-D reverse-range-loop` implied by `-D warnings`
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:176:5
--> examples/for_loop.rs:176:5
|
176 | / for i in 10..5+4 {
177 | | println!("{}", i);
178 | | }
| |_____^
|
= note: `-D reverse-range-loop` implied by `-D warnings`
help: consider using the following if you are attempting to iterate over this range in reverse
| for i in (5+4..10).rev() {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:180:5
--> examples/for_loop.rs:180:5
|
180 | / for i in (5+2)..(3-1) {
181 | | println!("{}", i);
182 | | }
| |_____^
|
= note: `-D reverse-range-loop` implied by `-D warnings`
help: consider using the following if you are attempting to iterate over this range in reverse
| for i in ((3-1)..(5+2)).rev() {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:184:5
--> examples/for_loop.rs:184:5
|
184 | / for i in (5+2)..(8-1) {
185 | | println!("{}", i);
186 | | }
| |_____^
|
= note: `-D reverse-range-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:207:15
--> examples/for_loop.rs:207:15
|
207 | for _v in vec.iter() { }
| ^^^^^^^^^^ help: to write this more concisely, try `&vec`
|
note: lint level defined here
--> $DIR/for_loop.rs:75:29
|
75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:209:15
--> examples/for_loop.rs:209:15
|
209 | for _v in vec.iter_mut() { }
| ^^^^^^^^^^^^^^ help: to write this more concisely, try `&mut vec`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over containers instead of using explicit iteration methods`
--> $DIR/for_loop.rs:212:15
--> examples/for_loop.rs:212:15
|
212 | for _v in out_vec.into_iter() { }
| ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `out_vec`
|
note: lint level defined here
--> $DIR/for_loop.rs:75:49
|
75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: `-D explicit-into-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:215:15
--> examples/for_loop.rs:215:15
|
215 | for _v in array.into_iter() {}
| ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `&array`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:220:15
--> examples/for_loop.rs:220:15
|
220 | for _v in [1, 2, 3].iter() { }
| ^^^^^^^^^^^^^^^^ help: to write this more concisely, try `&[1, 2, 3]`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:224:15
--> examples/for_loop.rs:224:15
|
224 | for _v in [0; 32].iter() {}
| ^^^^^^^^^^^^^^ help: to write this more concisely, try `&[0; 32]`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:229:15
--> examples/for_loop.rs:229:15
|
229 | for _v in ll.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&ll`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:232:15
--> examples/for_loop.rs:232:15
|
232 | for _v in vd.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&vd`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:235:15
--> examples/for_loop.rs:235:15
|
235 | for _v in bh.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&bh`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:238:15
--> examples/for_loop.rs:238:15
|
238 | for _v in hm.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&hm`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:241:15
--> examples/for_loop.rs:241:15
|
241 | for _v in bt.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&bt`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:244:15
--> examples/for_loop.rs:244:15
|
244 | for _v in hs.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&hs`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:247:15
--> examples/for_loop.rs:247:15
|
247 | for _v in bs.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&bs`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
--> $DIR/for_loop.rs:249:5
--> examples/for_loop.rs:249:5
|
249 | for _v in vec.iter().next() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:75:74
|
75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^
= note: `-D iter-next-loop` implied by `-D warnings`
error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator
--> $DIR/for_loop.rs:256:5
--> examples/for_loop.rs:256:5
|
256 | vec.iter().map(|x| out.push(x)).collect::<Vec<_>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:76:8
|
76 | #[deny(unused_collect)]
| ^^^^^^^^^^^^^^
= note: `-D unused-collect` implied by `-D warnings`
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
--> $DIR/for_loop.rs:261:5
--> examples/for_loop.rs:261:5
|
261 | for _v in &vec { _index += 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:75:110
|
75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: `-D explicit-counter-loop` implied by `-D warnings`
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
--> $DIR/for_loop.rs:265:5
--> examples/for_loop.rs:265:5
|
265 | for _v in &vec { _index += 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D explicit-counter-loop` implied by `-D warnings`
error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:325:5
--> examples/for_loop.rs:325:5
|
325 | / for (_, v) in &m {
326 | | let _v = v;
327 | | }
| |_____^
|
note: lint level defined here
--> $DIR/for_loop.rs:75:133
|
75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^
= note: `-D for-kv-map` implied by `-D warnings`
help: use the corresponding method
| for v in m.values() {
error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:330:5
--> examples/for_loop.rs:330:5
|
330 | / for (_, v) in &*m {
331 | | let _v = v;
@ -456,41 +453,48 @@ error: you seem to want to iterate on a map's values
334 | | }
| |_____^
|
= note: `-D for-kv-map` implied by `-D warnings`
help: use the corresponding method
| for v in (*m).values() {
error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:337:5
--> examples/for_loop.rs:337:5
|
337 | / for (_, v) in &mut m {
338 | | let _v = v;
339 | | }
| |_____^
|
= note: `-D for-kv-map` implied by `-D warnings`
help: use the corresponding method
| for v in m.values_mut() {
error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:342:5
--> examples/for_loop.rs:342:5
|
342 | / for (_, v) in &mut *m {
343 | | let _v = v;
344 | | }
| |_____^
|
= note: `-D for-kv-map` implied by `-D warnings`
help: use the corresponding method
| for v in (*m).values_mut() {
error: you seem to want to iterate on a map's keys
--> $DIR/for_loop.rs:348:5
--> examples/for_loop.rs:348:5
|
348 | / for (k, _value) in rm {
349 | | let _k = k;
350 | | }
| |_____^
|
= note: `-D for-kv-map` implied by `-D warnings`
help: use the corresponding method
| for k in rm.keys() {
error: aborting due to 48 previous errors
error: aborting due to 49 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,6 +1,6 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(useless_format)]
#![warn(useless_format)]
fn main() {
format!("foo");

View File

@ -0,0 +1,29 @@
error: useless use of `format!`
--> examples/format.rs:6:5
|
6 | format!("foo");
| ^^^^^^^^^^^^^^^
|
= note: `-D useless-format` implied by `-D warnings`
error: useless use of `format!`
--> examples/format.rs:8:5
|
8 | format!("{}", "foo");
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D useless-format` implied by `-D warnings`
error: useless use of `format!`
--> examples/format.rs:15:5
|
15 | format!("{}", arg);
| ^^^^^^^^^^^^^^^^^^^
|
= note: `-D useless-format` implied by `-D warnings`
error: aborting due to 3 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(clippy)]
#![warn(clippy)]
#![allow(unused_variables)]
#![allow(unused_assignments)]
#![allow(if_same_then_else)]

View File

@ -1,48 +1,43 @@
error: this looks like an `else if` but the `else` is missing
--> $DIR/formatting.rs:15:6
--> examples/formatting.rs:15:6
|
15 | } if foo() {
| ^
|
= note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/formatting.rs:4:9
|
4 | #![deny(clippy)]
| ^^^^^^
= note: `-D suspicious-else-formatting` implied by `-D warnings`
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
error: this looks like an `else if` but the `else` is missing
--> $DIR/formatting.rs:22:10
--> examples/formatting.rs:22:10
|
22 | } if foo() {
| ^
|
= note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)]
= note: `-D suspicious-else-formatting` implied by `-D warnings`
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
error: this looks like an `else if` but the `else` is missing
--> $DIR/formatting.rs:30:10
--> examples/formatting.rs:30:10
|
30 | } if foo() {
| ^
|
= note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)]
= note: `-D suspicious-else-formatting` implied by `-D warnings`
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
error: this is an `else if` but the formatting might hide it
--> $DIR/formatting.rs:39:6
--> examples/formatting.rs:39:6
|
39 | } else
| ______^
40 | | if foo() { // the span of the above error should continue here
| |____^
|
= note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)]
= note: `-D suspicious-else-formatting` implied by `-D warnings`
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
error: this is an `else if` but the formatting might hide it
--> $DIR/formatting.rs:44:6
--> examples/formatting.rs:44:6
|
44 | }
| ______^
@ -50,63 +45,56 @@ error: this is an `else if` but the formatting might hide it
46 | | if foo() { // the span of the above error should continue here
| |____^
|
= note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)]
= note: `-D suspicious-else-formatting` implied by `-D warnings`
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)`
--> $DIR/formatting.rs:71:6
--> examples/formatting.rs:71:6
|
71 | a =- 35;
| ^^^^
|
= note: #[deny(suspicious_assignment_formatting)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/formatting.rs:4:9
|
4 | #![deny(clippy)]
| ^^^^^^
= note: `-D suspicious-assignment-formatting` implied by `-D warnings`
= note: to remove this lint, use either `-=` or `= -`
error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)`
--> $DIR/formatting.rs:72:6
--> examples/formatting.rs:72:6
|
72 | a =* &191;
| ^^^^
|
= note: #[deny(suspicious_assignment_formatting)] implied by #[deny(clippy)]
= note: `-D suspicious-assignment-formatting` implied by `-D warnings`
= note: to remove this lint, use either `*=` or `= *`
error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)`
--> $DIR/formatting.rs:75:6
--> examples/formatting.rs:75:6
|
75 | b =! false;
| ^^^^
|
= note: #[deny(suspicious_assignment_formatting)] implied by #[deny(clippy)]
= note: `-D suspicious-assignment-formatting` implied by `-D warnings`
= note: to remove this lint, use either `!=` or `= !`
error: possibly missing a comma here
--> $DIR/formatting.rs:84:19
--> examples/formatting.rs:84:19
|
84 | -1, -2, -3 // <= no comma here
| ^
|
= note: #[deny(possible_missing_comma)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/formatting.rs:4:9
|
4 | #![deny(clippy)]
| ^^^^^^
= note: `-D possible-missing-comma` implied by `-D warnings`
= note: to remove this lint, add a comma or write the expr in a single line
error: possibly missing a comma here
--> $DIR/formatting.rs:88:19
--> examples/formatting.rs:88:19
|
88 | -1, -2, -3 // <= no comma here
| ^
|
= note: #[deny(possible_missing_comma)] implied by #[deny(clippy)]
= note: `-D possible-missing-comma` implied by `-D warnings`
= note: to remove this lint, add a comma or write the expr in a single line
error: aborting due to 10 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -1,7 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(clippy)]
#![warn(clippy)]
#![allow(dead_code)]
#![allow(unused_unsafe)]

View File

@ -1,109 +1,102 @@
error: this function has too many arguments (8/7)
--> $DIR/functions.rs:11:1
--> examples/functions.rs:11:1
|
11 | / fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {
12 | | }
| |_^
|
= note: #[deny(too_many_arguments)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/functions.rs:4:9
|
4 | #![deny(clippy)]
| ^^^^^^
= note: `-D too-many-arguments` implied by `-D warnings`
error: this function has too many arguments (8/7)
--> $DIR/functions.rs:19:5
--> examples/functions.rs:19:5
|
19 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(too_many_arguments)] implied by #[deny(clippy)]
= note: `-D too-many-arguments` implied by `-D warnings`
error: this function has too many arguments (8/7)
--> $DIR/functions.rs:28:5
--> examples/functions.rs:28:5
|
28 | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(too_many_arguments)] implied by #[deny(clippy)]
= note: `-D too-many-arguments` implied by `-D warnings`
error: this public function dereferences a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:37:34
--> examples/functions.rs:37:34
|
37 | println!("{}", unsafe { *p });
| ^
|
= note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/functions.rs:4:9
|
4 | #![deny(clippy)]
| ^^^^^^
= note: `-D not-unsafe-ptr-arg-deref` implied by `-D warnings`
error: this public function dereferences a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:38:35
--> examples/functions.rs:38:35
|
38 | println!("{:?}", unsafe { p.as_ref() });
| ^
|
= note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)]
= note: `-D not-unsafe-ptr-arg-deref` implied by `-D warnings`
error: this public function dereferences a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:39:33
--> examples/functions.rs:39:33
|
39 | unsafe { std::ptr::read(p) };
| ^
|
= note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)]
= note: `-D not-unsafe-ptr-arg-deref` implied by `-D warnings`
error: this public function dereferences a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:50:30
--> examples/functions.rs:50:30
|
50 | println!("{}", unsafe { *p });
| ^
|
= note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)]
= note: `-D not-unsafe-ptr-arg-deref` implied by `-D warnings`
error: this public function dereferences a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:51:31
--> examples/functions.rs:51:31
|
51 | println!("{:?}", unsafe { p.as_ref() });
| ^
|
= note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)]
= note: `-D not-unsafe-ptr-arg-deref` implied by `-D warnings`
error: this public function dereferences a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:52:29
--> examples/functions.rs:52:29
|
52 | unsafe { std::ptr::read(p) };
| ^
|
= note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)]
= note: `-D not-unsafe-ptr-arg-deref` implied by `-D warnings`
error: this public function dereferences a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:61:34
--> examples/functions.rs:61:34
|
61 | println!("{}", unsafe { *p });
| ^
|
= note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)]
= note: `-D not-unsafe-ptr-arg-deref` implied by `-D warnings`
error: this public function dereferences a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:62:35
--> examples/functions.rs:62:35
|
62 | println!("{:?}", unsafe { p.as_ref() });
| ^
|
= note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)]
= note: `-D not-unsafe-ptr-arg-deref` implied by `-D warnings`
error: this public function dereferences a raw pointer but is not marked `unsafe`
--> $DIR/functions.rs:63:33
--> examples/functions.rs:63:33
|
63 | unsafe { std::ptr::read(p) };
| ^
|
= note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)]
= note: `-D not-unsafe-ptr-arg-deref` implied by `-D warnings`
error: aborting due to 12 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

View File

@ -6,7 +6,7 @@ const NEG_ONE : i64 = -1;
const ZERO : i64 = 0;
#[allow(eq_op, no_effect, unnecessary_operation, double_parens)]
#[deny(identity_op)]
#[warn(identity_op)]
fn main() {
let x = 0;

View File

@ -1,50 +1,61 @@
error: the operation is ineffective. Consider reducing it to `x`
--> $DIR/identity_op.rs:13:5
--> examples/identity_op.rs:13:5
|
13 | x + 0;
| ^^^^^
|
note: lint level defined here
--> $DIR/identity_op.rs:9:8
|
9 | #[deny(identity_op)]
| ^^^^^^^^^^^
= note: `-D identity-op` implied by `-D warnings`
error: the operation is ineffective. Consider reducing it to `x`
--> $DIR/identity_op.rs:14:5
--> examples/identity_op.rs:14:5
|
14 | x + (1 - 1);
| ^^^^^^^^^^^
|
= note: `-D identity-op` implied by `-D warnings`
error: the operation is ineffective. Consider reducing it to `x`
--> $DIR/identity_op.rs:16:5
--> examples/identity_op.rs:16:5
|
16 | 0 + x;
| ^^^^^
|
= note: `-D identity-op` implied by `-D warnings`
error: the operation is ineffective. Consider reducing it to `x`
--> $DIR/identity_op.rs:19:5
--> examples/identity_op.rs:19:5
|
19 | x | (0);
| ^^^^^^^
|
= note: `-D identity-op` implied by `-D warnings`
error: the operation is ineffective. Consider reducing it to `x`
--> $DIR/identity_op.rs:22:5
--> examples/identity_op.rs:22:5
|
22 | x * 1;
| ^^^^^
|
= note: `-D identity-op` implied by `-D warnings`
error: the operation is ineffective. Consider reducing it to `x`
--> $DIR/identity_op.rs:23:5
--> examples/identity_op.rs:23:5
|
23 | 1 * x;
| ^^^^^
|
= note: `-D identity-op` implied by `-D warnings`
error: the operation is ineffective. Consider reducing it to `x`
--> $DIR/identity_op.rs:29:5
--> examples/identity_op.rs:29:5
|
29 | -1 & x;
| ^^^^^^
|
= note: `-D identity-op` implied by `-D warnings`
error: aborting due to 7 previous errors
error: Could not compile `clippy_tests`.
To learn more, run the command again with --verbose.

Some files were not shown because too many files have changed in this diff Show More