rustup and compile-fail -> ui test move

This commit is contained in:
Oliver Schneider 2017-02-07 21:05:30 +01:00
parent 4ee839857b
commit fd1351f6e3
262 changed files with 12031 additions and 15 deletions

View file

@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.
## 0.0.114 — 2017-02-07
* Rustup to rustc 1.17.0-nightly (c49d10207 2017-02-07)
* Tests are now ui tests (testing the exact output of rustc)
## 0.0.113 — 2017-02-04
* Rustup to *rustc 1.16.0-nightly (eedaa94e3 2017-02-02)*
* New lint: [`large_enum_variant`]

View file

@ -40,6 +40,11 @@ contains some questionable code itself! Also before making a pull request, pleas
`util/update_lints.py`, which will update `lib.rs` and `README.md` with the lint declarations. Our
travis build actually checks for this.
Clippy uses UI tests. UI tests check that the output of the compiler is exactly as expected.
Of course there's little sense in writing the output yourself or copying it around.
Therefore you can simply run `tests/ui/update-all-references.sh` and check whether
the output looks as you expect with `git diff`. Commit all `.stderr` files, too.
Also please document your lint with a doc comment akin to the following:
```rust
/// **What it does:** Checks for ... (describe what the lint matches).

View file

@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.113"
version = "0.0.114"
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",
"Andre Bogus <bogusandre@gmail.com>",
@ -30,7 +30,7 @@ test = false
[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.113", path = "clippy_lints" }
clippy_lints = { version = "0.0.114", path = "clippy_lints" }
# end automatic update
cargo_metadata = "0.1.1"

View file

@ -1,7 +1,7 @@
[package]
name = "clippy_lints"
# begin automatic update
version = "0.0.113"
version = "0.0.114"
# end automatic update
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",

View file

@ -158,7 +158,7 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
TypeVariants::TyFnPtr(..) => {
return;
},
TypeVariants::TyTuple(tys) if tys.len() > 12 => {
TypeVariants::TyTuple(tys, _) if tys.len() > 12 => {
return;
},
_ => (),

View file

@ -197,7 +197,7 @@ fn check_let_unit(cx: &LateContext, decl: &Decl) {
if let DeclLocal(ref local) = decl.node {
let bindtype = &cx.tables.pat_ty(&local.pat).sty;
match *bindtype {
ty::TyTuple(slice) if slice.is_empty() => {
ty::TyTuple(slice, _) if slice.is_empty() => {
if in_external_macro(cx, decl.span) || in_macro(cx, local.pat.span) {
return;
}
@ -268,7 +268,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitCmp {
if op.is_comparison() {
let sty = &cx.tables.expr_ty(left).sty;
match *sty {
ty::TyTuple(slice) if slice.is_empty() => {
ty::TyTuple(slice, _) if slice.is_empty() => {
let result = match op {
BiEq | BiLe | BiGe => "true",
_ => "false",

View file

@ -129,14 +129,18 @@ fn bla() {
}
{
let e: i32; //~ ERROR: 5th binding whose name is just one char
//~^ NOTE implied by
}
{
let e: i32; //~ ERROR: 5th binding whose name is just one char
//~^ NOTE implied by
let f: i32; //~ ERROR: 6th binding whose name is just one char
//~^ NOTE implied by
}
match 5 {
1 => println!(""),
e => panic!(), //~ ERROR: 5th binding whose name is just one char
//~^ NOTE implied by
}
match 5 {
1 => println!(""),

View file

@ -66,7 +66,7 @@ fn main() {
// the add is only caught for `String`
let mut x = 1;
; x = x + 1;
//~^ WARN assign_op_pattern
//~^ WARN manual implementation of an assign operation
//~| HELP replace
//~| SUGGESTION ; x += 1;
assert_eq!(2, x);

View file

@ -8,7 +8,7 @@ struct Foo(u32);
fn array() {
let mut foo = [1, 2];
let temp = foo[0];
let temp = foo[0]; //~ NOTE implied by
foo[0] = foo[1];
foo[1] = temp;
//~^^^ ERROR this looks like you are swapping elements of `foo` manually
@ -20,7 +20,7 @@ fn array() {
fn slice() {
let foo = &mut [1, 2];
let temp = foo[0];
let temp = foo[0]; //~ NOTE implied by
foo[0] = foo[1];
foo[1] = temp;
//~^^^ ERROR this looks like you are swapping elements of `foo` manually
@ -32,7 +32,7 @@ fn slice() {
fn vec() {
let mut foo = vec![1, 2];
let temp = foo[0];
let temp = foo[0]; //~ NOTE implied by
foo[0] = foo[1];
foo[1] = temp;
//~^^^ ERROR this looks like you are swapping elements of `foo` manually
@ -50,14 +50,14 @@ fn main() {
let mut a = 42;
let mut b = 1337;
a = b;
a = b; //~ NOTE implied by
b = a;
//~^^ ERROR this looks like you are trying to swap `a` and `b`
//~| HELP try
//~| SUGGESTION std::mem::swap(&mut a, &mut b);
//~| NOTE or maybe you should use `std::mem::replace`?
; let t = a;
; let t = a; //~ NOTE implied by
a = b;
b = t;
//~^^^ ERROR this looks like you are swapping `a` and `b` manually
@ -67,14 +67,14 @@ fn main() {
let mut c = Foo(42);
c.0 = a;
c.0 = a; //~ NOTE implied by
a = c.0;
//~^^ ERROR this looks like you are trying to swap `c.0` and `a`
//~| HELP try
//~| SUGGESTION std::mem::swap(&mut c.0, &mut a);
//~| NOTE or maybe you should use `std::mem::replace`?
; let t = c.0;
; let t = c.0; //~ NOTE implied by
c.0 = a;
a = t;
//~^^^ ERROR this looks like you are swapping `c.0` and `a` manually

View file

@ -14,6 +14,7 @@ fn run_mode(dir: &'static str, mode: &'static str) {
}
config.mode = cfg_mode;
config.build_base = PathBuf::from("target/debug/test_build_base");
config.src_base = PathBuf::from(format!("tests/{}", dir));
compiletest::run_tests(&config);
@ -27,5 +28,5 @@ fn prepare_env() {
fn compile_test() {
prepare_env();
run_mode("run-pass", "run-pass");
run_mode("compile-fail", "compile-fail");
run_mode("ui", "ui");
}

View file

@ -0,0 +1,151 @@
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
|
12 | u <= 0;
| ^^^^^^
|
note: lint level defined here
--> $DIR/absurd-extreme-comparisons.rs:4:9
|
4 | #![deny(absurd_extreme_comparisons)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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:15:5
|
15 | u <= Z;
| ^^^^^^
|
= help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == Z instead
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
|
18 | u < Z;
| ^^^^^
|
= 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:21:5
|
21 | Z >= u;
| ^^^^^^
|
= help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using Z == u instead
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
|
24 | Z > u;
| ^^^^^
|
= 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:27:5
|
27 | u > std::u32::MAX;
| ^^^^^^^^^^^^^^^^^
|
= 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:30:5
|
30 | u >= std::u32::MAX;
| ^^^^^^^^^^^^^^^^^^
|
= help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == std::u32::MAX instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:33:5
|
33 | std::u32::MAX < u;
| ^^^^^^^^^^^^^^^^^
|
= 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:36:5
|
36 | std::u32::MAX <= u;
| ^^^^^^^^^^^^^^^^^^
|
= help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using std::u32::MAX == u instead
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:40:5
|
40 | 1-1 > u;
| ^^^^^^^
|
= 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:43:5
|
43 | u >= !0;
| ^^^^^^^
|
= help: because !0 is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == !0 instead
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:46:5
|
46 | u <= 12 - 2*6;
| ^^^^^^^^^^^^^
|
= help: because 12 - 2*6 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 12 - 2*6 instead
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:51:5
|
51 | i < -127 - 1;
| ^^^^^^^^^^^^
|
= 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:54:5
|
54 | std::i8::MAX >= i;
| ^^^^^^^^^^^^^^^^^
|
= 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:57:5
|
57 | 3-7 < std::i32::MIN;
| ^^^^^^^^^^^^^^^^^^^
|
= 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:62:5
|
62 | b >= true;
| ^^^^^^^^^
|
= help: because true is the maximum value for this type, the case where the two sides are not equal never occurs, consider using b == true instead
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:65:5
|
65 | false > b;
| ^^^^^^^^^
|
= 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:72:5
|
72 | () < {}; //~WARNING <-comparison of unit values detected.
| ^^^^^^^
|
= note: #[warn(unit_cmp)] on by default
error: aborting due to 17 previous errors

View file

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

View file

@ -0,0 +1,82 @@
error: integer arithmetic detected
--> $DIR/arithmetic.rs:8:5
|
8 | 1 + i; //~ERROR integer arithmetic detected
| ^^^^^
|
note: lint level defined here
--> $DIR/arithmetic.rs:4:9
|
4 | #![deny(integer_arithmetic, float_arithmetic)]
| ^^^^^^^^^^^^^^^^^^
error: integer arithmetic detected
--> $DIR/arithmetic.rs:9:5
|
9 | i * 2; //~ERROR integer arithmetic detected
| ^^^^^
error: integer arithmetic detected
--> $DIR/arithmetic.rs:10:5
|
10 | 1 % //~ERROR integer arithmetic detected
| _____^ starting here...
11 | | i / 2; // no error, this is part of the expression in the preceding line
| |_________^ ...ending here
error: integer arithmetic detected
--> $DIR/arithmetic.rs:12:5
|
12 | i - 2 + 2 - i; //~ERROR integer arithmetic detected
| ^^^^^^^^^^^^^
error: integer arithmetic detected
--> $DIR/arithmetic.rs:13:5
|
13 | -i; //~ERROR integer arithmetic detected
| ^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:23:5
|
23 | f * 2.0; //~ERROR floating-point arithmetic detected
| ^^^^^^^
|
note: lint level defined here
--> $DIR/arithmetic.rs:4:29
|
4 | #![deny(integer_arithmetic, float_arithmetic)]
| ^^^^^^^^^^^^^^^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:25:5
|
25 | 1.0 + f; //~ERROR floating-point arithmetic detected
| ^^^^^^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:26:5
|
26 | f * 2.0; //~ERROR floating-point arithmetic detected
| ^^^^^^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:27:5
|
27 | f / 2.0; //~ERROR floating-point arithmetic detected
| ^^^^^^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:28:5
|
28 | f - 2.0 * 4.2; //~ERROR floating-point arithmetic detected
| ^^^^^^^^^^^^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:29:5
|
29 | -f; //~ERROR floating-point arithmetic detected
| ^^
error: aborting due to 11 previous errors

View file

@ -0,0 +1,152 @@
error: const index is out of bounds
--> $DIR/array_indexing.rs:12:5
|
12 | x[4]; //~ERROR: const index is out of bounds
| ^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: const index is out of bounds
--> $DIR/array_indexing.rs:13:5
|
13 | x[1 << 3]; //~ERROR: const index is out of bounds
| ^^^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:14:6
|
14 | &x[1..5]; //~ERROR: range is out of bounds
| ^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:16:6
|
16 | &x[0...4]; //~ERROR: range is out of bounds
| ^^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:17:6
|
17 | &x[...4]; //~ERROR: range is out of bounds
| ^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:21:6
|
21 | &x[5..]; //~ERROR: range is out of bounds
| ^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:23:6
|
23 | &x[..5]; //~ERROR: range is out of bounds
| ^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: indexing may panic
--> $DIR/array_indexing.rs:26:5
|
26 | y[0]; //~ERROR: indexing may panic
| ^^^^
|
note: lint level defined here
--> $DIR/array_indexing.rs:4:9
|
4 | #![deny(indexing_slicing)]
| ^^^^^^^^^^^^^^^^
error: slicing may panic
--> $DIR/array_indexing.rs:27:6
|
27 | &y[1..2]; //~ERROR: slicing may panic
| ^^^^^^^
error: slicing may panic
--> $DIR/array_indexing.rs:29:6
|
29 | &y[0...4]; //~ERROR: slicing may panic
| ^^^^^^^^
error: slicing may panic
--> $DIR/array_indexing.rs:30:6
|
30 | &y[...4]; //~ERROR: slicing may panic
| ^^^^^^^
error: const index is out of bounds
--> $DIR/array_indexing.rs:33:5
|
33 | empty[0]; //~ERROR: const index is out of bounds
| ^^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:34:6
|
34 | &empty[1..5]; //~ERROR: range is out of bounds
| ^^^^^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:35:6
|
35 | &empty[0...4]; //~ERROR: range is out of bounds
| ^^^^^^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:36:6
|
36 | &empty[...4]; //~ERROR: range is out of bounds
| ^^^^^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:40:6
|
40 | &empty[0...0]; //~ERROR: range is out of bounds
| ^^^^^^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:41:6
|
41 | &empty[...0]; //~ERROR: range is out of bounds
| ^^^^^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:43:6
|
43 | &empty[1..]; //~ERROR: range is out of bounds
| ^^^^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: range is out of bounds
--> $DIR/array_indexing.rs:44:6
|
44 | &empty[..4]; //~ERROR: range is out of bounds
| ^^^^^^^^^^
|
= note: #[deny(out_of_bounds_indexing)] on by default
error: aborting due to 19 previous errors

201
tests/ui/assign_ops.stderr Normal file
View file

@ -0,0 +1,201 @@
error: assign operation detected
--> $DIR/assign_ops.rs:8:5
|
8 | i += 2; //~ ERROR assign operation detected
| ^^^^^^
|
note: lint level defined here
--> $DIR/assign_ops.rs:4:8
|
4 | #[deny(assign_ops)]
| ^^^^^^^^^^
help: replace it with
| i = i + 2; //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:11:5
|
11 | i += 2 + 17; //~ ERROR assign operation detected
| ^^^^^^^^^^^
|
help: replace it with
| i = i + 2 + 17; //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:14:5
|
14 | i -= 6; //~ ERROR assign operation detected
| ^^^^^^
|
help: replace it with
| i = i - 6; //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:17:5
|
17 | i -= 2 - 1;
| ^^^^^^^^^^
|
help: replace it with
| i = i - (2 - 1);
error: assign operation detected
--> $DIR/assign_ops.rs:21:5
|
21 | i *= 5; //~ ERROR assign operation detected
| ^^^^^^
|
help: replace it with
| i = i * 5; //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:24:5
|
24 | i *= 1+5; //~ ERROR assign operation detected
| ^^^^^^^^
|
help: replace it with
| i = i * (1+5); //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:27:5
|
27 | i /= 32; //~ ERROR assign operation detected
| ^^^^^^^
|
help: replace it with
| i = i / 32; //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:30:5
|
30 | i /= 32 | 5; //~ ERROR assign operation detected
| ^^^^^^^^^^^
|
help: replace it with
| i = i / (32 | 5); //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:33:5
|
33 | i /= 32 / 5; //~ ERROR assign operation detected
| ^^^^^^^^^^^
|
help: replace it with
| i = i / (32 / 5); //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:36:5
|
36 | i %= 42; //~ ERROR assign operation detected
| ^^^^^^^
|
help: replace it with
| i = i % 42; //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:39:5
|
39 | i >>= i; //~ ERROR assign operation detected
| ^^^^^^^
|
help: replace it with
| i = i >> i; //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:42:5
|
42 | i <<= 9 + 6 - 7; //~ ERROR assign operation detected
| ^^^^^^^^^^^^^^^
|
help: replace it with
| i = i << (9 + 6 - 7); //~ ERROR assign operation detected
error: assign operation detected
--> $DIR/assign_ops.rs:45:5
|
45 | i += 1 << 5;
| ^^^^^^^^^^^
|
help: replace it with
| i = i + (1 << 5);
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:55:5
|
55 | a = a + 1; //~ ERROR manual implementation of an assign operation
| ^^^^^^^^^
|
note: lint level defined here
--> $DIR/assign_ops.rs:52:8
|
52 | #[deny(assign_op_pattern)]
| ^^^^^^^^^^^^^^^^^
help: replace it with
| a += 1; //~ ERROR manual implementation of an assign operation
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:58:5
|
58 | a = 1 + a; //~ ERROR manual implementation of an assign operation
| ^^^^^^^^^
|
help: replace it with
| a += 1; //~ ERROR manual implementation of an assign operation
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:61:5
|
61 | a = a - 1; //~ ERROR manual implementation of an assign operation
| ^^^^^^^^^
|
help: replace it with
| a -= 1; //~ ERROR manual implementation of an assign operation
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:64:5
|
64 | a = a * 99; //~ ERROR manual implementation of an assign operation
| ^^^^^^^^^^
|
help: replace it with
| a *= 99; //~ ERROR manual implementation of an assign operation
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:67:5
|
67 | a = 42 * a; //~ ERROR manual implementation of an assign operation
| ^^^^^^^^^^
|
help: replace it with
| a *= 42; //~ ERROR manual implementation of an assign operation
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:70:5
|
70 | a = a / 2; //~ ERROR manual implementation of an assign operation
| ^^^^^^^^^
|
help: replace it with
| a /= 2; //~ ERROR manual implementation of an assign operation
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:73:5
|
73 | a = a % 5; //~ ERROR manual implementation of an assign operation
| ^^^^^^^^^
|
help: replace it with
| a %= 5; //~ ERROR manual implementation of an assign operation
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:76:5
|
76 | a = a & 1; //~ ERROR manual implementation of an assign operation
| ^^^^^^^^^
|
help: replace it with
| a &= 1; //~ ERROR manual implementation of an assign operation
error: aborting due to 21 previous errors

View file

@ -0,0 +1,79 @@
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:8:5
|
8 | a += a + 1; //~ ERROR variable appears on both sides of an assignment operation
| ^^^^^^^^^^
|
note: lint level defined here
--> $DIR/assign_ops2.rs:5:8
|
5 | #[deny(misrefactored_assign_op)]
| ^^^^^^^^^^^^^^^^^^^^^^^
help: replace it with
| a += 1; //~ ERROR variable appears on both sides of an assignment operation
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:11:5
|
11 | a += 1 + a; //~ ERROR variable appears on both sides of an assignment operation
| ^^^^^^^^^^
|
help: replace it with
| a += 1; //~ ERROR variable appears on both sides of an assignment operation
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:14:5
|
14 | a -= a - 1; //~ ERROR variable appears on both sides of an assignment operation
| ^^^^^^^^^^
|
help: replace it with
| a -= 1; //~ ERROR variable appears on both sides of an assignment operation
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:17:5
|
17 | a *= a * 99; //~ ERROR variable appears on both sides of an assignment operation
| ^^^^^^^^^^^
|
help: replace it with
| a *= 99; //~ ERROR variable appears on both sides of an assignment operation
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:20:5
|
20 | a *= 42 * a; //~ ERROR variable appears on both sides of an assignment operation
| ^^^^^^^^^^^
|
help: replace it with
| a *= 42; //~ ERROR variable appears on both sides of an assignment operation
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:23:5
|
23 | a /= a / 2; //~ ERROR variable appears on both sides of an assignment operation
| ^^^^^^^^^^
|
help: replace it with
| a /= 2; //~ ERROR variable appears on both sides of an assignment operation
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:26:5
|
26 | a %= a % 5; //~ ERROR variable appears on both sides of an assignment operation
| ^^^^^^^^^^
|
help: replace it with
| a %= 5; //~ ERROR variable appears on both sides of an assignment operation
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:29:5
|
29 | a &= a & 1; //~ ERROR variable appears on both sides of an assignment operation
| ^^^^^^^^^^
|
help: replace it with
| a &= 1; //~ ERROR variable appears on both sides of an assignment operation
error: aborting due to 8 previous errors

32
tests/ui/attrs.stderr Normal file
View file

@ -0,0 +1,32 @@
error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea
--> $DIR/attrs.rs:6:1
|
6 | #[inline(always)] //~ERROR you have declared `#[inline(always)]` on `test_attr_lint`.
| ^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/attrs.rs:4:9
|
4 | #![deny(inline_always, deprecated_semver)]
| ^^^^^^^^^^^^^
error: the since field must contain a semver-compliant version
--> $DIR/attrs.rs:27:14
|
27 | #[deprecated(since = "forever")] //~ERROR the since field must contain a semver-compliant version
| ^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/attrs.rs:4:24
|
4 | #![deny(inline_always, deprecated_semver)]
| ^^^^^^^^^^^^^^^^^
error: the since field must contain a semver-compliant version
--> $DIR/attrs.rs:30:14
|
30 | #[deprecated(since = "1")] //~ERROR the since field must contain a semver-compliant version
| ^^^^^^^^^^^
error: aborting due to 3 previous errors

104
tests/ui/bit_masks.stderr Normal file
View file

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

View file

@ -0,0 +1,50 @@
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:9:9
|
9 | fn test(foo: ()) {} //~ERROR use of a blacklisted/placeholder name `foo`
| ^^^
|
note: lint level defined here
--> $DIR/blacklisted_name.rs:7:9
|
7 | #![deny(blacklisted_name)]
| ^^^^^^^^^^^^^^^^
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:12:9
|
12 | let foo = 42; //~ERROR use of a blacklisted/placeholder name `foo`
| ^^^
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:13:9
|
13 | let bar = 42; //~ERROR use of a blacklisted/placeholder name `bar`
| ^^^
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:14:9
|
14 | let baz = 42; //~ERROR use of a blacklisted/placeholder name `baz`
| ^^^
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:20:10
|
20 | (foo, Some(bar), baz @ Some(_)) => (),
| ^^^
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:20:20
|
20 | (foo, Some(bar), baz @ Some(_)) => (),
| ^^^
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:20:26
|
20 | (foo, Some(bar), baz @ Some(_)) => (),
| ^^^^^^^^^^^^^
error: aborting due to 7 previous errors

View file

@ -0,0 +1,68 @@
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
|
30 | if { //~ERROR in an 'if' condition, avoid complex blocks or closures with blocks;
| ________^ starting here...
31 | | let x = 3;
32 | | x == 3
33 | | } {
| |_____^ ...ending here
|
note: lint level defined here
--> $DIR/block_in_if_condition.rs:5:9
|
5 | #![deny(block_in_if_condition_stmt)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: try
let res = { //~ERROR in an 'if' condition, avoid complex blocks or closures with blocks;
let x = 3;
x == 3
};
if res {
6
} ...
error: omit braces around single expression condition
--> $DIR/block_in_if_condition.rs:41:8
|
41 | if { true } { //~ERROR omit braces around single expression condition
| ^^^^^^^^
|
note: lint level defined here
--> $DIR/block_in_if_condition.rs:4:9
|
4 | #![deny(block_in_if_condition_expr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: try
if true { //~ERROR omit braces around single expression condition
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
|
58 | if v == 3 && sky == "blue" && predicate(|x| { let target = 3; x == target }, v) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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:62:22
|
62 | if predicate(|x| { let target = 3; x == target }, v) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: this boolean expression can be simplified
--> $DIR/block_in_if_condition.rs:70:8
|
70 | if true && x == 3 { //~ WARN this boolean expression can be simplified
| ^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/block_in_if_condition.rs:7:9
|
7 | #![warn(nonminimal_bool)]
| ^^^^^^^^^^^^^^^
help: try
| if x == 3 { //~ WARN this boolean expression can be simplified
error: aborting due to 4 previous errors

View file

@ -0,0 +1,43 @@
error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:7:8
|
7 | if x == true { "yes" } else { "no" };
| ^^^^^^^^^
|
note: lint level defined here
--> $DIR/bool_comparison.rs:4:8
|
4 | #[deny(bool_comparison)]
| ^^^^^^^^^^^^^^^
help: try simplifying it as shown:
| if x { "yes" } else { "no" };
error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:11:8
|
11 | if x == false { "yes" } else { "no" };
| ^^^^^^^^^^
|
help: try simplifying it as shown:
| if !x { "yes" } else { "no" };
error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:15:8
|
15 | if true == x { "yes" } else { "no" };
| ^^^^^^^^^
|
help: try simplifying it as shown:
| if x { "yes" } else { "no" };
error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:19:8
|
19 | if false == x { "yes" } else { "no" };
| ^^^^^^^^^^
|
help: try simplifying it as shown:
| if !x { "yes" } else { "no" };
error: aborting due to 4 previous errors

160
tests/ui/booleans.stderr Normal file
View file

@ -0,0 +1,160 @@
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:12:13
|
12 | let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug
| ^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/booleans.rs:3:26
|
3 | #![deny(nonminimal_bool, logic_bug)]
| ^^^^^^^^^
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:12:18
|
12 | let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug
| ^
help: it would look like the following
| let _ = a; //~ ERROR this boolean expression contains a logic bug
error: this boolean expression can be simplified
--> $DIR/booleans.rs:17:13
|
17 | let _ = !true; //~ ERROR this boolean expression can be simplified
| ^^^^^
|
note: lint level defined here
--> $DIR/booleans.rs:3:9
|
3 | #![deny(nonminimal_bool, logic_bug)]
| ^^^^^^^^^^^^^^^
help: try
| let _ = false; //~ ERROR this boolean expression can be simplified
error: this boolean expression can be simplified
--> $DIR/booleans.rs:20:13
|
20 | let _ = !false; //~ ERROR this boolean expression can be simplified
| ^^^^^^
|
help: try
| let _ = true; //~ ERROR this boolean expression can be simplified
error: this boolean expression can be simplified
--> $DIR/booleans.rs:23:13
|
23 | let _ = !!a; //~ ERROR this boolean expression can be simplified
| ^^^
|
help: try
| let _ = a; //~ ERROR this boolean expression can be simplified
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:27:13
|
27 | let _ = false && a; //~ ERROR this boolean expression contains a logic bug
| ^^^^^^^^^^
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:27:22
|
27 | let _ = false && a; //~ ERROR this boolean expression contains a logic bug
| ^
help: it would look like the following
| let _ = false; //~ ERROR this boolean expression contains a logic bug
error: this boolean expression can be simplified
--> $DIR/booleans.rs:32:13
|
32 | let _ = false || a; //~ ERROR this boolean expression can be simplified
| ^^^^^^^^^^
|
help: try
| let _ = a; //~ ERROR this boolean expression can be simplified
error: this boolean expression can be simplified
--> $DIR/booleans.rs:43:13
|
43 | let _ = !(!a && b); //~ ERROR this boolean expression can be simplified
| ^^^^^^^^^^
|
help: try
| let _ = !b || a; //~ ERROR this boolean expression can be simplified
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:55:13
|
55 | let _ = a == b && a != b;
| ^^^^^^^^^^^^^^^^
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:55:13
|
55 | let _ = a == b && a != b;
| ^^^^^^
help: it would look like the following
| let _ = false;
error: this boolean expression can be simplified
--> $DIR/booleans.rs:60:13
|
60 | let _ = a == b && c == 5 && a == b;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try
| let _ = a == b && c == 5;
help: try
| let _ = !(c != 5 || a != b);
error: this boolean expression can be simplified
--> $DIR/booleans.rs:66:13
|
66 | let _ = a == b && c == 5 && b == a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try
| let _ = a == b && c == 5;
help: try
| let _ = !(c != 5 || a != b);
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:72:13
|
72 | let _ = a < b && a >= b;
| ^^^^^^^^^^^^^^^
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:72:13
|
72 | let _ = a < b && a >= b;
| ^^^^^
help: it would look like the following
| let _ = false;
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:77:13
|
77 | let _ = a > b && a <= b;
| ^^^^^^^^^^^^^^^
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:77:13
|
77 | let _ = a > b && a <= b;
| ^^^^^
help: it would look like the following
| let _ = false;
error: this boolean expression can be simplified
--> $DIR/booleans.rs:84:13
|
84 | let _ = a != b || !(a != b || c == d);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try
| let _ = c != d || a != b;
help: try
| let _ = !(a == b && c == d);
error: aborting due to 13 previous errors

16
tests/ui/box_vec.stderr Normal file
View file

@ -0,0 +1,16 @@
error: you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`
--> $DIR/box_vec.rs:17:18
|
17 | pub fn test(foo: Box<Vec<bool>>) { //~ ERROR you seem to be trying to use `Box<Vec<T>>`
| ^^^^^^^^^^^^^^
|
= note: #[deny(box_vec)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/box_vec.rs:4:9
|
4 | #![deny(clippy)]
| ^^^^^^
= help: `Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation.
error: aborting due to previous error

View file

@ -0,0 +1,23 @@
error: This generic shadows the built-in type `u32`
--> $DIR/builtin-type-shadow.rs:5:8
|
5 | fn foo<u32>(a: u32) -> u32 { //~ERROR shadows the built-in type `u32`
| ^^^
|
note: lint level defined here
--> $DIR/builtin-type-shadow.rs:3:9
|
3 | #![deny(builtin_type_shadow)]
| ^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/builtin-type-shadow.rs:6:5
|
6 | 42 //~ERROR E0308
| ^^ expected type parameter, found integral variable
|
= note: expected type `u32`
found type `{integer}`
error: aborting due to previous error

278
tests/ui/cast.stderr Normal file
View file

@ -0,0 +1,278 @@
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
|
8 | 1i32 as f32; //~ERROR casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
| ^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/cast.rs:4:8
|
4 | #[deny(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap)]
| ^^^^^^^^^^^^^^^^^^^
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
|
9 | 1i64 as f32; //~ERROR casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
| ^^^^^^^^^^^
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
|
10 | 1i64 as f64; //~ERROR casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
| ^^^^^^^^^^^
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
|
11 | 1u32 as f32; //~ERROR casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
| ^^^^^^^^^^^
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
|
12 | 1u64 as f32; //~ERROR casting u64 to f32 causes a loss of precision (u64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
| ^^^^^^^^^^^
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
|
13 | 1u64 as f64; //~ERROR casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
| ^^^^^^^^^^^
error: casting f32 to i32 may truncate the value
--> $DIR/cast.rs:18:5
|
18 | 1f32 as i32; //~ERROR casting f32 to i32 may truncate the value
| ^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/cast.rs:4:29
|
4 | #[deny(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: casting f32 to u32 may truncate the value
--> $DIR/cast.rs:19:5
|
19 | 1f32 as u32; //~ERROR casting f32 to u32 may truncate the value
| ^^^^^^^^^^^
error: casting f32 to u32 may lose the sign of the value
--> $DIR/cast.rs:19:5
|
19 | 1f32 as u32; //~ERROR casting f32 to u32 may truncate the value
| ^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/cast.rs:4:55
|
4 | #[deny(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap)]
| ^^^^^^^^^^^^^^
error: casting f64 to f32 may truncate the value
--> $DIR/cast.rs:21:5
|
21 | 1f64 as f32; //~ERROR casting f64 to f32 may truncate the value
| ^^^^^^^^^^^
error: casting i32 to i8 may truncate the value
--> $DIR/cast.rs:22:5
|
22 | 1i32 as i8; //~ERROR casting i32 to i8 may truncate the value
| ^^^^^^^^^^
error: casting i32 to u8 may lose the sign of the value
--> $DIR/cast.rs:23:5
|
23 | 1i32 as u8; //~ERROR casting i32 to u8 may truncate the value
| ^^^^^^^^^^
error: casting i32 to u8 may truncate the value
--> $DIR/cast.rs:23:5
|
23 | 1i32 as u8; //~ERROR casting i32 to u8 may truncate the value
| ^^^^^^^^^^
error: casting f64 to isize may truncate the value
--> $DIR/cast.rs:25:5
|
25 | 1f64 as isize; //~ERROR casting f64 to isize may truncate the value
| ^^^^^^^^^^^^^
error: casting f64 to usize may truncate the value
--> $DIR/cast.rs:26:5
|
26 | 1f64 as usize; //~ERROR casting f64 to usize may truncate the value
| ^^^^^^^^^^^^^
error: casting f64 to usize may lose the sign of the value
--> $DIR/cast.rs:26:5
|
26 | 1f64 as usize; //~ERROR casting f64 to usize may truncate the value
| ^^^^^^^^^^^^^
error: casting u8 to i8 may wrap around the value
--> $DIR/cast.rs:30:5
|
30 | 1u8 as i8; //~ERROR casting u8 to i8 may wrap around the value
| ^^^^^^^^^
|
note: lint level defined here
--> $DIR/cast.rs:4:71
|
4 | #[deny(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap)]
| ^^^^^^^^^^^^^^^^^^
error: casting u16 to i16 may wrap around the value
--> $DIR/cast.rs:31:5
|
31 | 1u16 as i16; //~ERROR casting u16 to i16 may wrap around the value
| ^^^^^^^^^^^
error: casting u32 to i32 may wrap around the value
--> $DIR/cast.rs:32:5
|
32 | 1u32 as i32; //~ERROR casting u32 to i32 may wrap around the value
| ^^^^^^^^^^^
error: casting u64 to i64 may wrap around the value
--> $DIR/cast.rs:33:5
|
33 | 1u64 as i64; //~ERROR casting u64 to i64 may wrap around the value
| ^^^^^^^^^^^
error: casting usize to isize may wrap around the value
--> $DIR/cast.rs:34:5
|
34 | 1usize as isize; //~ERROR casting usize to isize may wrap around the value
| ^^^^^^^^^^^^^^^
error: casting i32 to u32 may lose the sign of the value
--> $DIR/cast.rs:37:5
|
37 | 1i32 as u32; //~ERROR casting i32 to u32 may lose the sign of the value
| ^^^^^^^^^^^
error: casting isize to usize may lose the sign of the value
--> $DIR/cast.rs:38:5
|
38 | 1isize as usize; //~ERROR casting isize to usize may lose the sign of the value
| ^^^^^^^^^^^^^^^
error: casting isize to i8 may truncate the value
--> $DIR/cast.rs:42:5
|
42 | 1isize as i8; //~ERROR casting isize to i8 may truncate the value
| ^^^^^^^^^^^^
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:43:5
|
43 | 1isize as f64; //~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)
| ^^^^^^^^^^^^^
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:44:5
|
44 | 1usize as f64; //~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)
| ^^^^^^^^^^^^^
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:45:5
|
45 | 1isize as f32; //~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)
| ^^^^^^^^^^^^^
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:46:5
|
46 | 1usize as f32; //~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)
| ^^^^^^^^^^^^^
error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast.rs:47:5
|
47 | 1isize as i32; //~ERROR casting isize to i32 may truncate the value on targets with 64-bit wide pointers
| ^^^^^^^^^^^^^
error: casting isize to u32 may lose the sign of the value
--> $DIR/cast.rs:48:5
|
48 | 1isize as u32; //~ERROR casting isize to u32 may lose the sign of the value
| ^^^^^^^^^^^^^
error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast.rs:48:5
|
48 | 1isize as u32; //~ERROR casting isize to u32 may lose the sign of the value
| ^^^^^^^^^^^^^
error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast.rs:50:5
|
50 | 1usize as u32; //~ERROR casting usize to u32 may truncate the value on targets with 64-bit wide pointers
| ^^^^^^^^^^^^^
error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast.rs:51:5
|
51 | 1usize as i32; //~ERROR casting usize to i32 may truncate the value on targets with 64-bit wide pointers
| ^^^^^^^^^^^^^
error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:51:5
|
51 | 1usize as i32; //~ERROR casting usize to i32 may truncate the value on targets with 64-bit wide pointers
| ^^^^^^^^^^^^^
error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:54:5
|
54 | 1i64 as isize; //~ERROR casting i64 to isize may truncate the value on targets with 32-bit wide pointers
| ^^^^^^^^^^^^^
error: casting i64 to usize may lose the sign of the value
--> $DIR/cast.rs:55:5
|
55 | 1i64 as usize; //~ERROR casting i64 to usize may truncate the value on targets with 32-bit wide pointers
| ^^^^^^^^^^^^^
error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:55:5
|
55 | 1i64 as usize; //~ERROR casting i64 to usize may truncate the value on targets with 32-bit wide pointers
| ^^^^^^^^^^^^^
error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:57:5
|
57 | 1u64 as isize; //~ERROR casting u64 to isize may truncate the value on targets with 32-bit wide pointers
| ^^^^^^^^^^^^^
error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers
--> $DIR/cast.rs:57:5
|
57 | 1u64 as isize; //~ERROR casting u64 to isize may truncate the value on targets with 32-bit wide pointers
| ^^^^^^^^^^^^^
error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:59:5
|
59 | 1u64 as usize; //~ERROR casting u64 to usize may truncate the value on targets with 32-bit wide pointers
| ^^^^^^^^^^^^^
error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers
--> $DIR/cast.rs:60:5
|
60 | 1u32 as isize; //~ERROR casting u32 to isize may wrap around the value on targets with 32-bit wide pointers
| ^^^^^^^^^^^^^
error: casting i32 to usize may lose the sign of the value
--> $DIR/cast.rs:63:5
|
63 | 1i32 as usize; //~ERROR casting i32 to usize may lose the sign of the value
| ^^^^^^^^^^^^^
error: aborting due to 42 previous errors

View file

@ -0,0 +1,16 @@
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
|
7 | let c = 'a' as u8; //~ERROR casting character literal
| ^^^^^^^^^
|
note: lint level defined here
--> $DIR/char_lit_as_u8.rs:4:9
|
4 | #![deny(char_lit_as_u8)]
| ^^^^^^^^^^^^^^
= help: Consider using a byte literal instead:
b'a'
error: aborting due to previous error

98
tests/ui/cmp_nan.stderr Normal file
View file

@ -0,0 +1,98 @@
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:8:5
|
8 | x == std::f32::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:9:5
|
9 | x != std::f32::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:10:5
|
10 | x < std::f32::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:11:5
|
11 | x > std::f32::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:12:5
|
12 | x <= std::f32::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:13:5
|
13 | x >= std::f32::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:16:5
|
16 | y == std::f64::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:17:5
|
17 | y != std::f64::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:18:5
|
18 | y < std::f64::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:19:5
|
19 | y > std::f64::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:20:5
|
20 | y <= std::f64::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:21:5
|
21 | y >= std::f64::NAN; //~ERROR doomed comparison with NAN
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(cmp_nan)] on by default
error: aborting due to 12 previous errors

20
tests/ui/cmp_null.stderr Normal file
View file

@ -0,0 +1,20 @@
error: Comparing with null is better expressed by the .is_null() method
--> $DIR/cmp_null.rs:11:8
|
11 | if p == ptr::null() { //~ERROR: Comparing with null
| ^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/cmp_null.rs:3:9
|
3 | #![deny(cmp_null)]
| ^^^^^^^^
error: Comparing with null is better expressed by the .is_null() method
--> $DIR/cmp_null.rs:16:8
|
16 | if m == ptr::null_mut() { //~ERROR: Comparing with null
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

32
tests/ui/cmp_owned.stderr Normal file
View file

@ -0,0 +1,32 @@
error: this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation
--> $DIR/cmp_owned.rs:8:14
|
8 | x != "foo".to_string();
| ^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/cmp_owned.rs:4:8
|
4 | #[deny(cmp_owned)]
| ^^^^^^^^^
error: this creates an owned instance just for comparison. Consider using `"foo" != x` to compare without allocation
--> $DIR/cmp_owned.rs:11:9
|
11 | "foo".to_string() != x;
| ^^^^^^^^^^^^^^^^^
error: this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation
--> $DIR/cmp_owned.rs:19:10
|
19 | x != "foo".to_owned(); //~ERROR this creates an owned instance
| ^^^^^^^^^^^^^^^^
error: this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation
--> $DIR/cmp_owned.rs:24:10
|
24 | x != String::from("foo"); //~ERROR this creates an owned instance
| ^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors

View file

@ -0,0 +1,229 @@
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:8:5
|
8 | if x == "hello" {
| _____^ starting here...
9 | | //~^ ERROR this if statement can be collapsed
10 | | //~| HELP try
11 | | //~| SUGGESTION if x == "hello" && y == "world" {
12 | | if y == "world" {
13 | | println!("Hello world!");
14 | | }
15 | | }
| |_____^ ...ending here
|
note: lint level defined here
--> $DIR/collapsible_if.rs:4:8
|
4 | #[deny(collapsible_if)]
| ^^^^^^^^^^^^^^
help: try
| if x == "hello" && y == "world" {
| println!("Hello world!");
| }
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:17:5
|
17 | if x == "hello" || x == "world" {
| _____^ starting here...
18 | | //~^ ERROR this if statement can be collapsed
19 | | //~| HELP try
20 | | //~| SUGGESTION if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
21 | | if y == "world" || y == "hello" {
22 | | println!("Hello world!");
23 | | }
24 | | }
| |_____^ ...ending here
|
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
|
26 | if x == "hello" && x == "world" {
| _____^ starting here...
27 | | //~^ ERROR this if statement can be collapsed
28 | | //~| HELP try
29 | | //~| SUGGESTION if x == "hello" && x == "world" && (y == "world" || y == "hello") {
30 | | if y == "world" || y == "hello" {
31 | | println!("Hello world!");
32 | | }
33 | | }
| |_____^ ...ending here
|
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:35:5
|
35 | if x == "hello" || x == "world" {
| _____^ starting here...
36 | | //~^ ERROR this if statement can be collapsed
37 | | //~| HELP try
38 | | //~| SUGGESTION if (x == "hello" || x == "world") && y == "world" && y == "hello" {
39 | | if y == "world" && y == "hello" {
40 | | println!("Hello world!");
41 | | }
42 | | }
| |_____^ ...ending here
|
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:44:5
|
44 | if x == "hello" && x == "world" {
| _____^ starting here...
45 | | //~^ ERROR this if statement can be collapsed
46 | | //~| HELP try
47 | | //~| SUGGESTION if x == "hello" && x == "world" && y == "world" && y == "hello" {
48 | | if y == "world" && y == "hello" {
49 | | println!("Hello world!");
50 | | }
51 | | }
| |_____^ ...ending here
|
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:53:5
|
53 | if 42 == 1337 {
| _____^ starting here...
54 | | //~^ ERROR this if statement can be collapsed
55 | | //~| HELP try
56 | | //~| SUGGESTION if 42 == 1337 && 'a' != 'A' {
57 | | if 'a' != 'A' {
58 | | println!("world!")
59 | | }
60 | | }
| |_____^ ...ending here
|
help: try
| if 42 == 1337 && 'a' != 'A' {
| println!("world!")
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:65:12
|
65 | } else {
| ____________^ starting here...
66 | | //~^ ERROR: this `else { if .. }`
67 | | //~| HELP try
68 | | //~| SUGGESTION } else if y == "world"
69 | | if y == "world" {
70 | | println!("world!")
71 | | }
72 | | }
| |_____^ ...ending here
|
help: try
| } else if y == "world" {
| println!("world!")
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:76:12
|
76 | } else {
| ____________^ starting here...
77 | | //~^ ERROR: this `else { if .. }`
78 | | //~| HELP try
79 | | //~| SUGGESTION } else if let Some(42)
80 | | if let Some(42) = Some(42) {
81 | | println!("world!")
82 | | }
83 | | }
| |_____^ ...ending here
|
help: try
| } else if let Some(42) = Some(42) {
| println!("world!")
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:87:12
|
87 | } else {
| ^
|
help: try
| } else if y == "world" {
| println!("world")
| }
| else {
| println!("!")
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:101:12
|
101 | } else {
| ^
|
help: try
| } else if let Some(42) = Some(42) {
| println!("world")
| }
| else {
| println!("!")
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:115:12
|
115 | } else {
| ^
|
help: try
| } else if let Some(42) = Some(42) {
| println!("world")
| }
| else {
| println!("!")
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:129:12
|
129 | } else {
| ^
|
help: try
| } else if x == "hello" {
| println!("world")
| }
| else {
| println!("!")
| }
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:143:12
|
143 | } else {
| ^
|
help: try
| } else if let Some(42) = Some(42) {
| println!("world")
| }
| else {
| println!("!")
| }
error: aborting due to 13 previous errors

View file

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

View file

@ -0,0 +1,14 @@
error: `conf_file` must be a named value
--> $DIR/conf_bad_arg.rs:4:18
|
4 | #![plugin(clippy(conf_file))]
| ^^^^^^^^^
|
note: Clippy will use default configuration
--> $DIR/conf_bad_arg.rs:4:18
|
4 | #![plugin(clippy(conf_file))]
| ^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,4 @@
error: error reading Clippy's configuration file: No such file or directory (os error 2)
error: aborting due to previous error

View file

@ -0,0 +1,4 @@
error: error reading Clippy's configuration file: No such file or directory (os error 2)
error: aborting due to previous error

View file

@ -0,0 +1,50 @@
error: use of a blacklisted/placeholder name `toto`
--> $DIR/conf_french_blacklisted_name.rs:9:9
|
9 | fn test(toto: ()) {} //~ERROR use of a blacklisted/placeholder name `toto`
| ^^^^
|
note: lint level defined here
--> $DIR/conf_french_blacklisted_name.rs:7:9
|
7 | #![deny(blacklisted_name)]
| ^^^^^^^^^^^^^^^^
error: use of a blacklisted/placeholder name `toto`
--> $DIR/conf_french_blacklisted_name.rs:12:9
|
12 | let toto = 42; //~ERROR use of a blacklisted/placeholder name `toto`
| ^^^^
error: use of a blacklisted/placeholder name `tata`
--> $DIR/conf_french_blacklisted_name.rs:13:9
|
13 | let tata = 42; //~ERROR use of a blacklisted/placeholder name `tata`
| ^^^^
error: use of a blacklisted/placeholder name `titi`
--> $DIR/conf_french_blacklisted_name.rs:14:9
|
14 | let titi = 42; //~ERROR use of a blacklisted/placeholder name `titi`
| ^^^^
error: use of a blacklisted/placeholder name `toto`
--> $DIR/conf_french_blacklisted_name.rs:20:10
|
20 | (toto, Some(tata), titi @ Some(_)) => (),
| ^^^^
error: use of a blacklisted/placeholder name `tata`
--> $DIR/conf_french_blacklisted_name.rs:20:21
|
20 | (toto, Some(tata), titi @ Some(_)) => (),
| ^^^^
error: use of a blacklisted/placeholder name `titi`
--> $DIR/conf_french_blacklisted_name.rs:20:28
|
20 | (toto, Some(tata), titi @ Some(_)) => (),
| ^^^^^^^^^^^^^^
error: aborting due to 7 previous errors

View file

@ -0,0 +1,4 @@
error: error reading Clippy's configuration file: No such file or directory (os error 2)
error: aborting due to previous error

View file

@ -0,0 +1,14 @@
error: `conf_file` value must be a string
--> $DIR/conf_path_non_string.rs:3:28
|
3 | #![plugin(clippy(conf_file=42))]
| ^^
|
note: Clippy will use default configuration
--> $DIR/conf_path_non_string.rs:3:28
|
3 | #![plugin(clippy(conf_file=42))]
| ^^
error: aborting due to previous error

View file

@ -0,0 +1,4 @@
error: error reading Clippy's configuration file: unknown key `foobar`
error: aborting due to previous error

409
tests/ui/copies.stderr Normal file
View file

@ -0,0 +1,409 @@
error: this `if` has identical blocks
--> $DIR/copies.rs:40:10
|
40 | else { //~ERROR this `if` has identical blocks
| __________^ starting here...
41 | | Foo { bar: 42 };
42 | | 0..10;
43 | | ..;
44 | | 0..;
45 | | ..10;
46 | | 0...10;
47 | | foo();
48 | | }
| |_____^ ...ending here
|
note: lint level defined here
--> $DIR/copies.rs:27:8
|
27 | #[deny(if_same_then_else)]
| ^^^^^^^^^^^^^^^^^
note: same as this
--> $DIR/copies.rs:30:13
|
30 | if true {
| ^
error: this `match` has identical arm bodies
--> $DIR/copies.rs:91:14
|
91 | _ => { //~ERROR this `match` has identical arm bodies
| ______________^ starting here...
92 | | foo();
93 | | let mut a = 42 + [23].len() as i32;
94 | | if true {
95 | | a += 7;
96 | | }
97 | | a = -31-a;
98 | | a
99 | | }
| |_________^ ...ending here
|
note: lint level defined here
--> $DIR/copies.rs:28:8
|
28 | #[deny(match_same_arms)]
| ^^^^^^^^^^^^^^^
note: same as this
--> $DIR/copies.rs:80:15
|
80 | 42 => {
| ^
note: `42` has the same arm body as the `_` wildcard, consider removing it`
--> $DIR/copies.rs:80:15
|
80 | 42 => {
| ^
error: this `match` has identical arm bodies
--> $DIR/copies.rs:107:14
|
107 | _ => 0, //~ERROR this `match` has identical arm bodies
| ^
|
note: same as this
--> $DIR/copies.rs:103:19
|
103 | Abc::A => 0,
| ^
note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it`
--> $DIR/copies.rs:103:19
|
103 | Abc::A => 0,
| ^
error: this `if` has identical blocks
--> $DIR/copies.rs:118:10
|
118 | else { //~ERROR this `if` has identical blocks
| __________^ starting here...
119 | | 42
120 | | };
| |_____^ ...ending here
|
note: same as this
--> $DIR/copies.rs:114:21
|
114 | let _ = if true {
| _____________________^ starting here...
115 | | //~^NOTE same as this
116 | | 42
117 | | }
| |_____^ ...ending here
error: this `if` has identical blocks
--> $DIR/copies.rs:133:10
|
133 | else { //~ERROR this `if` has identical blocks
| ^
|
note: same as this
--> $DIR/copies.rs:122:13
|
122 | if true {
| ^
error: this `if` has identical blocks
--> $DIR/copies.rs:156:10
|
156 | else { //~ERROR this `if` has identical blocks
| ^
|
note: same as this
--> $DIR/copies.rs:144:13
|
144 | if true {
| ^
error: this `if` has identical blocks
--> $DIR/copies.rs:180:19
|
180 | else if foo() { //~ERROR this `if` has identical blocks
| ___________________^ starting here...
181 | | let _ = match 42 {
182 | | 42 => 1,
183 | | a if a > 0 => 2,
184 | | 10...15 => 3,
185 | | _ => 4,
186 | | };
187 | | }
| |_____^ ...ending here
|
note: same as this
--> $DIR/copies.rs:168:13
|
168 | if true {
| _____________^ starting here...
169 | | //~^NOTE same as this
170 | | let _ = match 42 {
171 | | 42 => 1,
172 | | a if a > 0 => 2,
173 | | 10...15 => 3,
174 | | _ => 4,
175 | | };
176 | | }
| |_____^ ...ending here
error: this `if` has identical blocks
--> $DIR/copies.rs:193:10
|
193 | else { //~ERROR this `if` has identical blocks
| __________^ starting here...
194 | | if let Some(a) = Some(42) {}
195 | | }
| |_____^ ...ending here
|
note: same as this
--> $DIR/copies.rs:189:13
|
189 | if true {
| _____________^ starting here...
190 | | //~^NOTE same as this
191 | | if let Some(a) = Some(42) {}
192 | | }
| |_____^ ...ending here
error: this `if` has identical blocks
--> $DIR/copies.rs:201:10
|
201 | else { //~ERROR this `if` has identical blocks
| __________^ starting here...
202 | | if let (1, .., 3) = (1, 2, 3) {}
203 | | }
| |_____^ ...ending here
|
note: same as this
--> $DIR/copies.rs:197:13
|
197 | if true {
| _____________^ starting here...
198 | | //~^NOTE same as this
199 | | if let (1, .., 3) = (1, 2, 3) {}
200 | | }
| |_____^ ...ending here
error: this `match` has identical arm bodies
--> $DIR/copies.rs:258:15
|
258 | 51 => foo(), //~ERROR this `match` has identical arm bodies
| ^^^^^
|
note: same as this
--> $DIR/copies.rs:255:15
|
255 | 42 => foo(),
| ^^^^^
note: consider refactoring into `42 | 51`
--> $DIR/copies.rs:255:15
|
255 | 42 => foo(),
| ^^^^^
error: this `match` has identical arm bodies
--> $DIR/copies.rs:266:17
|
266 | None => 24, //~ERROR this `match` has identical arm bodies
| ^^
|
note: same as this
--> $DIR/copies.rs:263:20
|
263 | Some(_) => 24,
| ^^
note: consider refactoring into `Some(_) | None`
--> $DIR/copies.rs:263:20
|
263 | Some(_) => 24,
| ^^
error: this `match` has identical arm bodies
--> $DIR/copies.rs:290:28
|
290 | (None, Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
| ^^^^^^
|
note: same as this
--> $DIR/copies.rs:287:28
|
287 | (Some(a), None) => bar(a),
| ^^^^^^
note: consider refactoring into `(Some(a), None) | (None, Some(a))`
--> $DIR/copies.rs:287:28
|
287 | (Some(a), None) => bar(a),
| ^^^^^^
error: this `match` has identical arm bodies
--> $DIR/copies.rs:298:26
|
298 | (.., Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
| ^^^^^^
|
note: same as this
--> $DIR/copies.rs:295:26
|
295 | (Some(a), ..) => bar(a),
| ^^^^^^
note: consider refactoring into `(Some(a), ..) | (.., Some(a))`
--> $DIR/copies.rs:295:26
|
295 | (Some(a), ..) => bar(a),
| ^^^^^^
error: this `match` has identical arm bodies
--> $DIR/copies.rs:306:20
|
306 | (.., 3) => 42, //~ERROR this `match` has identical arm bodies
| ^^
|
note: same as this
--> $DIR/copies.rs:303:23
|
303 | (1, .., 3) => 42,
| ^^
note: consider refactoring into `(1, .., 3) | (.., 3)`
--> $DIR/copies.rs:303:23
|
303 | (1, .., 3) => 42,
| ^^
error: this `if` has identical blocks
--> $DIR/copies.rs:313:12
|
313 | } else { //~ERROR this `if` has identical blocks
| ____________^ starting here...
314 | | 0.0
315 | | };
| |_____^ ...ending here
|
note: same as this
--> $DIR/copies.rs:310:21
|
310 | let _ = if true {
| _____________________^ starting here...
311 | | //~^NOTE same as this
312 | | 0.0
313 | | } else { //~ERROR this `if` has identical blocks
| |_____^ ...ending here
error: this `if` has identical blocks
--> $DIR/copies.rs:320:12
|
320 | } else { //~ERROR this `if` has identical blocks
| ____________^ starting here...
321 | | -0.0
322 | | };
| |_____^ ...ending here
|
note: same as this
--> $DIR/copies.rs:317:21
|
317 | let _ = if true {
| _____________________^ starting here...
318 | | //~^NOTE same as this
319 | | -0.0
320 | | } else { //~ERROR this `if` has identical blocks
| |_____^ ...ending here
error: this `if` has identical blocks
--> $DIR/copies.rs:341:12
|
341 | } else { //~ERROR this `if` has identical blocks
| ____________^ starting here...
342 | | std::f32::NAN
343 | | };
| |_____^ ...ending here
|
note: same as this
--> $DIR/copies.rs:338:21
|
338 | let _ = if true {
| _____________________^ starting here...
339 | | //~^NOTE same as this
340 | | std::f32::NAN
341 | | } else { //~ERROR this `if` has identical blocks
| |_____^ ...ending here
error: this `if` has identical blocks
--> $DIR/copies.rs:360:10
|
360 | else { //~ERROR this `if` has identical blocks
| __________^ starting here...
361 | | try!(Ok("foo"));
362 | | }
| |_____^ ...ending here
|
note: same as this
--> $DIR/copies.rs:356:13
|
356 | if true {
| _____________^ starting here...
357 | | //~^NOTE same as this
358 | | try!(Ok("foo"));
359 | | }
| |_____^ ...ending here
error: this `if` has identical blocks
--> $DIR/copies.rs:373:10
|
373 | else { //~ERROR this `if` has identical blocks
| __________^ starting here...
374 | | let foo = "";
375 | | return Ok(&foo[0..]);
376 | | }
| |_____^ ...ending here
|
note: same as this
--> $DIR/copies.rs:364:13
|
364 | if true {
| _____________^ starting here...
365 | | //~^NOTE same as this
366 | | let foo = "";
367 | | return Ok(&foo[0..]);
368 | | }
| |_____^ ...ending here
error: this `if` has the same condition as a previous if
--> $DIR/copies.rs:388:13
|
388 | else if b { //~ERROR this `if` has the same condition as a previous if
| ^
|
note: lint level defined here
--> $DIR/copies.rs:379:8
|
379 | #[deny(ifs_same_cond)]
| ^^^^^^^^^^^^^
note: same as this
--> $DIR/copies.rs:385:8
|
385 | if b {
| ^
error: this `if` has the same condition as a previous if
--> $DIR/copies.rs:394:13
|
394 | else if a == 1 { //~ERROR this `if` has the same condition as a previous if
| ^^^^^^
|
note: same as this
--> $DIR/copies.rs:391:8
|
391 | if a == 1 {
| ^^^^^^
error: this `if` has the same condition as a previous if
--> $DIR/copies.rs:402:13
|
402 | else if 2*a == 1 { //~ERROR this `if` has the same condition as a previous if
| ^^^^^^^^
|
note: same as this
--> $DIR/copies.rs:397:8
|
397 | if 2*a == 1 {
| ^^^^^^^^
error: aborting due to 22 previous errors

View file

@ -0,0 +1,232 @@
error: the function has a cyclomatic complexity of 28
--> $DIR/cyclomatic_complexity.rs:7:1
|
7 | fn main() { //~ERROR the function has a cyclomatic complexity of 28
| ^
|
note: lint level defined here
--> $DIR/cyclomatic_complexity.rs:4:9
|
4 | #![deny(cyclomatic_complexity)]
| ^^^^^^^^^^^^^^^^^^^^^
= 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
|
92 | fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 7
| ^
|
= 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
|
138 | fn lots_of_short_circuits() -> bool { //~ ERROR: the function has a cyclomatic complexity of 1
| _^ starting here...
139 | | true && false && true && false && true && false && true
140 | | }
| |_^ ...ending here
|
= 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
|
143 | fn lots_of_short_circuits2() -> bool { //~ ERROR: the function has a cyclomatic complexity of 1
| _^ starting here...
144 | | true || false || true || false || true || false || true
145 | | }
| |_^ ...ending here
|
= 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
|
148 | fn baa() { //~ ERROR: the function has a cyclomatic complexity of 2
| ^
|
= 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
|
149 | let x = || match 99 { //~ ERROR: the function has a cyclomatic complexity of 2
| _____________^ starting here...
150 | | 0 => 0,
151 | | 1 => 1,
152 | | 2 => 2,
153 | | 4 => 4,
154 | | 6 => 6,
155 | | 9 => 9,
156 | | _ => 42,
157 | | };
| |_____^ ...ending here
|
= 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
|
166 | fn bar() { //~ ERROR: the function has a cyclomatic complexity of 2
| _^ starting here...
167 | | match 99 {
168 | | 0 => println!("hi"),
169 | | _ => println!("bye"),
170 | | }
171 | | }
| |_^ ...ending here
|
= 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
|
185 | fn barr() { //~ ERROR: the function has a cyclomatic complexity of 2
| _^ starting here...
186 | | match 99 {
187 | | 0 => println!("hi"),
188 | | 1 => println!("bla"),
189 | | 2 | 3 => println!("blub"),
190 | | _ => println!("bye"),
191 | | }
192 | | }
| |_^ ...ending here
|
= 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
|
195 | fn barr2() { //~ ERROR: the function has a cyclomatic complexity of 3
| ^
|
= 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
|
211 | fn barrr() { //~ ERROR: the function has a cyclomatic complexity of 2
| _^ starting here...
212 | | match 99 {
213 | | 0 => println!("hi"),
214 | | 1 => panic!("bla"),
215 | | 2 | 3 => println!("blub"),
216 | | _ => println!("bye"),
217 | | }
218 | | }
| |_^ ...ending here
|
= 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
|
221 | fn barrr2() { //~ ERROR: the function has a cyclomatic complexity of 3
| ^
|
= 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
|
237 | fn barrrr() { //~ ERROR: the function has a cyclomatic complexity of 2
| _^ starting here...
238 | | match 99 {
239 | | 0 => println!("hi"),
240 | | 1 => println!("bla"),
241 | | 2 | 3 => panic!("blub"),
242 | | _ => println!("bye"),
243 | | }
244 | | }
| |_^ ...ending here
|
= 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
|
247 | fn barrrr2() { //~ ERROR: the function has a cyclomatic complexity of 3
| ^
|
= 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
|
263 | fn cake() { //~ ERROR: the function has a cyclomatic complexity of 2
| _^ starting here...
264 | | if 4 == 5 {
265 | | println!("yea");
266 | | } else {
267 | | panic!("meh");
268 | | }
269 | | println!("whee");
270 | | }
| |_^ ...ending here
|
= 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
|
274 | pub fn read_file(input_path: &str) -> String { //~ ERROR: the function has a cyclomatic complexity of 4
| ^
|
= 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
|
305 | fn void(void: Void) { //~ ERROR: the function has a cyclomatic complexity of 1
| _^ starting here...
306 | | if true {
307 | | match void {
308 | | }
309 | | }
310 | | }
| |_^ ...ending here
|
= 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
|
319 | fn try() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
| _^ starting here...
320 | | match 5 {
321 | | 5 => Ok(5),
322 | | _ => return Err("bla"),
323 | | }
324 | | }
| |_^ ...ending here
|
= 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
|
327 | fn try_again() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
| ^
|
= 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
|
343 | fn early() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
| ^
|
= 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
|
356 | fn early_ret() -> i32 { //~ ERROR: cyclomatic complexity of 8
| ^
|
= help: you could split it up into multiple smaller functions
error: aborting due to 20 previous errors

View file

@ -0,0 +1,22 @@
error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity_attr_used.rs:11:1
|
11 | fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 3
| _^ starting here...
12 | | if 42 == 43 {
13 | | panic!();
14 | | } else if "cake" == "lie" {
15 | | println!("what?");
16 | | }
17 | | }
| |_^ ...ending here
|
note: lint level defined here
--> $DIR/cyclomatic_complexity_attr_used.rs:3:9
|
3 | #![deny(cyclomatic_complexity)]
| ^^^^^^^^^^^^^^^^^^^^^
= help: you could split it up into multiple smaller functions
error: aborting due to previous error

103
tests/ui/derive.stderr Normal file
View file

@ -0,0 +1,103 @@
error: you are deriving `Hash` but have implemented `PartialEq` explicitly
--> $DIR/derive.rs:18:10
|
18 | #[derive(Hash)]
| ^^^^
|
= note: #[deny(derive_hash_xor_eq)] implied by #[deny(warnings)]
note: lint level defined here
--> $DIR/derive.rs:6:9
|
6 | #![deny(warnings)]
| ^^^^^^^^
note: `PartialEq` implemented here
--> $DIR/derive.rs:22:1
|
22 | impl PartialEq for Bar {
| _^ starting here...
23 | | fn eq(&self, _: &Bar) -> bool { true }
24 | | }
| |_^ ...ending here
error: you are deriving `Hash` but have implemented `PartialEq` explicitly
--> $DIR/derive.rs:26:10
|
26 | #[derive(Hash)]
| ^^^^
|
= note: #[deny(derive_hash_xor_eq)] implied by #[deny(warnings)]
note: `PartialEq` implemented here
--> $DIR/derive.rs:30:1
|
30 | impl PartialEq<Baz> for Baz {
| _^ starting here...
31 | | fn eq(&self, _: &Baz) -> bool { true }
32 | | }
| |_^ ...ending here
error: you are implementing `Hash` explicitly but have derived `PartialEq`
--> $DIR/derive.rs:37:1
|
37 | impl Hash for Bah {
| _^ starting here...
38 | | //~^ ERROR you are implementing `Hash` explicitly but have derived `PartialEq`
39 | | fn hash<H: Hasher>(&self, _: &mut H) {}
40 | | }
| |_^ ...ending here
|
= note: #[deny(derive_hash_xor_eq)] implied by #[deny(warnings)]
note: `PartialEq` implemented here
--> $DIR/derive.rs:34:10
|
34 | #[derive(PartialEq)]
| ^^^^^^^^^
error: you are implementing `Clone` explicitly on a `Copy` type
--> $DIR/derive.rs:45:1
|
45 | impl Clone for Qux {
| _^ starting here...
46 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
47 | | fn clone(&self) -> Self { Qux }
48 | | }
| |_^ ...ending here
|
= note: #[deny(expl_impl_clone_on_copy)] implied by #[deny(warnings)]
note: lint level defined here
--> $DIR/derive.rs:6:9
|
6 | #![deny(warnings)]
| ^^^^^^^^
note: consider deriving `Clone` or removing `Copy`
--> $DIR/derive.rs:45:1
|
45 | impl Clone for Qux {
| _^ starting here...
46 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
47 | | fn clone(&self) -> Self { Qux }
48 | | }
| |_^ ...ending here
error: you are implementing `Clone` explicitly on a `Copy` type
--> $DIR/derive.rs:70:1
|
70 | impl<'a> Clone for Lt<'a> {
| _^ starting here...
71 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
72 | | fn clone(&self) -> Self { unimplemented!() }
73 | | }
| |_^ ...ending here
|
= note: #[deny(expl_impl_clone_on_copy)] implied by #[deny(warnings)]
note: consider deriving `Clone` or removing `Copy`
--> $DIR/derive.rs:70:1
|
70 | impl<'a> Clone for Lt<'a> {
| _^ starting here...
71 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
72 | | fn clone(&self) -> Self { unimplemented!() }
73 | | }
| |_^ ...ending here
error: aborting due to 5 previous errors

View file

@ -0,0 +1,44 @@
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:18:10
|
18 | b || diverge(); //~ ERROR sub-expression diverges
| ^^^^^^^^^
|
note: lint level defined here
--> $DIR/diverging_sub_expression.rs:3:9
|
3 | #![deny(diverging_sub_expression)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:19:10
|
19 | b || A.foo(); //~ ERROR sub-expression diverges
| ^^^^^^^
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:28:26
|
28 | 6 => true || return, //~ ERROR sub-expression diverges
| ^^^^^^
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:29:26
|
29 | 7 => true || continue, //~ ERROR sub-expression diverges
| ^^^^^^^^
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:32:26
|
32 | 3 => true || diverge(), //~ ERROR sub-expression diverges
| ^^^^^^^^^
error: sub-expression diverges
--> $DIR/diverging_sub_expression.rs:37:26
|
37 | _ => true || break, //~ ERROR sub-expression diverges
| ^^^^^
error: aborting due to 6 previous errors

61
tests/ui/dlist.stderr Normal file
View file

@ -0,0 +1,61 @@
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
--> $DIR/dlist.rs:13:16
|
13 | type Baz = LinkedList<u8>; //~ ERROR I see you're using a LinkedList!
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/dlist.rs:6:9
|
6 | #![deny(clippy)]
| ^^^^^^
= 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
|
14 | fn foo(LinkedList<u8>); //~ ERROR I see you're using a LinkedList!
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
= 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
|
15 | const BAR : Option<LinkedList<u8>>; //~ ERROR I see you're using a LinkedList!
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
= 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
|
26 | fn foo(_: LinkedList<u8>) {} //~ ERROR I see you're using a LinkedList!
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
= 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
|
29 | pub fn test(my_favourite_linked_list: LinkedList<u8>) { //~ ERROR I see you're using a LinkedList!
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
= 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
|
33 | pub fn test_ret() -> Option<LinkedList<u8>> { //~ ERROR I see you're using a LinkedList!
| ^^^^^^^^^^^^^^
|
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
= help: a VecDeque might work
error: aborting due to 6 previous errors

182
tests/ui/doc.stderr Normal file
View file

@ -0,0 +1,182 @@
error: you should put `DOC_MARKDOWN` between ticks in the documentation
--> $DIR/doc.rs:1:29
|
1 | //! This file tests for the DOC_MARKDOWN lint
| ^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/doc.rs:7:9
|
7 | #![deny(doc_markdown)]
| ^^^^^^^^^^^^
error: you should put `foo_bar` between ticks in the documentation
--> $DIR/doc.rs:9:9
|
9 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
| ^^^^^^^
error: you should put `foo::bar` between ticks in the documentation
--> $DIR/doc.rs:9:51
|
9 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
| ^^^^^^^^
error: you should put `Foo::some_fun` between ticks in the documentation
--> $DIR/doc.rs:12:84
|
12 | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun
| ^^^^^^^^^^^^^
error: you should put `is::a::global:path` between ticks in the documentation
--> $DIR/doc.rs:15:13
|
15 | /// Here be ::is::a::global:path.
| ^^^^^^^^^^^^^^^^^^^^
error: you should put `NotInCodeBlock` between ticks in the documentation
--> $DIR/doc.rs:17:21
|
17 | /// That's not code ~NotInCodeBlock~.
| ^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:19:5
|
19 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:34:5
|
34 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:42:5
|
42 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:57:5
|
57 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `ß_foo` between ticks in the documentation
--> $DIR/doc.rs:67:5
|
67 | /// ß_foo
| ^^^^^
error: you should put `_foo` between ticks in the documentation
--> $DIR/doc.rs:69:5
|
69 | /// _foo
| ^^^^^
error: you should put `foo_ß` between ticks in the documentation
--> $DIR/doc.rs:73:5
|
73 | /// foo_ß
| ^^^^^
error: you should put `foo_` between ticks in the documentation
--> $DIR/doc.rs:75:5
|
75 | /// foo_
| ^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:91:5
|
91 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `link_with_underscores` between ticks in the documentation
--> $DIR/doc.rs:96:22
|
96 | /// This test has [a link_with_underscores][chunked-example] inside it. See #823.
| ^^^^^^^^^^^^^^^^^^^^^
error: you should put `inline_link2` between ticks in the documentation
--> $DIR/doc.rs:100:21
|
100 | /// It can also be [inline_link2].
| ^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:112:5
|
112 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `CamelCaseThing` between ticks in the documentation
--> $DIR/doc.rs:126:22
|
126 | /// Not a title #897 CamelCaseThing
| ^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:128:5
|
128 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:136:5
|
136 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:150:5
|
150 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `FooBar` between ticks in the documentation
--> $DIR/doc.rs:162:42
|
162 | /** E.g. serialization of an empty list: FooBar
| ^^^^^^
error: you should put `BarQuz` between ticks in the documentation
--> $DIR/doc.rs:167:5
|
167 | And BarQuz too.
| ^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:168:1
|
168 | be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `FooBar` between ticks in the documentation
--> $DIR/doc.rs:176:42
|
176 | /** E.g. serialization of an empty list: FooBar
| ^^^^^^
error: you should put `BarQuz` between ticks in the documentation
--> $DIR/doc.rs:181:5
|
181 | And BarQuz too.
| ^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:182:1
|
182 | be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
--> $DIR/doc.rs:196:5
|
196 | /// be_sure_we_got_to_the_end_of_it
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 29 previous errors

View file

@ -0,0 +1,14 @@
error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op
--> $DIR/double_neg.rs:9:5
|
9 | --x; //~ERROR: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op
| ^^^
|
note: lint level defined here
--> $DIR/double_neg.rs:4:8
|
4 | #[deny(double_neg)]
| ^^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,38 @@
error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:16:5
|
16 | ((0)) //~ERROR Consider removing unnecessary double parentheses
| ^^^^^
|
note: lint level defined here
--> $DIR/double_parens.rs:4:9
|
4 | #![deny(double_parens)]
| ^^^^^^^^^^^^^
error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:20:14
|
20 | dummy_fn((0)); //~ERROR Consider removing unnecessary double parentheses
| ^^^
error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:24:20
|
24 | x.dummy_method((0)); //~ERROR Consider removing unnecessary double parentheses
| ^^^
error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:28:5
|
28 | ((1, 2)) //~ERROR Consider removing unnecessary double parentheses
| ^^^^^^^^
error: Consider removing unnecessary double parentheses
--> $DIR/double_parens.rs:32:5
|
32 | (()) //~ERROR Consider removing unnecessary double parentheses
| ^^^^
error: aborting due to 5 previous errors

View file

@ -0,0 +1,228 @@
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:12:5
|
12 | drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/drop_forget_ref.rs:4:9
|
4 | #![deny(drop_ref, forget_ref)]
| ^^^^^^^^
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:12:10
|
12 | drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:13:5
|
13 | forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/drop_forget_ref.rs:4:19
|
4 | #![deny(drop_ref, forget_ref)]
| ^^^^^^^^^^
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:13:12
|
13 | forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:16:5
|
16 | drop(&owned1); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:16:10
|
16 | drop(&owned1); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:17:5
|
17 | drop(&&owned1); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^^^^
|
note: argument has type &&SomeStruct
--> $DIR/drop_forget_ref.rs:17:10
|
17 | drop(&&owned1); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:18:5
|
18 | drop(&mut owned1); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^^^^^^^
|
note: argument has type &mut SomeStruct
--> $DIR/drop_forget_ref.rs:18:10
|
18 | drop(&mut owned1); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:21:5
|
21 | forget(&owned2); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:21:12
|
21 | forget(&owned2); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:22:5
|
22 | forget(&&owned2); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^^^^^^
|
note: argument has type &&SomeStruct
--> $DIR/drop_forget_ref.rs:22:12
|
22 | forget(&&owned2); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:23:5
|
23 | forget(&mut owned2); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^^^^^^^^^
|
note: argument has type &mut SomeStruct
--> $DIR/drop_forget_ref.rs:23:12
|
23 | forget(&mut owned2); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:27:5
|
27 | drop(reference1); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:27:10
|
27 | drop(reference1); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:28:5
|
28 | forget(&*reference1); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^^^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:28:12
|
28 | forget(&*reference1); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:31:5
|
31 | drop(reference2); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^^^^^^
|
note: argument has type &mut SomeStruct
--> $DIR/drop_forget_ref.rs:31:10
|
31 | drop(reference2); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:33:5
|
33 | forget(reference3); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^^^^^^^^
|
note: argument has type &mut SomeStruct
--> $DIR/drop_forget_ref.rs:33:12
|
33 | forget(reference3); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:36:5
|
36 | drop(reference4); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:36:10
|
36 | drop(reference4); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:37:5
|
37 | forget(reference4); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:37:12
|
37 | forget(reference4); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:42:5
|
42 | drop(&val); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^
|
note: argument has type &T
--> $DIR/drop_forget_ref.rs:42:10
|
42 | drop(&val); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:48:5
|
48 | forget(&val); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^^
|
note: argument has type &T
--> $DIR/drop_forget_ref.rs:48:12
|
48 | forget(&val); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:56:5
|
56 | std::mem::drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:56:20
|
56 | std::mem::drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
| ^^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:59:5
|
59 | std::mem::forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:59:22
|
59 | std::mem::forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument
| ^^^^^^^^^^^
error: aborting due to 18 previous errors

View file

@ -0,0 +1,14 @@
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
|
7 | fn join_the_dark_side(darth: i32, _darth: i32) {} //~ERROR `darth` already exists
| ^^^^^
|
note: lint level defined here
--> $DIR/duplicate_underscore_argument.rs:4:9
|
4 | #![deny(duplicate_underscore_argument)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,19 @@
error: enum with no variants
--> $DIR/empty_enum.rs:7:1
|
7 | enum Empty {} //~ ERROR enum with no variants
| ^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/empty_enum.rs:5:9
|
5 | #![deny(empty_enum)]
| ^^^^^^^^^^
help: consider using the uninhabited type `!` or a wrapper around it
--> $DIR/empty_enum.rs:7:1
|
7 | enum Empty {} //~ ERROR enum with no variants
| ^^^^^^^^^^^^^
error: aborting due to previous error

70
tests/ui/entry.stderr Normal file
View file

@ -0,0 +1,70 @@
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:13:5
|
13 | if !m.contains_key(&k) { m.insert(k, v); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/entry.rs:5:9
|
5 | #![deny(map_entry)]
| ^^^^^^^^^
help: consider using
| m.entry(k).or_insert(v)
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:20:5
|
20 | if !m.contains_key(&k) { foo(); m.insert(k, v); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider using
| m.entry(k)
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:27:5
|
27 | if !m.contains_key(&k) { m.insert(k, v) } else { None };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider using
| m.entry(k);
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:34:5
|
34 | if m.contains_key(&k) { None } else { m.insert(k, v) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider using
| m.entry(k);
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:41:5
|
41 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider using
| m.entry(k);
error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:48:5
|
48 | if m.contains_key(&k) { None } else { foo(); m.insert(k, v) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider using
| m.entry(k);
error: usage of `contains_key` followed by `insert` on a `BTreeMap`
--> $DIR/entry.rs:55:5
|
55 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider using
| m.entry(k);
error: aborting due to 7 previous errors

View file

@ -0,0 +1,23 @@
error: don't use glob imports for enum variants
--> $DIR/enum_glob_use.rs:6:1
|
6 | use std::cmp::Ordering::*; //~ ERROR: don't use glob imports for enum variants
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_glob_use)] implied by #[deny(clippy_pedantic)]
note: lint level defined here
--> $DIR/enum_glob_use.rs:3:17
|
3 | #![deny(clippy, clippy_pedantic)]
| ^^^^^^^^^^^^^^^
error: don't use glob imports for enum variants
--> $DIR/enum_glob_use.rs:12:1
|
12 | use self::Enum::*; //~ ERROR: don't use glob imports for enum variants
| ^^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_glob_use)] implied by #[deny(clippy_pedantic)]
error: aborting due to 2 previous errors

View file

@ -0,0 +1,127 @@
error: Variant name ends with the enum's name
--> $DIR/enum_variants.rs:14:5
|
14 | cFoo, //~ ERROR: Variant name ends with the enum's name
| ^^^^
|
= 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)]
| ^^^^^^
error: Variant name starts with the enum's name
--> $DIR/enum_variants.rs:25:5
|
25 | FoodGood, //~ ERROR: Variant name starts with the enum's name
| ^^^^^^^^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
error: Variant name starts with the enum's name
--> $DIR/enum_variants.rs:26:5
|
26 | FoodMiddle, //~ ERROR: Variant name starts with the enum's name
| ^^^^^^^^^^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
error: Variant name starts with the enum's name
--> $DIR/enum_variants.rs:27:5
|
27 | FoodBad, //~ ERROR: Variant name starts with the enum's name
| ^^^^^^^
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
error: All variants have the same prefix: `Food`
--> $DIR/enum_variants.rs:24:1
|
24 | enum Food { //~ ERROR: All variants have the same prefix: `Food`
| _^ starting here...
25 | | FoodGood, //~ ERROR: Variant name starts with the enum's name
26 | | FoodMiddle, //~ ERROR: Variant name starts with the enum's name
27 | | FoodBad, //~ ERROR: Variant name starts with the enum's name
28 | | }
| |_^ ...ending here
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= 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
|
34 | enum BadCallType { //~ ERROR: All variants have the same prefix: `CallType`
| _^ starting here...
35 | | CallTypeCall,
36 | | CallTypeCreate,
37 | | CallTypeDestroy,
38 | | }
| |_^ ...ending here
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= 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
|
45 | enum Consts { //~ ERROR: All variants have the same prefix: `Constant`
| _^ starting here...
46 | | ConstantInt,
47 | | ConstantCake,
48 | | ConstantLie,
49 | | }
| |_^ ...ending here
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= 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
|
78 | enum Seallll { //~ ERROR: All variants have the same prefix: `With`
| _^ starting here...
79 | | WithOutCake,
80 | | WithOutTea,
81 | | WithOut,
82 | | }
| |_^ ...ending here
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= 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
|
84 | enum NonCaps { //~ ERROR: All variants have the same prefix: `Prefix`
| _^ starting here...
85 | | Prefix的,
86 | | PrefixTea,
87 | | PrefixCake,
88 | | }
| |_^ ...ending here
|
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= 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
|
90 | pub enum PubSeall { //~ ERROR: All variants have the same prefix:
| _^ starting here...
91 | | WithOutCake,
92 | | WithOutTea,
93 | | WithOut,
94 | | }
| |_^ ...ending here
|
note: lint level defined here
--> $DIR/enum_variants.rs:3:17
|
3 | #![deny(clippy, pub_enum_variant_names)]
| ^^^^^^^^^^^^^^^^^^^^^^
= help: remove the prefixes and use full paths to the variants instead of glob imports
error: aborting due to 10 previous errors

View file

@ -0,0 +1,71 @@
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:10:5
|
10 | X = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/enums_clike.rs:4:9
|
4 | #![deny(clippy)]
| ^^^^^^
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:17:5
|
17 | X = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:20:5
|
20 | A = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
| ^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:27:5
|
27 | Z = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
| ^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:28:5
|
28 | A = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:30:5
|
30 | C = (std::i32::MIN as isize) - 1, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:36:5
|
36 | Z = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
| ^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
error: Clike enum variant discriminant is not portable to 32-bit targets
--> $DIR/enums_clike.rs:37:5
|
37 | A = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
| ^^^^^^^^^^^^^^^^^
|
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
error: aborting due to 8 previous errors

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