diff --git a/ci/base-tests.sh b/ci/base-tests.sh index 6eeab6671cb..dfc5ad99e0c 100755 --- a/ci/base-tests.sh +++ b/ci/base-tests.sh @@ -28,6 +28,9 @@ cd clippy_dev && cargo test && cd .. ./util/dev update_lints --check cargo +nightly fmt --all -- --check + +#avoid loop spam +set +ex # make sure tests are formatted # some lints are sensitive to formatting, exclude some files @@ -36,7 +39,9 @@ for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/fo rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true done -if $needs_reformatting - "Tests need reformatting!" +if [ "${needs_reformatting}" = true] ; then + echo "Tests need reformatting!" exit 2 fi + +set -ex diff --git a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr index dd414657c28..e67cdd8f9dd 100644 --- a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr +++ b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr @@ -1,45 +1,45 @@ error: use of a blacklisted/placeholder name `toto` - --> $DIR/conf_french_blacklisted_name.rs:19:9 + --> $DIR/conf_french_blacklisted_name.rs:15:9 | -19 | fn test(toto: ()) {} +15 | fn test(toto: ()) {} | ^^^^ | = note: `-D clippy::blacklisted-name` implied by `-D warnings` error: use of a blacklisted/placeholder name `toto` - --> $DIR/conf_french_blacklisted_name.rs:22:9 + --> $DIR/conf_french_blacklisted_name.rs:18:9 | -22 | let toto = 42; +18 | let toto = 42; | ^^^^ error: use of a blacklisted/placeholder name `tata` - --> $DIR/conf_french_blacklisted_name.rs:23:9 + --> $DIR/conf_french_blacklisted_name.rs:19:9 | -23 | let tata = 42; +19 | let tata = 42; | ^^^^ error: use of a blacklisted/placeholder name `titi` - --> $DIR/conf_french_blacklisted_name.rs:24:9 + --> $DIR/conf_french_blacklisted_name.rs:20:9 | -24 | let titi = 42; +20 | let titi = 42; | ^^^^ error: use of a blacklisted/placeholder name `toto` - --> $DIR/conf_french_blacklisted_name.rs:30:10 + --> $DIR/conf_french_blacklisted_name.rs:26:10 | -30 | (toto, Some(tata), titi @ Some(_)) => (), +26 | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a blacklisted/placeholder name `tata` - --> $DIR/conf_french_blacklisted_name.rs:30:21 + --> $DIR/conf_french_blacklisted_name.rs:26:21 | -30 | (toto, Some(tata), titi @ Some(_)) => (), +26 | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a blacklisted/placeholder name `titi` - --> $DIR/conf_french_blacklisted_name.rs:30:28 + --> $DIR/conf_french_blacklisted_name.rs:26:28 | -30 | (toto, Some(tata), titi @ Some(_)) => (), +26 | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui-toml/toml_trivially_copy/test.stderr b/tests/ui-toml/toml_trivially_copy/test.stderr index ad3ca831fd7..efa9223bde8 100644 --- a/tests/ui-toml/toml_trivially_copy/test.stderr +++ b/tests/ui-toml/toml_trivially_copy/test.stderr @@ -1,15 +1,15 @@ error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/test.rs:23:11 + --> $DIR/test.rs:20:11 | -23 | fn bad(x: &u16, y: &Foo) { +20 | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `u16` | = note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/test.rs:23:20 + --> $DIR/test.rs:20:20 | -23 | fn bad(x: &u16, y: &Foo) { +20 | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `Foo` error: aborting due to 2 previous errors diff --git a/tests/ui/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index 895794da71a..00f7086dc55 100644 --- a/tests/ui/absurd-extreme-comparisons.stderr +++ b/tests/ui/absurd-extreme-comparisons.stderr @@ -1,144 +1,144 @@ error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:17:5 + --> $DIR/absurd-extreme-comparisons.rs:23:5 | -17 | u <= 0; +23 | u <= 0; | ^^^^^^ | = note: `-D clippy::absurd-extreme-comparisons` implied by `-D warnings` = help: because 0 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 0 instead 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 + --> $DIR/absurd-extreme-comparisons.rs:24:5 | -18 | u <= Z; +24 | 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:19:5 + --> $DIR/absurd-extreme-comparisons.rs:25:5 | -19 | u < Z; +25 | 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:20:5 + --> $DIR/absurd-extreme-comparisons.rs:26:5 | -20 | Z >= u; +26 | 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:21:5 + --> $DIR/absurd-extreme-comparisons.rs:27:5 | -21 | Z > u; +27 | 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:22:5 + --> $DIR/absurd-extreme-comparisons.rs:28:5 | -22 | u > std::u32::MAX; +28 | 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:23:5 + --> $DIR/absurd-extreme-comparisons.rs:29:5 | -23 | u >= std::u32::MAX; +29 | 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:24:5 + --> $DIR/absurd-extreme-comparisons.rs:30:5 | -24 | std::u32::MAX < u; +30 | 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:25:5 + --> $DIR/absurd-extreme-comparisons.rs:31:5 | -25 | std::u32::MAX <= u; +31 | 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:26:5 + --> $DIR/absurd-extreme-comparisons.rs:32:5 | -26 | 1-1 > u; +32 | 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:27:5 + --> $DIR/absurd-extreme-comparisons.rs:33:5 | -27 | u >= !0; +33 | 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:28:5 + --> $DIR/absurd-extreme-comparisons.rs:34:5 | -28 | u <= 12 - 2*6; +34 | 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:30:5 + --> $DIR/absurd-extreme-comparisons.rs:36:5 | -30 | i < -127 - 1; +36 | 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:31:5 + --> $DIR/absurd-extreme-comparisons.rs:37:5 | -31 | std::i8::MAX >= i; +37 | 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:32:5 + --> $DIR/absurd-extreme-comparisons.rs:38:5 | -32 | 3-7 < std::i32::MIN; +38 | 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:34:5 + --> $DIR/absurd-extreme-comparisons.rs:40:5 | -34 | b >= true; +40 | 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:35:5 + --> $DIR/absurd-extreme-comparisons.rs:41:5 | -35 | false > b; +41 | false > b; | ^^^^^^^^^ | = help: because false is the minimum value for this type, this comparison is always false error: <-comparison of unit values detected. This will always be false - --> $DIR/absurd-extreme-comparisons.rs:38:5 + --> $DIR/absurd-extreme-comparisons.rs:44:5 | -38 | () < {}; +44 | () < {}; | ^^^^^^^ | = note: #[deny(clippy::unit_cmp)] on by default diff --git a/tests/ui/approx_const.stderr b/tests/ui/approx_const.stderr index a765ffb64de..cee7fe6919a 100644 --- a/tests/ui/approx_const.stderr +++ b/tests/ui/approx_const.stderr @@ -1,117 +1,117 @@ error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly - --> $DIR/approx_const.rs:17:16 + --> $DIR/approx_const.rs:13:16 | -17 | let my_e = 2.7182; +13 | let my_e = 2.7182; | ^^^^^^ | = note: `-D clippy::approx-constant` implied by `-D warnings` error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly - --> $DIR/approx_const.rs:18:20 + --> $DIR/approx_const.rs:14:20 | -18 | let almost_e = 2.718; +14 | let almost_e = 2.718; | ^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_1_PI` found. Consider using it directly - --> $DIR/approx_const.rs:21:24 + --> $DIR/approx_const.rs:17:24 | -21 | let my_1_frac_pi = 0.3183; +17 | let my_1_frac_pi = 0.3183; | ^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly - --> $DIR/approx_const.rs:24:28 + --> $DIR/approx_const.rs:20:28 | -24 | let my_frac_1_sqrt_2 = 0.70710678; +20 | let my_frac_1_sqrt_2 = 0.70710678; | ^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly - --> $DIR/approx_const.rs:25:32 + --> $DIR/approx_const.rs:21:32 | -25 | let almost_frac_1_sqrt_2 = 0.70711; +21 | let almost_frac_1_sqrt_2 = 0.70711; | ^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_2_PI` found. Consider using it directly - --> $DIR/approx_const.rs:28:24 + --> $DIR/approx_const.rs:24:24 | -28 | let my_frac_2_pi = 0.63661977; +24 | let my_frac_2_pi = 0.63661977; | ^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found. Consider using it directly - --> $DIR/approx_const.rs:31:27 + --> $DIR/approx_const.rs:27:27 | -31 | let my_frac_2_sq_pi = 1.128379; +27 | let my_frac_2_sq_pi = 1.128379; | ^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_2` found. Consider using it directly - --> $DIR/approx_const.rs:34:24 + --> $DIR/approx_const.rs:30:24 | -34 | let my_frac_pi_2 = 1.57079632679; +30 | let my_frac_pi_2 = 1.57079632679; | ^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_3` found. Consider using it directly - --> $DIR/approx_const.rs:37:24 + --> $DIR/approx_const.rs:33:24 | -37 | let my_frac_pi_3 = 1.04719755119; +33 | let my_frac_pi_3 = 1.04719755119; | ^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_4` found. Consider using it directly - --> $DIR/approx_const.rs:40:24 + --> $DIR/approx_const.rs:36:24 | -40 | let my_frac_pi_4 = 0.785398163397; +36 | let my_frac_pi_4 = 0.785398163397; | ^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_6` found. Consider using it directly - --> $DIR/approx_const.rs:43:24 + --> $DIR/approx_const.rs:39:24 | -43 | let my_frac_pi_6 = 0.523598775598; +39 | let my_frac_pi_6 = 0.523598775598; | ^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_8` found. Consider using it directly - --> $DIR/approx_const.rs:46:24 + --> $DIR/approx_const.rs:42:24 | -46 | let my_frac_pi_8 = 0.3926990816987; +42 | let my_frac_pi_8 = 0.3926990816987; | ^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LN_10` found. Consider using it directly - --> $DIR/approx_const.rs:49:20 + --> $DIR/approx_const.rs:45:20 | -49 | let my_ln_10 = 2.302585092994046; +45 | let my_ln_10 = 2.302585092994046; | ^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LN_2` found. Consider using it directly - --> $DIR/approx_const.rs:52:19 + --> $DIR/approx_const.rs:48:19 | -52 | let my_ln_2 = 0.6931471805599453; +48 | let my_ln_2 = 0.6931471805599453; | ^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LOG10_E` found. Consider using it directly - --> $DIR/approx_const.rs:55:22 + --> $DIR/approx_const.rs:51:22 | -55 | let my_log10_e = 0.4342944819032518; +51 | let my_log10_e = 0.4342944819032518; | ^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LOG2_E` found. Consider using it directly - --> $DIR/approx_const.rs:58:21 + --> $DIR/approx_const.rs:54:21 | -58 | let my_log2_e = 1.4426950408889634; +54 | let my_log2_e = 1.4426950408889634; | ^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly - --> $DIR/approx_const.rs:61:17 + --> $DIR/approx_const.rs:57:17 | -61 | let my_pi = 3.1415; +57 | let my_pi = 3.1415; | ^^^^^^ error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly - --> $DIR/approx_const.rs:62:21 + --> $DIR/approx_const.rs:58:21 | -62 | let almost_pi = 3.14; +58 | let almost_pi = 3.14; | ^^^^ error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it directly - --> $DIR/approx_const.rs:65:18 + --> $DIR/approx_const.rs:61:18 | -65 | let my_sq2 = 1.4142; +61 | let my_sq2 = 1.4142; | ^^^^^^ error: aborting due to 19 previous errors diff --git a/tests/ui/arithmetic.stderr b/tests/ui/arithmetic.stderr index f3a1db16b48..1dff9941bb2 100644 --- a/tests/ui/arithmetic.stderr +++ b/tests/ui/arithmetic.stderr @@ -1,72 +1,72 @@ error: integer arithmetic detected - --> $DIR/arithmetic.rs:17:5 + --> $DIR/arithmetic.rs:22:5 | -17 | 1 + i; +22 | 1 + i; | ^^^^^ | = note: `-D clippy::integer-arithmetic` implied by `-D warnings` error: integer arithmetic detected - --> $DIR/arithmetic.rs:18:5 + --> $DIR/arithmetic.rs:23:5 | -18 | i * 2; +23 | i * 2; | ^^^^^ error: integer arithmetic detected - --> $DIR/arithmetic.rs:19:5 + --> $DIR/arithmetic.rs:24:5 | -19 | / 1 % -20 | | i / 2; // no error, this is part of the expression in the preceding line +24 | / 1 % +25 | | i / 2; // no error, this is part of the expression in the preceding line | |_________^ error: integer arithmetic detected - --> $DIR/arithmetic.rs:21:5 + --> $DIR/arithmetic.rs:26:5 | -21 | i - 2 + 2 - i; +26 | i - 2 + 2 - i; | ^^^^^^^^^^^^^ error: integer arithmetic detected - --> $DIR/arithmetic.rs:22:5 + --> $DIR/arithmetic.rs:27:5 | -22 | -i; +27 | -i; | ^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:32:5 + --> $DIR/arithmetic.rs:37:5 | -32 | f * 2.0; +37 | f * 2.0; | ^^^^^^^ | = note: `-D clippy::float-arithmetic` implied by `-D warnings` error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:34:5 + --> $DIR/arithmetic.rs:39:5 | -34 | 1.0 + f; +39 | 1.0 + f; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:35:5 + --> $DIR/arithmetic.rs:40:5 | -35 | f * 2.0; +40 | f * 2.0; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:36:5 + --> $DIR/arithmetic.rs:41:5 | -36 | f / 2.0; +41 | f / 2.0; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:37:5 + --> $DIR/arithmetic.rs:42:5 | -37 | f - 2.0 * 4.2; +42 | f - 2.0 * 4.2; | ^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:38:5 + --> $DIR/arithmetic.rs:43:5 | -38 | -f; +43 | -f; | ^^ error: aborting due to 11 previous errors diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index 20ed51334ab..7acbdc89984 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -1,57 +1,57 @@ error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:17:5 + --> $DIR/assign_ops.rs:14:5 | -17 | a = a + 1; +14 | a = a + 1; | ^^^^^^^^^ help: replace it with: `a += 1` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` +error: manual implementation of an assign operation + --> $DIR/assign_ops.rs:15:5 + | +15 | a = 1 + a; + | ^^^^^^^^^ help: replace it with: `a += 1` + +error: manual implementation of an assign operation + --> $DIR/assign_ops.rs:16:5 + | +16 | a = a - 1; + | ^^^^^^^^^ help: replace it with: `a -= 1` + +error: manual implementation of an assign operation + --> $DIR/assign_ops.rs:17:5 + | +17 | a = a * 99; + | ^^^^^^^^^^ help: replace it with: `a *= 99` + error: manual implementation of an assign operation --> $DIR/assign_ops.rs:18:5 | -18 | a = 1 + a; - | ^^^^^^^^^ help: replace it with: `a += 1` +18 | a = 42 * a; + | ^^^^^^^^^^ help: replace it with: `a *= 42` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:19:5 | -19 | a = a - 1; - | ^^^^^^^^^ help: replace it with: `a -= 1` +19 | a = a / 2; + | ^^^^^^^^^ help: replace it with: `a /= 2` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:20:5 | -20 | a = a * 99; - | ^^^^^^^^^^ help: replace it with: `a *= 99` +20 | a = a % 5; + | ^^^^^^^^^ help: replace it with: `a %= 5` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:21:5 | -21 | a = 42 * a; - | ^^^^^^^^^^ help: replace it with: `a *= 42` - -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:22:5 - | -22 | a = a / 2; - | ^^^^^^^^^ help: replace it with: `a /= 2` - -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:23:5 - | -23 | a = a % 5; - | ^^^^^^^^^ help: replace it with: `a %= 5` - -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:24:5 - | -24 | a = a & 1; +21 | a = a & 1; | ^^^^^^^^^ help: replace it with: `a &= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:30:5 + --> $DIR/assign_ops.rs:27:5 | -30 | s = s + "bla"; +27 | s = s + "bla"; | ^^^^^^^^^^^^^ help: replace it with: `s += "bla"` error: aborting due to 9 previous errors diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index bd49c3cdd80..26ff079ad62 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -1,135 +1,135 @@ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:18:5 + --> $DIR/assign_ops2.rs:14:5 | -18 | a += a + 1; +14 | a += a + 1; | ^^^^^^^^^^ | = note: `-D clippy::misrefactored-assign-op` implied by `-D warnings` help: Did you mean a = a + 1 or a = a + a + 1? Consider replacing it with | -18 | a += 1; +14 | a += 1; | ^^^^^^ help: or | -18 | a = a + a + 1; +14 | a = a + a + 1; | ^^^^^^^^^^^^^ +error: variable appears on both sides of an assignment operation + --> $DIR/assign_ops2.rs:15:5 + | +15 | a += 1 + a; + | ^^^^^^^^^^ +help: Did you mean a = a + 1 or a = a + 1 + a? Consider replacing it with + | +15 | a += 1; + | ^^^^^^ +help: or + | +15 | a = a + 1 + a; + | ^^^^^^^^^^^^^ + +error: variable appears on both sides of an assignment operation + --> $DIR/assign_ops2.rs:16:5 + | +16 | a -= a - 1; + | ^^^^^^^^^^ +help: Did you mean a = a - 1 or a = a - (a - 1)? Consider replacing it with + | +16 | a -= 1; + | ^^^^^^ +help: or + | +16 | a = a - (a - 1); + | ^^^^^^^^^^^^^^^ + +error: variable appears on both sides of an assignment operation + --> $DIR/assign_ops2.rs:17:5 + | +17 | a *= a * 99; + | ^^^^^^^^^^^ +help: Did you mean a = a * 99 or a = a * a * 99? Consider replacing it with + | +17 | a *= 99; + | ^^^^^^^ +help: or + | +17 | a = a * a * 99; + | ^^^^^^^^^^^^^^ + +error: variable appears on both sides of an assignment operation + --> $DIR/assign_ops2.rs:18:5 + | +18 | a *= 42 * a; + | ^^^^^^^^^^^ +help: Did you mean a = a * 42 or a = a * 42 * a? Consider replacing it with + | +18 | a *= 42; + | ^^^^^^^ +help: or + | +18 | a = a * 42 * a; + | ^^^^^^^^^^^^^^ + error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:19:5 | -19 | a += 1 + a; +19 | a /= a / 2; | ^^^^^^^^^^ -help: Did you mean a = a + 1 or a = a + 1 + a? Consider replacing it with +help: Did you mean a = a / 2 or a = a / (a / 2)? Consider replacing it with | -19 | a += 1; +19 | a /= 2; | ^^^^^^ help: or | -19 | a = a + 1 + a; - | ^^^^^^^^^^^^^ +19 | a = a / (a / 2); + | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:20:5 | -20 | a -= a - 1; +20 | a %= a % 5; | ^^^^^^^^^^ -help: Did you mean a = a - 1 or a = a - (a - 1)? Consider replacing it with +help: Did you mean a = a % 5 or a = a % (a % 5)? Consider replacing it with | -20 | a -= 1; +20 | a %= 5; | ^^^^^^ help: or | -20 | a = a - (a - 1); +20 | a = a % (a % 5); | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:21:5 | -21 | a *= a * 99; - | ^^^^^^^^^^^ -help: Did you mean a = a * 99 or a = a * a * 99? Consider replacing it with +21 | a &= a & 1; + | ^^^^^^^^^^ +help: Did you mean a = a & 1 or a = a & a & 1? Consider replacing it with | -21 | a *= 99; - | ^^^^^^^ +21 | a &= 1; + | ^^^^^^ help: or | -21 | a = a * a * 99; - | ^^^^^^^^^^^^^^ +21 | a = a & a & 1; + | ^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:22:5 | -22 | a *= 42 * a; - | ^^^^^^^^^^^ -help: Did you mean a = a * 42 or a = a * 42 * a? Consider replacing it with - | -22 | a *= 42; - | ^^^^^^^ -help: or - | -22 | a = a * 42 * a; - | ^^^^^^^^^^^^^^ - -error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:23:5 - | -23 | a /= a / 2; - | ^^^^^^^^^^ -help: Did you mean a = a / 2 or a = a / (a / 2)? Consider replacing it with - | -23 | a /= 2; - | ^^^^^^ -help: or - | -23 | a = a / (a / 2); - | ^^^^^^^^^^^^^^^ - -error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:24:5 - | -24 | a %= a % 5; - | ^^^^^^^^^^ -help: Did you mean a = a % 5 or a = a % (a % 5)? Consider replacing it with - | -24 | a %= 5; - | ^^^^^^ -help: or - | -24 | a = a % (a % 5); - | ^^^^^^^^^^^^^^^ - -error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:25:5 - | -25 | a &= a & 1; - | ^^^^^^^^^^ -help: Did you mean a = a & 1 or a = a & a & 1? Consider replacing it with - | -25 | a &= 1; - | ^^^^^^ -help: or - | -25 | a = a & a & 1; - | ^^^^^^^^^^^^^ - -error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:26:5 - | -26 | a *= a * a; +22 | a *= a * a; | ^^^^^^^^^^ help: Did you mean a = a * a or a = a * a * a? Consider replacing it with | -26 | a *= a; +22 | a *= a; | ^^^^^^ help: or | -26 | a = a * a * a; +22 | a = a * a * a; | ^^^^^^^^^^^^^ error: manual implementation of an assign operation - --> $DIR/assign_ops2.rs:63:5 + --> $DIR/assign_ops2.rs:59:5 | -63 | buf = buf + cows.clone(); +59 | buf = buf + cows.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index a361d0968f5..1331fa2912c 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -1,23 +1,23 @@ error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea - --> $DIR/attrs.rs:16:1 + --> $DIR/attrs.rs:12:1 | -16 | #[inline(always)] +12 | #[inline(always)] | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::inline-always` implied by `-D warnings` error: the since field must contain a semver-compliant version - --> $DIR/attrs.rs:37:14 + --> $DIR/attrs.rs:32:14 | -37 | #[deprecated(since = "forever")] +32 | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::deprecated-semver` implied by `-D warnings` error: the since field must contain a semver-compliant version - --> $DIR/attrs.rs:40:14 + --> $DIR/attrs.rs:35:14 | -40 | #[deprecated(since = "1")] +35 | #[deprecated(since = "1")] | ^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/author/matches.stderr b/tests/ui/author/matches.stderr index d78a173316b..4b895b0b8e3 100644 --- a/tests/ui/author/matches.stderr +++ b/tests/ui/author/matches.stderr @@ -1,14 +1,14 @@ error: returning the result of a let binding from a block. Consider returning the expression directly. - --> $DIR/matches.rs:19:13 + --> $DIR/matches.rs:18:13 | -19 | x +18 | x | ^ | = note: `-D clippy::let-and-return` implied by `-D warnings` note: this expression can be directly returned - --> $DIR/matches.rs:18:21 + --> $DIR/matches.rs:17:21 | -18 | let x = 3; +17 | let x = 3; | ^ error: aborting due to previous error diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr index f0f450fc169..853f5a992f3 100644 --- a/tests/ui/bit_masks.stderr +++ b/tests/ui/bit_masks.stderr @@ -1,109 +1,109 @@ error: &-masking with zero - --> $DIR/bit_masks.rs:22:5 + --> $DIR/bit_masks.rs:23:5 | -22 | x & 0 == 0; +23 | x & 0 == 0; | ^^^^^^^^^^ | = note: `-D clippy::bad-bit-mask` implied by `-D warnings` error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/bit_masks.rs:22:5 + --> $DIR/bit_masks.rs:23:5 | -22 | x & 0 == 0; +23 | x & 0 == 0; | ^^^^^ | = note: #[deny(clippy::erasing_op)] on by default error: incompatible bit mask: `_ & 2` can never be equal to `1` - --> $DIR/bit_masks.rs:25:5 + --> $DIR/bit_masks.rs:26:5 | -25 | x & 2 == 1; +26 | x & 2 == 1; | ^^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` - --> $DIR/bit_masks.rs:29:5 + --> $DIR/bit_masks.rs:30:5 | -29 | x | 3 == 2; +30 | x | 3 == 2; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 1` will never be higher than `1` - --> $DIR/bit_masks.rs:31:5 + --> $DIR/bit_masks.rs:32:5 | -31 | x & 1 > 1; +32 | x & 1 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` - --> $DIR/bit_masks.rs:35:5 + --> $DIR/bit_masks.rs:36:5 | -35 | x | 2 > 1; +36 | x | 2 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ & 7` can never be equal to `8` - --> $DIR/bit_masks.rs:42:5 + --> $DIR/bit_masks.rs:43:5 | -42 | x & THREE_BITS == 8; +43 | x & THREE_BITS == 8; | ^^^^^^^^^^^^^^^^^^^ error: incompatible bit mask: `_ | 7` will never be lower than `7` - --> $DIR/bit_masks.rs:43:5 + --> $DIR/bit_masks.rs:44:5 | -43 | x | EVEN_MORE_REDIRECTION < 7; +44 | x | EVEN_MORE_REDIRECTION < 7; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: &-masking with zero - --> $DIR/bit_masks.rs:45:5 + --> $DIR/bit_masks.rs:46:5 | -45 | 0 & x == 0; +46 | 0 & x == 0; | ^^^^^^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/bit_masks.rs:45:5 + --> $DIR/bit_masks.rs:46:5 | -45 | 0 & x == 0; +46 | 0 & x == 0; | ^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` - --> $DIR/bit_masks.rs:49:5 + --> $DIR/bit_masks.rs:50:5 | -49 | 1 < 2 | x; +50 | 1 < 2 | x; | ^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` - --> $DIR/bit_masks.rs:50:5 + --> $DIR/bit_masks.rs:51:5 | -50 | 2 == 3 | x; +51 | 2 == 3 | x; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 2` can never be equal to `1` - --> $DIR/bit_masks.rs:51:5 + --> $DIR/bit_masks.rs:52:5 | -51 | 1 == x & 2; +52 | 1 == x & 2; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly - --> $DIR/bit_masks.rs:62:5 + --> $DIR/bit_masks.rs:63:5 | -62 | x | 1 > 3; +63 | x | 1 > 3; | ^^^^^^^^^ | = note: `-D clippy::ineffective-bit-mask` implied by `-D warnings` error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly - --> $DIR/bit_masks.rs:63:5 + --> $DIR/bit_masks.rs:64:5 | -63 | x | 1 < 4; +64 | x | 1 < 4; | ^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly - --> $DIR/bit_masks.rs:64:5 + --> $DIR/bit_masks.rs:65:5 | -64 | x | 1 <= 3; +65 | x | 1 <= 3; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly - --> $DIR/bit_masks.rs:65:5 + --> $DIR/bit_masks.rs:66:5 | -65 | x | 1 >= 8; +66 | x | 1 >= 8; | ^^^^^^^^^^ error: aborting due to 17 previous errors diff --git a/tests/ui/blacklisted_name.stderr b/tests/ui/blacklisted_name.stderr index 1e253eba140..707d36b24b2 100644 --- a/tests/ui/blacklisted_name.stderr +++ b/tests/ui/blacklisted_name.stderr @@ -1,87 +1,87 @@ error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:17:9 + --> $DIR/blacklisted_name.rs:20:9 | -17 | fn test(foo: ()) {} +20 | fn test(foo: ()) {} | ^^^ | = note: `-D clippy::blacklisted-name` implied by `-D warnings` error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:20:9 + --> $DIR/blacklisted_name.rs:23:9 | -20 | let foo = 42; +23 | let foo = 42; | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:21:9 + --> $DIR/blacklisted_name.rs:24:9 | -21 | let bar = 42; +24 | let bar = 42; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:22:9 + --> $DIR/blacklisted_name.rs:25:9 | -22 | let baz = 42; +25 | let baz = 42; | ^^^ error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:28:10 + --> $DIR/blacklisted_name.rs:31:10 | -28 | (foo, Some(bar), baz @ Some(_)) => (), +31 | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:28:20 + --> $DIR/blacklisted_name.rs:31:20 | -28 | (foo, Some(bar), baz @ Some(_)) => (), +31 | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:28:26 + --> $DIR/blacklisted_name.rs:31:26 | -28 | (foo, Some(bar), baz @ Some(_)) => (), +31 | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:33:19 + --> $DIR/blacklisted_name.rs:36:19 | -33 | fn issue_1647(mut foo: u8) { +36 | fn issue_1647(mut foo: u8) { | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:34:13 + --> $DIR/blacklisted_name.rs:37:13 | -34 | let mut bar = 0; +37 | let mut bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:35:21 + --> $DIR/blacklisted_name.rs:38:21 | -35 | if let Some(mut baz) = Some(42) {} +38 | if let Some(mut baz) = Some(42) {} | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:39:13 + --> $DIR/blacklisted_name.rs:42:13 | -39 | let ref bar = 0; +42 | let ref bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:40:21 + --> $DIR/blacklisted_name.rs:43:21 | -40 | if let Some(ref baz) = Some(42) {} +43 | if let Some(ref baz) = Some(42) {} | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:44:17 + --> $DIR/blacklisted_name.rs:47:17 | -44 | let ref mut bar = 0; +47 | let ref mut bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:45:25 + --> $DIR/blacklisted_name.rs:48:25 | -45 | if let Some(ref mut baz) = Some(42) {} +48 | if let Some(ref mut baz) = Some(42) {} | ^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/block_in_if_condition.stderr b/tests/ui/block_in_if_condition.stderr index b0036d1ee23..d83cef26a8b 100644 --- a/tests/ui/block_in_if_condition.stderr +++ b/tests/ui/block_in_if_condition.stderr @@ -1,11 +1,11 @@ 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:40:8 + --> $DIR/block_in_if_condition.rs:35:8 | -40 | if { +35 | if { | ________^ -41 | | let x = 3; -42 | | x == 3 -43 | | } { +36 | | let x = 3; +37 | | x == 3 +38 | | } { | |_____^ | = note: `-D clippy::block-in-if-condition-stmt` implied by `-D warnings` @@ -19,9 +19,9 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; inste } ... error: omit braces around single expression condition - --> $DIR/block_in_if_condition.rs:51:8 + --> $DIR/block_in_if_condition.rs:46:8 | -51 | if { true } { +46 | if { true } { | ^^^^^^^^ | = note: `-D clippy::block-in-if-condition-expr` implied by `-D warnings` @@ -31,21 +31,29 @@ error: omit braces around single expression condition } ... 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:68:49 + --> $DIR/block_in_if_condition.rs:66:17 | -68 | if v == 3 && sky == "blue" && predicate(|x| { let target = 3; x == target }, v) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +66 | |x| { + | _________________^ +67 | | let target = 3; +68 | | x == target +69 | | }, + | |_____________^ 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:71:22 + --> $DIR/block_in_if_condition.rs:75:13 | -71 | if predicate(|x| { let target = 3; x == target }, v) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +75 | |x| { + | _____________^ +76 | | let target = 3; +77 | | x == target +78 | | }, + | |_________^ error: this boolean expression can be simplified - --> $DIR/block_in_if_condition.rs:77:8 + --> $DIR/block_in_if_condition.rs:85:8 | -77 | if true && x == 3 { +85 | if true && x == 3 { | ^^^^^^^^^^^^^^ help: try: `x == 3` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` diff --git a/tests/ui/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index b4a1545b49e..d136bc656b6 100644 --- a/tests/ui/bool_comparison.stderr +++ b/tests/ui/bool_comparison.stderr @@ -1,7 +1,7 @@ error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:17:8 + --> $DIR/bool_comparison.rs:13:8 | -17 | if x == true { "yes" } else { "no" }; +13 | if x == true { | ^^^^^^^^^ help: try simplifying it as shown: `x` | = note: `-D clippy::bool-comparison` implied by `-D warnings` @@ -9,43 +9,43 @@ error: equality checks against true are unnecessary error: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:18:8 | -18 | if x == false { "yes" } else { "no" }; +18 | if x == false { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:19:8 + --> $DIR/bool_comparison.rs:23:8 | -19 | if true == x { "yes" } else { "no" }; +23 | if true == x { | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:20:8 + --> $DIR/bool_comparison.rs:28:8 | -20 | if false == x { "yes" } else { "no" }; +28 | if false == x { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against true can be replaced by a negation - --> $DIR/bool_comparison.rs:21:8 + --> $DIR/bool_comparison.rs:33:8 | -21 | if x != true { "yes" } else { "no" }; +33 | if x != true { | ^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against false are unnecessary - --> $DIR/bool_comparison.rs:22:8 + --> $DIR/bool_comparison.rs:38:8 | -22 | if x != false { "yes" } else { "no" }; +38 | if x != false { | ^^^^^^^^^^ help: try simplifying it as shown: `x` error: inequality checks against true can be replaced by a negation - --> $DIR/bool_comparison.rs:23:8 + --> $DIR/bool_comparison.rs:43:8 | -23 | if true != x { "yes" } else { "no" }; +43 | if true != x { | ^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against false are unnecessary - --> $DIR/bool_comparison.rs:24:8 + --> $DIR/bool_comparison.rs:48:8 | -24 | if false != x { "yes" } else { "no" }; +48 | if false != x { | ^^^^^^^^^^ help: try simplifying it as shown: `x` error: aborting due to 8 previous errors diff --git a/tests/ui/booleans.stderr b/tests/ui/booleans.stderr index 01f821f511f..45205b978ef 100644 --- a/tests/ui/booleans.stderr +++ b/tests/ui/booleans.stderr @@ -1,202 +1,202 @@ error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:22:13 + --> $DIR/booleans.rs:19:13 | -22 | let _ = a && b || a; +19 | let _ = a && b || a; | ^^^^^^^^^^^ help: it would look like the following: `a` | = note: `-D clippy::logic-bug` implied by `-D warnings` help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:22:18 + --> $DIR/booleans.rs:19:18 | -22 | let _ = a && b || a; +19 | let _ = a && b || a; | ^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:24:13 + --> $DIR/booleans.rs:21:13 | -24 | let _ = !true; +21 | let _ = !true; | ^^^^^ help: try: `false` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: this boolean expression can be simplified - --> $DIR/booleans.rs:25:13 + --> $DIR/booleans.rs:22:13 | -25 | let _ = !false; +22 | let _ = !false; | ^^^^^^ help: try: `true` error: this boolean expression can be simplified - --> $DIR/booleans.rs:26:13 + --> $DIR/booleans.rs:23:13 | -26 | let _ = !!a; +23 | let _ = !!a; | ^^^ help: try: `a` error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:27:13 + --> $DIR/booleans.rs:24:13 | -27 | let _ = false && a; +24 | let _ = false && a; | ^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:27:22 + --> $DIR/booleans.rs:24:22 | -27 | let _ = false && a; +24 | let _ = false && a; | ^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:28:13 + --> $DIR/booleans.rs:25:13 | -28 | let _ = false || a; +25 | let _ = false || a; | ^^^^^^^^^^ help: try: `a` error: this boolean expression can be simplified - --> $DIR/booleans.rs:33:13 + --> $DIR/booleans.rs:30:13 | -33 | let _ = !(!a && b); +30 | let _ = !(!a && b); | ^^^^^^^^^^ help: try: `!b || a` error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:43:13 + --> $DIR/booleans.rs:40:13 | -43 | let _ = a == b && a != b; +40 | let _ = a == b && a != b; | ^^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:43:13 + --> $DIR/booleans.rs:40:13 | -43 | let _ = a == b && a != b; +40 | let _ = a == b && a != b; | ^^^^^^ error: this boolean expression can be simplified + --> $DIR/booleans.rs:41:13 + | +41 | let _ = a == b && c == 5 && a == b; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try + | +41 | let _ = a == b && c == 5; + | ^^^^^^^^^^^^^^^^ +41 | let _ = !(c != 5 || a != b); + | ^^^^^^^^^^^^^^^^^^^ + +error: this boolean expression can be simplified + --> $DIR/booleans.rs:42:13 + | +42 | let _ = a == b && c == 5 && b == a; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try + | +42 | let _ = a == b && c == 5; + | ^^^^^^^^^^^^^^^^ +42 | let _ = !(c != 5 || a != b); + | ^^^^^^^^^^^^^^^^^^^ + +error: this boolean expression contains a logic bug + --> $DIR/booleans.rs:43:13 + | +43 | let _ = a < b && a >= b; + | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` + | +help: this expression can be optimized out by applying boolean operations to the outer expression + --> $DIR/booleans.rs:43:13 + | +43 | let _ = a < b && a >= b; + | ^^^^^ + +error: this boolean expression contains a logic bug --> $DIR/booleans.rs:44:13 | -44 | let _ = a == b && c == 5 && a == b; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: try - | -44 | let _ = a == b && c == 5; - | ^^^^^^^^^^^^^^^^ -44 | let _ = !(c != 5 || a != b); - | ^^^^^^^^^^^^^^^^^^^ - -error: this boolean expression can be simplified - --> $DIR/booleans.rs:45:13 - | -45 | let _ = a == b && c == 5 && b == a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: try - | -45 | let _ = a == b && c == 5; - | ^^^^^^^^^^^^^^^^ -45 | let _ = !(c != 5 || a != b); - | ^^^^^^^^^^^^^^^^^^^ - -error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:46:13 - | -46 | let _ = a < b && a >= b; +44 | let _ = a > b && a <= b; | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:46:13 + --> $DIR/booleans.rs:44:13 | -46 | let _ = a < b && a >= b; - | ^^^^^ - -error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:47:13 - | -47 | let _ = a > b && a <= b; - | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` - | -help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:47:13 - | -47 | let _ = a > b && a <= b; +44 | let _ = a > b && a <= b; | ^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:49:13 + --> $DIR/booleans.rs:46:13 | -49 | let _ = a != b || !(a != b || c == d); +46 | let _ = a != b || !(a != b || c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | -49 | let _ = c != d || a != b; +46 | let _ = c != d || a != b; | ^^^^^^^^^^^^^^^^ -49 | let _ = !(a == b && c == d); +46 | let _ = !(a == b && c == d); | ^^^^^^^^^^^^^^^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:57:13 + --> $DIR/booleans.rs:54:13 | -57 | let _ = !a.is_some(); +54 | let _ = !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:59:13 + --> $DIR/booleans.rs:56:13 | -59 | let _ = !a.is_none(); +56 | let _ = !a.is_none(); | ^^^^^^^^^^^^ help: try: `a.is_some()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:61:13 + --> $DIR/booleans.rs:58:13 | -61 | let _ = !b.is_err(); +58 | let _ = !b.is_err(); | ^^^^^^^^^^^ help: try: `b.is_ok()` +error: this boolean expression can be simplified + --> $DIR/booleans.rs:60:13 + | +60 | let _ = !b.is_ok(); + | ^^^^^^^^^^ help: try: `b.is_err()` + +error: this boolean expression can be simplified + --> $DIR/booleans.rs:62:13 + | +62 | let _ = !(a.is_some() && !c); + | ^^^^^^^^^^^^^^^^^^^^ help: try: `c || a.is_none()` + error: this boolean expression can be simplified --> $DIR/booleans.rs:63:13 | -63 | let _ = !b.is_ok(); - | ^^^^^^^^^^ help: try: `b.is_err()` +63 | let _ = !(!c ^ c) || !a.is_some(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!(!c ^ c) || a.is_none()` + +error: this boolean expression can be simplified + --> $DIR/booleans.rs:64:13 + | +64 | let _ = (!c ^ c) || !a.is_some(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(!c ^ c) || a.is_none()` error: this boolean expression can be simplified --> $DIR/booleans.rs:65:13 | -65 | let _ = !(a.is_some() && !c); - | ^^^^^^^^^^^^^^^^^^^^ help: try: `c || a.is_none()` - -error: this boolean expression can be simplified - --> $DIR/booleans.rs:66:13 - | -66 | let _ = !(!c ^ c) || !a.is_some(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!(!c ^ c) || a.is_none()` - -error: this boolean expression can be simplified - --> $DIR/booleans.rs:67:13 - | -67 | let _ = (!c ^ c) || !a.is_some(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(!c ^ c) || a.is_none()` - -error: this boolean expression can be simplified - --> $DIR/booleans.rs:68:13 - | -68 | let _ = !c ^ c || !a.is_some(); +65 | let _ = !c ^ c || !a.is_some(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `!c ^ c || a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:120:8 + --> $DIR/booleans.rs:137:8 | -120 | if !res.is_ok() { } +137 | if !res.is_ok() {} | ^^^^^^^^^^^^ help: try: `res.is_err()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:121:8 + --> $DIR/booleans.rs:138:8 | -121 | if !res.is_err() { } +138 | if !res.is_err() {} | ^^^^^^^^^^^^^ help: try: `res.is_ok()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:124:8 + --> $DIR/booleans.rs:141:8 | -124 | if !res.is_some() { } +141 | if !res.is_some() {} | ^^^^^^^^^^^^^^ help: try: `res.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:125:8 + --> $DIR/booleans.rs:142:8 | -125 | if !res.is_none() { } +142 | if !res.is_none() {} | ^^^^^^^^^^^^^^ help: try: `res.is_some()` error: aborting due to 25 previous errors diff --git a/tests/ui/borrow_box.stderr b/tests/ui/borrow_box.stderr index 7cc8eb8da40..0e42fe177ba 100644 --- a/tests/ui/borrow_box.stderr +++ b/tests/ui/borrow_box.stderr @@ -1,31 +1,31 @@ error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:19:19 + --> $DIR/borrow_box.rs:15:19 | -19 | pub fn test1(foo: &mut Box) { +15 | pub fn test1(foo: &mut Box) { | ^^^^^^^^^^^^^^ help: try: `&mut bool` | note: lint level defined here - --> $DIR/borrow_box.rs:14:9 + --> $DIR/borrow_box.rs:10:9 | -14 | #![deny(clippy::borrowed_box)] +10 | #![deny(clippy::borrowed_box)] | ^^^^^^^^^^^^^^^^^^^^ error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:24:14 + --> $DIR/borrow_box.rs:20:14 | -24 | let foo: &Box; +20 | let foo: &Box; | ^^^^^^^^^^ help: try: `&bool` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:28:10 + --> $DIR/borrow_box.rs:24:10 | -28 | foo: &'a Box +24 | foo: &'a Box, | ^^^^^^^^^^^^^ help: try: `&'a bool` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:32:17 + --> $DIR/borrow_box.rs:28:17 | -32 | fn test4(a: &Box); +28 | fn test4(a: &Box); | ^^^^^^^^^^ help: try: `&bool` error: aborting due to 4 previous errors diff --git a/tests/ui/box_vec.stderr b/tests/ui/box_vec.stderr index 34be890b534..84c0b6c36e3 100644 --- a/tests/ui/box_vec.stderr +++ b/tests/ui/box_vec.stderr @@ -1,7 +1,7 @@ error: you seem to be trying to use `Box>`. Consider using just `Vec` - --> $DIR/box_vec.rs:27:18 + --> $DIR/box_vec.rs:23:18 | -27 | pub fn test(foo: Box>) { +23 | pub fn test(foo: Box>) { | ^^^^^^^^^^^^^^ | = note: `-D clippy::box-vec` implied by `-D warnings` diff --git a/tests/ui/builtin-type-shadow.stderr b/tests/ui/builtin-type-shadow.stderr index 11253715716..540d9f4f458 100644 --- a/tests/ui/builtin-type-shadow.stderr +++ b/tests/ui/builtin-type-shadow.stderr @@ -1,17 +1,17 @@ error: This generic shadows the built-in type `u32` - --> $DIR/builtin-type-shadow.rs:15:8 + --> $DIR/builtin-type-shadow.rs:12:8 | -15 | fn foo(a: u32) -> u32 { +12 | fn foo(a: u32) -> u32 { | ^^^ | = note: `-D clippy::builtin-type-shadow` implied by `-D warnings` error[E0308]: mismatched types - --> $DIR/builtin-type-shadow.rs:16:5 + --> $DIR/builtin-type-shadow.rs:13:5 | -15 | fn foo(a: u32) -> u32 { +12 | fn foo(a: u32) -> u32 { | --- expected `u32` because of return type -16 | 42 +13 | 42 | ^^ expected type parameter, found integral variable | = note: expected type `u32` diff --git a/tests/ui/bytecount.stderr b/tests/ui/bytecount.stderr index c5c0ec7eda4..605cf287419 100644 --- a/tests/ui/bytecount.stderr +++ b/tests/ui/bytecount.stderr @@ -1,25 +1,25 @@ error: You appear to be counting bytes the naive way - --> $DIR/bytecount.rs:18:13 + --> $DIR/bytecount.rs:14:13 | -18 | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count +14 | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, 0)` | note: lint level defined here - --> $DIR/bytecount.rs:14:8 + --> $DIR/bytecount.rs:10:8 | -14 | #[deny(clippy::naive_bytecount)] +10 | #[deny(clippy::naive_bytecount)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: You appear to be counting bytes the naive way - --> $DIR/bytecount.rs:20:13 + --> $DIR/bytecount.rs:16:13 | -20 | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count +16 | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count((&x[..]), 0)` error: You appear to be counting bytes the naive way - --> $DIR/bytecount.rs:32:13 + --> $DIR/bytecount.rs:28:13 | -32 | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count +28 | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, b + 1)` error: aborting due to 3 previous errors diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 1f9ab5712f5..1b6b1e6319c 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -1,181 +1,181 @@ 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:18:5 + --> $DIR/cast.rs:20:5 | -18 | 1i32 as f32; +20 | 1i32 as f32; | ^^^^^^^^^^^ | = note: `-D clippy::cast-precision-loss` implied by `-D warnings` error: casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:19:5 + --> $DIR/cast.rs:21:5 | -19 | 1i64 as f32; +21 | 1i64 as f32; | ^^^^^^^^^^^ 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:20:5 + --> $DIR/cast.rs:22:5 | -20 | 1i64 as f64; +22 | 1i64 as f64; | ^^^^^^^^^^^ 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:21:5 + --> $DIR/cast.rs:23:5 | -21 | 1u32 as f32; +23 | 1u32 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) - --> $DIR/cast.rs:22:5 + --> $DIR/cast.rs:24:5 | -22 | 1u64 as f32; +24 | 1u64 as f32; | ^^^^^^^^^^^ 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:23:5 + --> $DIR/cast.rs:25:5 | -23 | 1u64 as f64; +25 | 1u64 as f64; | ^^^^^^^^^^^ error: casting f32 to i32 may truncate the value - --> $DIR/cast.rs:25:5 + --> $DIR/cast.rs:27:5 | -25 | 1f32 as i32; +27 | 1f32 as i32; | ^^^^^^^^^^^ | = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` error: casting f32 to u32 may truncate the value - --> $DIR/cast.rs:26:5 + --> $DIR/cast.rs:28:5 | -26 | 1f32 as u32; +28 | 1f32 as u32; | ^^^^^^^^^^^ error: casting f32 to u32 may lose the sign of the value - --> $DIR/cast.rs:26:5 + --> $DIR/cast.rs:28:5 | -26 | 1f32 as u32; +28 | 1f32 as u32; | ^^^^^^^^^^^ | = note: `-D clippy::cast-sign-loss` implied by `-D warnings` error: casting f64 to f32 may truncate the value - --> $DIR/cast.rs:27:5 + --> $DIR/cast.rs:29:5 | -27 | 1f64 as f32; +29 | 1f64 as f32; | ^^^^^^^^^^^ error: casting i32 to i8 may truncate the value - --> $DIR/cast.rs:28:5 + --> $DIR/cast.rs:30:5 | -28 | 1i32 as i8; +30 | 1i32 as i8; | ^^^^^^^^^^ error: casting i32 to u8 may lose the sign of the value - --> $DIR/cast.rs:29:5 + --> $DIR/cast.rs:31:5 | -29 | 1i32 as u8; +31 | 1i32 as u8; | ^^^^^^^^^^ error: casting i32 to u8 may truncate the value - --> $DIR/cast.rs:29:5 + --> $DIR/cast.rs:31:5 | -29 | 1i32 as u8; +31 | 1i32 as u8; | ^^^^^^^^^^ error: casting f64 to isize may truncate the value - --> $DIR/cast.rs:30:5 + --> $DIR/cast.rs:32:5 | -30 | 1f64 as isize; +32 | 1f64 as isize; | ^^^^^^^^^^^^^ error: casting f64 to usize may truncate the value - --> $DIR/cast.rs:31:5 + --> $DIR/cast.rs:33:5 | -31 | 1f64 as usize; +33 | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting f64 to usize may lose the sign of the value - --> $DIR/cast.rs:31:5 + --> $DIR/cast.rs:33:5 | -31 | 1f64 as usize; +33 | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting u8 to i8 may wrap around the value - --> $DIR/cast.rs:33:5 + --> $DIR/cast.rs:35:5 | -33 | 1u8 as i8; +35 | 1u8 as i8; | ^^^^^^^^^ | = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` error: casting u16 to i16 may wrap around the value - --> $DIR/cast.rs:34:5 + --> $DIR/cast.rs:36:5 | -34 | 1u16 as i16; +36 | 1u16 as i16; | ^^^^^^^^^^^ error: casting u32 to i32 may wrap around the value - --> $DIR/cast.rs:35:5 + --> $DIR/cast.rs:37:5 | -35 | 1u32 as i32; +37 | 1u32 as i32; | ^^^^^^^^^^^ error: casting u64 to i64 may wrap around the value - --> $DIR/cast.rs:36:5 + --> $DIR/cast.rs:38:5 | -36 | 1u64 as i64; +38 | 1u64 as i64; | ^^^^^^^^^^^ error: casting usize to isize may wrap around the value - --> $DIR/cast.rs:37:5 + --> $DIR/cast.rs:39:5 | -37 | 1usize as isize; +39 | 1usize as isize; | ^^^^^^^^^^^^^^^ error: casting f32 to f64 may become silently lossy if types change - --> $DIR/cast.rs:39:5 + --> $DIR/cast.rs:41:5 | -39 | 1.0f32 as f64; +41 | 1.0f32 as f64; | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting u8 to u16 may become silently lossy if types change - --> $DIR/cast.rs:41:5 + --> $DIR/cast.rs:43:5 | -41 | (1u8 + 1u8) as u16; +43 | (1u8 + 1u8) as u16; | ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)` error: casting i32 to u32 may lose the sign of the value - --> $DIR/cast.rs:43:5 + --> $DIR/cast.rs:45:5 | -43 | 1i32 as u32; +45 | 1i32 as u32; | ^^^^^^^^^^^ error: casting isize to usize may lose the sign of the value - --> $DIR/cast.rs:44:5 + --> $DIR/cast.rs:46:5 | -44 | 1isize as usize; +46 | 1isize as usize; | ^^^^^^^^^^^^^^^ error: casting to the same type is unnecessary (`i32` -> `i32`) - --> $DIR/cast.rs:47:5 + --> $DIR/cast.rs:49:5 | -47 | 1i32 as i32; +49 | 1i32 as i32; | ^^^^^^^^^^^ | = note: `-D clippy::unnecessary-cast` implied by `-D warnings` error: casting to the same type is unnecessary (`f32` -> `f32`) - --> $DIR/cast.rs:48:5 + --> $DIR/cast.rs:50:5 | -48 | 1f32 as f32; +50 | 1f32 as f32; | ^^^^^^^^^^^ error: casting to the same type is unnecessary (`bool` -> `bool`) - --> $DIR/cast.rs:49:5 + --> $DIR/cast.rs:51:5 | -49 | false as bool; +51 | false as bool; | ^^^^^^^^^^^^^ error: aborting due to 28 previous errors diff --git a/tests/ui/cast_alignment.stderr b/tests/ui/cast_alignment.stderr index a4dd6038cab..1c7d53c3ce7 100644 --- a/tests/ui/cast_alignment.stderr +++ b/tests/ui/cast_alignment.stderr @@ -1,15 +1,15 @@ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) - --> $DIR/cast_alignment.rs:25:5 + --> $DIR/cast_alignment.rs:22:5 | -25 | (&1u8 as *const u8) as *const u16; +22 | (&1u8 as *const u8) as *const u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings` error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) - --> $DIR/cast_alignment.rs:26:5 + --> $DIR/cast_alignment.rs:23:5 | -26 | (&mut 1u8 as *mut u8) as *mut u16; +23 | (&mut 1u8 as *mut u8) as *mut u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr index 95b9bfb0262..8380c7c84e2 100644 --- a/tests/ui/cast_lossless_float.stderr +++ b/tests/ui/cast_lossless_float.stderr @@ -1,63 +1,63 @@ error: casting i8 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:17:5 + --> $DIR/cast_lossless_float.rs:14:5 | -17 | 1i8 as f32; +14 | 1i8 as f32; | ^^^^^^^^^^ help: try: `f32::from(1i8)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting i8 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:18:5 + --> $DIR/cast_lossless_float.rs:15:5 | -18 | 1i8 as f64; +15 | 1i8 as f64; | ^^^^^^^^^^ help: try: `f64::from(1i8)` error: casting u8 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:19:5 + --> $DIR/cast_lossless_float.rs:16:5 | -19 | 1u8 as f32; +16 | 1u8 as f32; | ^^^^^^^^^^ help: try: `f32::from(1u8)` error: casting u8 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:20:5 + --> $DIR/cast_lossless_float.rs:17:5 | -20 | 1u8 as f64; +17 | 1u8 as f64; | ^^^^^^^^^^ help: try: `f64::from(1u8)` error: casting i16 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:21:5 + --> $DIR/cast_lossless_float.rs:18:5 | -21 | 1i16 as f32; +18 | 1i16 as f32; | ^^^^^^^^^^^ help: try: `f32::from(1i16)` error: casting i16 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:22:5 + --> $DIR/cast_lossless_float.rs:19:5 | -22 | 1i16 as f64; +19 | 1i16 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1i16)` error: casting u16 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:23:5 + --> $DIR/cast_lossless_float.rs:20:5 | -23 | 1u16 as f32; +20 | 1u16 as f32; | ^^^^^^^^^^^ help: try: `f32::from(1u16)` error: casting u16 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:24:5 + --> $DIR/cast_lossless_float.rs:21:5 | -24 | 1u16 as f64; +21 | 1u16 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1u16)` error: casting i32 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:25:5 + --> $DIR/cast_lossless_float.rs:22:5 | -25 | 1i32 as f64; +22 | 1i32 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1i32)` error: casting u32 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:26:5 + --> $DIR/cast_lossless_float.rs:23:5 | -26 | 1u32 as f64; +23 | 1u32 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1u32)` error: aborting due to 10 previous errors diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index 5f9c70879b4..e5558b66681 100644 --- a/tests/ui/cast_lossless_integer.stderr +++ b/tests/ui/cast_lossless_integer.stderr @@ -1,111 +1,111 @@ error: casting i8 to i16 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:16:5 + --> $DIR/cast_lossless_integer.rs:14:5 | -16 | 1i8 as i16; +14 | 1i8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1i8)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting i8 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:17:5 + --> $DIR/cast_lossless_integer.rs:15:5 | -17 | 1i8 as i32; +15 | 1i8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1i8)` error: casting i8 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:18:5 + --> $DIR/cast_lossless_integer.rs:16:5 | -18 | 1i8 as i64; +16 | 1i8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1i8)` error: casting u8 to i16 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:19:5 + --> $DIR/cast_lossless_integer.rs:17:5 | -19 | 1u8 as i16; +17 | 1u8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1u8)` error: casting u8 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:20:5 + --> $DIR/cast_lossless_integer.rs:18:5 | -20 | 1u8 as i32; +18 | 1u8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1u8)` error: casting u8 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:21:5 + --> $DIR/cast_lossless_integer.rs:19:5 | -21 | 1u8 as i64; +19 | 1u8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1u8)` error: casting u8 to u16 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:22:5 + --> $DIR/cast_lossless_integer.rs:20:5 | -22 | 1u8 as u16; +20 | 1u8 as u16; | ^^^^^^^^^^ help: try: `u16::from(1u8)` error: casting u8 to u32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:23:5 + --> $DIR/cast_lossless_integer.rs:21:5 | -23 | 1u8 as u32; +21 | 1u8 as u32; | ^^^^^^^^^^ help: try: `u32::from(1u8)` error: casting u8 to u64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:24:5 + --> $DIR/cast_lossless_integer.rs:22:5 | -24 | 1u8 as u64; +22 | 1u8 as u64; | ^^^^^^^^^^ help: try: `u64::from(1u8)` error: casting i16 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:25:5 + --> $DIR/cast_lossless_integer.rs:23:5 | -25 | 1i16 as i32; +23 | 1i16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1i16)` error: casting i16 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:26:5 + --> $DIR/cast_lossless_integer.rs:24:5 | -26 | 1i16 as i64; +24 | 1i16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i16)` error: casting u16 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:27:5 + --> $DIR/cast_lossless_integer.rs:25:5 | -27 | 1u16 as i32; +25 | 1u16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1u16)` error: casting u16 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:28:5 + --> $DIR/cast_lossless_integer.rs:26:5 | -28 | 1u16 as i64; +26 | 1u16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u16)` error: casting u16 to u32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:29:5 + --> $DIR/cast_lossless_integer.rs:27:5 | -29 | 1u16 as u32; +27 | 1u16 as u32; | ^^^^^^^^^^^ help: try: `u32::from(1u16)` error: casting u16 to u64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:30:5 + --> $DIR/cast_lossless_integer.rs:28:5 | -30 | 1u16 as u64; +28 | 1u16 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u16)` error: casting i32 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:31:5 + --> $DIR/cast_lossless_integer.rs:29:5 | -31 | 1i32 as i64; +29 | 1i32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i32)` error: casting u32 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:32:5 + --> $DIR/cast_lossless_integer.rs:30:5 | -32 | 1u32 as i64; +30 | 1u32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u32)` error: casting u32 to u64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:33:5 + --> $DIR/cast_lossless_integer.rs:31:5 | -33 | 1u32 as u64; +31 | 1u32 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u32)` error: aborting due to 18 previous errors diff --git a/tests/ui/cast_size.stderr b/tests/ui/cast_size.stderr index c5f569db167..9f658d40523 100644 --- a/tests/ui/cast_size.stderr +++ b/tests/ui/cast_size.stderr @@ -1,123 +1,123 @@ error: casting isize to i8 may truncate the value - --> $DIR/cast_size.rs:17:5 + --> $DIR/cast_size.rs:20:5 | -17 | 1isize as i8; +20 | 1isize as i8; | ^^^^^^^^^^^^ | = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:18:5 + --> $DIR/cast_size.rs:21:5 | -18 | 1isize as f64; +21 | 1isize as f64; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-precision-loss` implied by `-D warnings` error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:19:5 + --> $DIR/cast_size.rs:22:5 | -19 | 1usize as f64; +22 | 1usize as f64; | ^^^^^^^^^^^^^ 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_size.rs:20:5 + --> $DIR/cast_size.rs:23:5 | -20 | 1isize as f32; +23 | 1isize 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) - --> $DIR/cast_size.rs:21:5 + --> $DIR/cast_size.rs:24:5 | -21 | 1usize as f32; +24 | 1usize as f32; | ^^^^^^^^^^^^^ error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:22:5 + --> $DIR/cast_size.rs:25:5 | -22 | 1isize as i32; +25 | 1isize as i32; | ^^^^^^^^^^^^^ error: casting isize to u32 may lose the sign of the value - --> $DIR/cast_size.rs:23:5 + --> $DIR/cast_size.rs:26:5 | -23 | 1isize as u32; +26 | 1isize as u32; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-sign-loss` implied by `-D warnings` error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:23:5 + --> $DIR/cast_size.rs:26:5 | -23 | 1isize as u32; +26 | 1isize as u32; | ^^^^^^^^^^^^^ error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:24:5 + --> $DIR/cast_size.rs:27:5 | -24 | 1usize as u32; +27 | 1usize as u32; | ^^^^^^^^^^^^^ error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> $DIR/cast_size.rs:28:5 | -25 | 1usize as i32; +28 | 1usize as i32; | ^^^^^^^^^^^^^ error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> $DIR/cast_size.rs:28:5 | -25 | 1usize as i32; +28 | 1usize as i32; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:27:5 + --> $DIR/cast_size.rs:30:5 | -27 | 1i64 as isize; +30 | 1i64 as isize; | ^^^^^^^^^^^^^ error: casting i64 to usize may lose the sign of the value - --> $DIR/cast_size.rs:28:5 + --> $DIR/cast_size.rs:31:5 | -28 | 1i64 as usize; +31 | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> $DIR/cast_size.rs:31:5 | -28 | 1i64 as usize; +31 | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:29:5 + --> $DIR/cast_size.rs:32:5 | -29 | 1u64 as isize; +32 | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:29:5 + --> $DIR/cast_size.rs:32:5 | -29 | 1u64 as isize; +32 | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:30:5 + --> $DIR/cast_size.rs:33:5 | -30 | 1u64 as usize; +33 | 1u64 as usize; | ^^^^^^^^^^^^^ error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:31:5 + --> $DIR/cast_size.rs:34:5 | -31 | 1u32 as isize; +34 | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting i32 to usize may lose the sign of the value - --> $DIR/cast_size.rs:34:5 + --> $DIR/cast_size.rs:37:5 | -34 | 1i32 as usize; +37 | 1i32 as usize; | ^^^^^^^^^^^^^ error: aborting due to 19 previous errors diff --git a/tests/ui/char_lit_as_u8.stderr b/tests/ui/char_lit_as_u8.stderr index 38a469bfebb..cee27df2a7d 100644 --- a/tests/ui/char_lit_as_u8.stderr +++ b/tests/ui/char_lit_as_u8.stderr @@ -1,7 +1,7 @@ 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:17:13 + --> $DIR/char_lit_as_u8.rs:13:13 | -17 | let c = 'a' as u8; +13 | let c = 'a' as u8; | ^^^^^^^^^ | = note: `-D clippy::char-lit-as-u8` implied by `-D warnings` diff --git a/tests/ui/checked_unwrap.stderr b/tests/ui/checked_unwrap.stderr index f7f49360348..bce37d50226 100644 --- a/tests/ui/checked_unwrap.stderr +++ b/tests/ui/checked_unwrap.stderr @@ -1,312 +1,312 @@ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:19:9 + --> $DIR/checked_unwrap.rs:16:9 | -18 | if x.is_some() { +15 | if x.is_some() { | ----------- the check is happening here -19 | x.unwrap(); // unnecessary +16 | x.unwrap(); // unnecessary | ^^^^^^^^^^ | note: lint level defined here - --> $DIR/checked_unwrap.rs:13:35 + --> $DIR/checked_unwrap.rs:10:35 | -13 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +10 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: This call to `unwrap()` will always panic. + --> $DIR/checked_unwrap.rs:18:9 + | +15 | if x.is_some() { + | ----------- because of this check +... +18 | x.unwrap(); // will panic + | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/checked_unwrap.rs:10:9 + | +10 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:21:9 | -18 | if x.is_some() { +20 | if x.is_none() { | ----------- because of this check -... 21 | x.unwrap(); // will panic | ^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/checked_unwrap.rs:13:9 - | -13 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:24:9 - | -23 | if x.is_none() { - | ----------- because of this check -24 | x.unwrap(); // will panic - | ^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:26:9 + --> $DIR/checked_unwrap.rs:23:9 | -23 | if x.is_none() { +20 | if x.is_none() { | ----------- the check is happening here ... -26 | x.unwrap(); // unnecessary +23 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:27:9 + | +26 | if x.is_ok() { + | --------- the check is happening here +27 | x.unwrap(); // unnecessary + | ^^^^^^^^^^ + +error: This call to `unwrap_err()` will always panic. + --> $DIR/checked_unwrap.rs:28:9 + | +26 | if x.is_ok() { + | --------- because of this check +27 | x.unwrap(); // unnecessary +28 | x.unwrap_err(); // will panic + | ^^^^^^^^^^^^^^ + +error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:30:9 | -29 | if x.is_ok() { - | --------- the check is happening here -30 | x.unwrap(); // unnecessary +26 | if x.is_ok() { + | --------- because of this check +... +30 | x.unwrap(); // will panic | ^^^^^^^^^^ -error: This call to `unwrap_err()` will always panic. +error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. --> $DIR/checked_unwrap.rs:31:9 | -29 | if x.is_ok() { - | --------- because of this check -30 | x.unwrap(); // unnecessary -31 | x.unwrap_err(); // will panic +26 | if x.is_ok() { + | --------- the check is happening here +... +31 | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:33:9 - | -29 | if x.is_ok() { - | --------- because of this check -... -33 | x.unwrap(); // will panic - | ^^^^^^^^^^ - -error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. --> $DIR/checked_unwrap.rs:34:9 | -29 | if x.is_ok() { - | --------- the check is happening here -... -34 | x.unwrap_err(); // unnecessary +33 | if x.is_err() { + | ---------- because of this check +34 | x.unwrap(); // will panic + | ^^^^^^^^^^ + +error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:35:9 + | +33 | if x.is_err() { + | ---------- the check is happening here +34 | x.unwrap(); // will panic +35 | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ -error: This call to `unwrap()` will always panic. +error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. --> $DIR/checked_unwrap.rs:37:9 | -36 | if x.is_err() { - | ---------- because of this check -37 | x.unwrap(); // will panic +33 | if x.is_err() { + | ---------- the check is happening here +... +37 | x.unwrap(); // unnecessary | ^^^^^^^^^^ -error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. +error: This call to `unwrap_err()` will always panic. --> $DIR/checked_unwrap.rs:38:9 | -36 | if x.is_err() { - | ---------- the check is happening here -37 | x.unwrap(); // will panic -38 | x.unwrap_err(); // unnecessary - | ^^^^^^^^^^^^^^ - -error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:40:9 - | -36 | if x.is_err() { - | ---------- the check is happening here -... -40 | x.unwrap(); // unnecessary - | ^^^^^^^^^^ - -error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:41:9 - | -36 | if x.is_err() { +33 | if x.is_err() { | ---------- because of this check ... -41 | x.unwrap_err(); // will panic +38 | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:58:9 + --> $DIR/checked_unwrap.rs:55:9 | -57 | if x.is_ok() && y.is_err() { +54 | if x.is_ok() && y.is_err() { | --------- the check is happening here -58 | x.unwrap(); // unnecessary +55 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:59:9 + --> $DIR/checked_unwrap.rs:56:9 | -57 | if x.is_ok() && y.is_err() { +54 | if x.is_ok() && y.is_err() { | --------- because of this check -58 | x.unwrap(); // unnecessary -59 | x.unwrap_err(); // will panic +55 | x.unwrap(); // unnecessary +56 | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:60:9 + --> $DIR/checked_unwrap.rs:57:9 | -57 | if x.is_ok() && y.is_err() { +54 | if x.is_ok() && y.is_err() { | ---------- because of this check ... -60 | y.unwrap(); // will panic +57 | y.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:61:9 + --> $DIR/checked_unwrap.rs:58:9 | -57 | if x.is_ok() && y.is_err() { +54 | if x.is_ok() && y.is_err() { | ---------- the check is happening here ... -61 | y.unwrap_err(); // unnecessary +58 | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:75:9 + --> $DIR/checked_unwrap.rs:72:9 | -70 | if x.is_ok() || y.is_ok() { +67 | if x.is_ok() || y.is_ok() { | --------- because of this check ... -75 | x.unwrap(); // will panic +72 | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:76:9 + --> $DIR/checked_unwrap.rs:73:9 | -70 | if x.is_ok() || y.is_ok() { +67 | if x.is_ok() || y.is_ok() { | --------- the check is happening here ... -76 | x.unwrap_err(); // unnecessary +73 | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:77:9 + --> $DIR/checked_unwrap.rs:74:9 | -70 | if x.is_ok() || y.is_ok() { +67 | if x.is_ok() || y.is_ok() { | --------- because of this check ... -77 | y.unwrap(); // will panic +74 | y.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:78:9 + --> $DIR/checked_unwrap.rs:75:9 | -70 | if x.is_ok() || y.is_ok() { +67 | if x.is_ok() || y.is_ok() { | --------- the check is happening here ... -78 | y.unwrap_err(); // unnecessary +75 | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:79:9 + | +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { + | --------- the check is happening here +79 | x.unwrap(); // unnecessary + | ^^^^^^^^^^ + +error: This call to `unwrap_err()` will always panic. + --> $DIR/checked_unwrap.rs:80:9 + | +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { + | --------- because of this check +79 | x.unwrap(); // unnecessary +80 | x.unwrap_err(); // will panic + | ^^^^^^^^^^^^^^ + +error: This call to `unwrap()` will always panic. + --> $DIR/checked_unwrap.rs:81:9 + | +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { + | --------- because of this check +... +81 | y.unwrap(); // will panic + | ^^^^^^^^^^ + +error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. --> $DIR/checked_unwrap.rs:82:9 | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { - | --------- the check is happening here -82 | x.unwrap(); // unnecessary - | ^^^^^^^^^^ +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { + | --------- the check is happening here +... +82 | y.unwrap_err(); // unnecessary + | ^^^^^^^^^^^^^^ -error: This call to `unwrap_err()` will always panic. +error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. --> $DIR/checked_unwrap.rs:83:9 | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { - | --------- because of this check -82 | x.unwrap(); // unnecessary -83 | x.unwrap_err(); // will panic - | ^^^^^^^^^^^^^^ - -error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:84:9 - | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { - | --------- because of this check -... -84 | y.unwrap(); // will panic - | ^^^^^^^^^^ - -error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:85:9 - | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { - | --------- the check is happening here -... -85 | y.unwrap_err(); // unnecessary - | ^^^^^^^^^^^^^^ - -error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:86:9 - | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- the check is happening here ... -86 | z.unwrap(); // unnecessary +83 | z.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:87:9 + --> $DIR/checked_unwrap.rs:84:9 | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- because of this check ... -87 | z.unwrap_err(); // will panic +84 | z.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:95:9 + --> $DIR/checked_unwrap.rs:92:9 | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check ... -95 | x.unwrap(); // will panic +92 | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:96:9 + --> $DIR/checked_unwrap.rs:93:9 | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here ... -96 | x.unwrap_err(); // unnecessary +93 | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:97:9 + --> $DIR/checked_unwrap.rs:94:9 | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here ... -97 | y.unwrap(); // unnecessary +94 | y.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:98:9 + --> $DIR/checked_unwrap.rs:95:9 | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check ... -98 | y.unwrap_err(); // will panic +95 | y.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:99:9 + --> $DIR/checked_unwrap.rs:96:9 | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- because of this check ... -99 | z.unwrap(); // will panic +96 | z.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:100:9 - | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { - | ---------- the check is happening here + --> $DIR/checked_unwrap.rs:97:9 + | +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { + | ---------- the check is happening here ... -100 | z.unwrap_err(); // unnecessary - | ^^^^^^^^^^^^^^ +97 | z.unwrap_err(); // unnecessary + | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:108:13 + --> $DIR/checked_unwrap.rs:105:13 | -107 | if x.is_some() { +104 | if x.is_some() { | ----------- the check is happening here -108 | x.unwrap(); // unnecessary +105 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:110:13 + --> $DIR/checked_unwrap.rs:107:13 | -107 | if x.is_some() { +104 | if x.is_some() { | ----------- because of this check ... -110 | x.unwrap(); // will panic +107 | x.unwrap(); // will panic | ^^^^^^^^^^ error: aborting due to 34 previous errors diff --git a/tests/ui/cmp_nan.stderr b/tests/ui/cmp_nan.stderr index b880b821f08..6838e6ad7ae 100644 --- a/tests/ui/cmp_nan.stderr +++ b/tests/ui/cmp_nan.stderr @@ -1,75 +1,75 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:18:5 + --> $DIR/cmp_nan.rs:14:5 | -18 | x == std::f32::NAN; +14 | x == std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::cmp-nan` implied by `-D warnings` error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:19:5 + --> $DIR/cmp_nan.rs:15:5 | -19 | x != std::f32::NAN; +15 | x != std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:20:5 + --> $DIR/cmp_nan.rs:16:5 | -20 | x < std::f32::NAN; +16 | x < std::f32::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:21:5 + --> $DIR/cmp_nan.rs:17:5 | -21 | x > std::f32::NAN; +17 | x > std::f32::NAN; | ^^^^^^^^^^^^^^^^^ +error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead + --> $DIR/cmp_nan.rs:18:5 + | +18 | x <= std::f32::NAN; + | ^^^^^^^^^^^^^^^^^^ + +error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead + --> $DIR/cmp_nan.rs:19:5 + | +19 | x >= std::f32::NAN; + | ^^^^^^^^^^^^^^^^^^ + error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:22:5 | -22 | x <= std::f32::NAN; +22 | y == std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:23:5 | -23 | x >= std::f32::NAN; +23 | y != std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ +error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead + --> $DIR/cmp_nan.rs:24:5 + | +24 | y < std::f64::NAN; + | ^^^^^^^^^^^^^^^^^ + +error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead + --> $DIR/cmp_nan.rs:25:5 + | +25 | y > std::f64::NAN; + | ^^^^^^^^^^^^^^^^^ + error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:26:5 | -26 | y == std::f64::NAN; +26 | y <= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:27:5 | -27 | y != std::f64::NAN; - | ^^^^^^^^^^^^^^^^^^ - -error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:28:5 - | -28 | y < std::f64::NAN; - | ^^^^^^^^^^^^^^^^^ - -error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:29:5 - | -29 | y > std::f64::NAN; - | ^^^^^^^^^^^^^^^^^ - -error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:30:5 - | -30 | y <= std::f64::NAN; - | ^^^^^^^^^^^^^^^^^^ - -error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:31:5 - | -31 | y >= std::f64::NAN; +27 | y >= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index 1f1fdf32852..5038298d9c4 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -1,15 +1,15 @@ error: Comparing with null is better expressed by the .is_null() method - --> $DIR/cmp_null.rs:21:8 + --> $DIR/cmp_null.rs:18:8 | -21 | if p == ptr::null() { +18 | if p == ptr::null() { | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::cmp-null` implied by `-D warnings` error: Comparing with null is better expressed by the .is_null() method - --> $DIR/cmp_null.rs:26:8 + --> $DIR/cmp_null.rs:23:8 | -26 | if m == ptr::null_mut() { +23 | if m == ptr::null_mut() { | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/cmp_owned.stderr b/tests/ui/cmp_owned.stderr index a7371ab4b6c..2d06f736967 100644 --- a/tests/ui/cmp_owned.stderr +++ b/tests/ui/cmp_owned.stderr @@ -1,57 +1,57 @@ error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:18:14 + --> $DIR/cmp_owned.rs:14:14 | -18 | x != "foo".to_string(); +14 | x != "foo".to_string(); | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` | = note: `-D clippy::cmp-owned` implied by `-D warnings` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:20:9 + --> $DIR/cmp_owned.rs:16:9 | -20 | "foo".to_string() != x; +16 | "foo".to_string() != x; | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:27:10 + --> $DIR/cmp_owned.rs:23:10 | -27 | x != "foo".to_owned(); +23 | x != "foo".to_owned(); | ^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:29:10 + --> $DIR/cmp_owned.rs:25:10 | -29 | x != String::from("foo"); +25 | x != String::from("foo"); | ^^^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:33:5 + --> $DIR/cmp_owned.rs:29:5 | -33 | Foo.to_owned() == Foo; +29 | Foo.to_owned() == Foo; | ^^^^^^^^^^^^^^ help: try: `Foo` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:35:30 + --> $DIR/cmp_owned.rs:31:30 | -35 | "abc".chars().filter(|c| c.to_owned() != 'X'); +31 | "abc".chars().filter(|c| c.to_owned() != 'X'); | ^^^^^^^^^^^^ help: try: `*c` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:42:5 + --> $DIR/cmp_owned.rs:38:5 | -42 | y.to_owned() == *x; +38 | y.to_owned() == *x; | ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:47:5 + --> $DIR/cmp_owned.rs:43:5 | -47 | y.to_owned() == **x; +43 | y.to_owned() == **x; | ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:54:9 + --> $DIR/cmp_owned.rs:50:9 | -54 | self.to_owned() == *other +50 | self.to_owned() == *other | ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: aborting due to 9 previous errors diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index 697dec336fa..1884045a2db 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -1,259 +1,259 @@ error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:16:5 + --> $DIR/collapsible_if.rs:15:5 | -16 | / if x == "hello" { -17 | | if y == "world" { -18 | | println!("Hello world!"); -19 | | } -20 | | } +15 | / if x == "hello" { +16 | | if y == "world" { +17 | | println!("Hello world!"); +18 | | } +19 | | } | |_____^ | = note: `-D clippy::collapsible-if` implied by `-D warnings` help: try | -16 | if x == "hello" && y == "world" { -17 | println!("Hello world!"); -18 | } +15 | if x == "hello" && y == "world" { +16 | println!("Hello world!"); +17 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:22:5 + --> $DIR/collapsible_if.rs:21:5 | -22 | / if x == "hello" || x == "world" { -23 | | if y == "world" || y == "hello" { -24 | | println!("Hello world!"); -25 | | } -26 | | } +21 | / if x == "hello" || x == "world" { +22 | | if y == "world" || y == "hello" { +23 | | println!("Hello world!"); +24 | | } +25 | | } | |_____^ help: try | -22 | if (x == "hello" || x == "world") && (y == "world" || y == "hello") { -23 | println!("Hello world!"); -24 | } +21 | if (x == "hello" || x == "world") && (y == "world" || y == "hello") { +22 | println!("Hello world!"); +23 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:28:5 + --> $DIR/collapsible_if.rs:27:5 | -28 | / if x == "hello" && x == "world" { -29 | | if y == "world" || y == "hello" { -30 | | println!("Hello world!"); -31 | | } -32 | | } +27 | / if x == "hello" && x == "world" { +28 | | if y == "world" || y == "hello" { +29 | | println!("Hello world!"); +30 | | } +31 | | } | |_____^ help: try | -28 | if x == "hello" && x == "world" && (y == "world" || y == "hello") { -29 | println!("Hello world!"); -30 | } +27 | if x == "hello" && x == "world" && (y == "world" || y == "hello") { +28 | println!("Hello world!"); +29 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:34:5 + --> $DIR/collapsible_if.rs:33:5 | -34 | / if x == "hello" || x == "world" { -35 | | if y == "world" && y == "hello" { -36 | | println!("Hello world!"); -37 | | } -38 | | } +33 | / if x == "hello" || x == "world" { +34 | | if y == "world" && y == "hello" { +35 | | println!("Hello world!"); +36 | | } +37 | | } | |_____^ help: try | -34 | if (x == "hello" || x == "world") && y == "world" && y == "hello" { -35 | println!("Hello world!"); -36 | } +33 | if (x == "hello" || x == "world") && y == "world" && y == "hello" { +34 | println!("Hello world!"); +35 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:40:5 + --> $DIR/collapsible_if.rs:39:5 | -40 | / if x == "hello" && x == "world" { -41 | | if y == "world" && y == "hello" { -42 | | println!("Hello world!"); -43 | | } -44 | | } +39 | / if x == "hello" && x == "world" { +40 | | if y == "world" && y == "hello" { +41 | | println!("Hello world!"); +42 | | } +43 | | } | |_____^ help: try | -40 | if x == "hello" && x == "world" && y == "world" && y == "hello" { -41 | println!("Hello world!"); -42 | } +39 | if x == "hello" && x == "world" && y == "world" && y == "hello" { +40 | println!("Hello world!"); +41 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:46:5 + --> $DIR/collapsible_if.rs:45:5 | -46 | / if 42 == 1337 { -47 | | if 'a' != 'A' { -48 | | println!("world!") -49 | | } -50 | | } +45 | / if 42 == 1337 { +46 | | if 'a' != 'A' { +47 | | println!("world!") +48 | | } +49 | | } | |_____^ help: try | -46 | if 42 == 1337 && 'a' != 'A' { -47 | println!("world!") -48 | } +45 | if 42 == 1337 && 'a' != 'A' { +46 | println!("world!") +47 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:55:12 + --> $DIR/collapsible_if.rs:54:12 | -55 | } else { +54 | } else { | ____________^ -56 | | if y == "world" { -57 | | println!("world!") -58 | | } -59 | | } +55 | | if y == "world" { +56 | | println!("world!") +57 | | } +58 | | } | |_____^ help: try | -55 | } else if y == "world" { -56 | println!("world!") -57 | } +54 | } else if y == "world" { +55 | println!("world!") +56 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:63:12 + --> $DIR/collapsible_if.rs:62:12 | -63 | } else { +62 | } else { | ____________^ -64 | | if let Some(42) = Some(42) { -65 | | println!("world!") -66 | | } -67 | | } +63 | | if let Some(42) = Some(42) { +64 | | println!("world!") +65 | | } +66 | | } | |_____^ help: try | -63 | } else if let Some(42) = Some(42) { -64 | println!("world!") -65 | } +62 | } else if let Some(42) = Some(42) { +63 | println!("world!") +64 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:71:12 + --> $DIR/collapsible_if.rs:70:12 | -71 | } else { +70 | } else { | ____________^ -72 | | if y == "world" { -73 | | println!("world") -74 | | } +71 | | if y == "world" { +72 | | println!("world") +73 | | } ... | -77 | | } -78 | | } +76 | | } +77 | | } | |_____^ help: try | -71 | } else if y == "world" { -72 | println!("world") -73 | } -74 | else { -75 | println!("!") -76 | } +70 | } else if y == "world" { +71 | println!("world") +72 | } +73 | else { +74 | println!("!") +75 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:82:12 + --> $DIR/collapsible_if.rs:81:12 | -82 | } else { +81 | } else { | ____________^ -83 | | if let Some(42) = Some(42) { -84 | | println!("world") -85 | | } +82 | | if let Some(42) = Some(42) { +83 | | println!("world") +84 | | } ... | -88 | | } -89 | | } +87 | | } +88 | | } | |_____^ help: try | -82 | } else if let Some(42) = Some(42) { -83 | println!("world") -84 | } -85 | else { -86 | println!("!") -87 | } +81 | } else if let Some(42) = Some(42) { +82 | println!("world") +83 | } +84 | else { +85 | println!("!") +86 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:93:12 + --> $DIR/collapsible_if.rs:92:12 + | +92 | } else { + | ____________^ +93 | | if let Some(42) = Some(42) { +94 | | println!("world") +95 | | } +... | +98 | | } +99 | | } + | |_____^ +help: try + | +92 | } else if let Some(42) = Some(42) { +93 | println!("world") +94 | } +95 | else { +96 | println!("!") +97 | } + | + +error: this `else { if .. }` block can be collapsed + --> $DIR/collapsible_if.rs:103:12 | -93 | } else { +103 | } else { | ____________^ -94 | | if let Some(42) = Some(42) { -95 | | println!("world") -96 | | } +104 | | if x == "hello" { +105 | | println!("world") +106 | | } ... | -99 | | } -100 | | } +109 | | } +110 | | } | |_____^ help: try | -93 | } else if let Some(42) = Some(42) { -94 | println!("world") -95 | } -96 | else { -97 | println!("!") -98 | } +103 | } else if x == "hello" { +104 | println!("world") +105 | } +106 | else { +107 | println!("!") +108 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:104:12 + --> $DIR/collapsible_if.rs:114:12 | -104 | } else { +114 | } else { | ____________^ -105 | | if x == "hello" { -106 | | println!("world") -107 | | } +115 | | if let Some(42) = Some(42) { +116 | | println!("world") +117 | | } ... | -110 | | } -111 | | } +120 | | } +121 | | } | |_____^ help: try | -104 | } else if x == "hello" { -105 | println!("world") -106 | } -107 | else { -108 | println!("!") -109 | } - | - -error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:115:12 - | -115 | } else { - | ____________^ -116 | | if let Some(42) = Some(42) { -117 | | println!("world") -118 | | } -... | -121 | | } -122 | | } - | |_____^ -help: try - | -115 | } else if let Some(42) = Some(42) { -116 | println!("world") -117 | } -118 | else { -119 | println!("!") -120 | } +114 | } else if let Some(42) = Some(42) { +115 | println!("world") +116 | } +117 | else { +118 | println!("!") +119 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:174:5 + --> $DIR/collapsible_if.rs:173:5 | -174 | / if x == "hello" { -175 | | if y == "world" { // Collapsible -176 | | println!("Hello world!"); -177 | | } -178 | | } +173 | / if x == "hello" { +174 | | if y == "world" { // Collapsible +175 | | println!("Hello world!"); +176 | | } +177 | | } | |_____^ help: try | -174 | if x == "hello" && y == "world" { // Collapsible -175 | println!("Hello world!"); -176 | } +173 | if x == "hello" && y == "world" { // Collapsible +174 | println!("Hello world!"); +175 | } | error: aborting due to 14 previous errors diff --git a/tests/ui/complex_types.stderr b/tests/ui/complex_types.stderr index f373f09951b..80f133fd1ce 100644 --- a/tests/ui/complex_types.stderr +++ b/tests/ui/complex_types.stderr @@ -1,93 +1,93 @@ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:19:12 + --> $DIR/complex_types.rs:16:12 | -19 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); +16 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::type-complexity` implied by `-D warnings` error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:20:12 + --> $DIR/complex_types.rs:17:12 | -20 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); +17 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:23:8 + --> $DIR/complex_types.rs:20:8 | -23 | f: Vec>>, +20 | f: Vec>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: very complex type used. Consider factoring parts into `type` definitions + --> $DIR/complex_types.rs:23:11 + | +23 | struct TS(Vec>>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:26:11 | -26 | struct TS(Vec>>); +26 | Tuple(Vec>>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:29:11 + --> $DIR/complex_types.rs:27:17 | -29 | Tuple(Vec>>), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:30:17 - | -30 | Struct { f: Vec>> }, +27 | Struct { f: Vec>> }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:34:14 + --> $DIR/complex_types.rs:31:14 | -34 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); +31 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:35:30 + --> $DIR/complex_types.rs:32:30 | -35 | fn impl_method(&self, p: Vec>>) { } +32 | fn impl_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:39:14 + --> $DIR/complex_types.rs:36:14 | -39 | const A: Vec>>; +36 | const A: Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:40:14 + --> $DIR/complex_types.rs:37:14 | -40 | type B = Vec>>; +37 | type B = Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:41:25 + --> $DIR/complex_types.rs:38:25 | -41 | fn method(&self, p: Vec>>); +38 | fn method(&self, p: Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:42:29 + --> $DIR/complex_types.rs:39:29 | -42 | fn def_method(&self, p: Vec>>) { } +39 | fn def_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:45:15 + --> $DIR/complex_types.rs:42:15 | -45 | fn test1() -> Vec>> { vec![] } +42 | fn test1() -> Vec>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:47:14 + --> $DIR/complex_types.rs:46:14 | -47 | fn test2(_x: Vec>>) { } +46 | fn test2(_x: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:50:13 + --> $DIR/complex_types.rs:49:13 | -50 | let _y: Vec>> = vec![]; +49 | let _y: Vec>> = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 15 previous errors diff --git a/tests/ui/const_static_lifetime.stderr b/tests/ui/const_static_lifetime.stderr index 908a681584d..ba53d0718fc 100644 --- a/tests/ui/const_static_lifetime.stderr +++ b/tests/ui/const_static_lifetime.stderr @@ -1,81 +1,81 @@ error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:14:17 + --> $DIR/const_static_lifetime.rs:13:17 | -14 | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. +13 | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` | = note: `-D clippy::const-static-lifetime` implied by `-D warnings` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:18:21 + --> $DIR/const_static_lifetime.rs:17:21 | -18 | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static +17 | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:20:32 + --> $DIR/const_static_lifetime.rs:19:32 | -20 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +19 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:20:47 + --> $DIR/const_static_lifetime.rs:19:47 | -20 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +19 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:22:18 + --> $DIR/const_static_lifetime.rs:21:18 | -22 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +21 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:22:30 + --> $DIR/const_static_lifetime.rs:21:30 | -22 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +21 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:24:17 + --> $DIR/const_static_lifetime.rs:23:17 | -24 | const VAR_SIX: &'static u8 = &5; +23 | const VAR_SIX: &'static u8 = &5; | -^^^^^^^--- help: consider removing `'static`: `&u8` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:26:29 + --> $DIR/const_static_lifetime.rs:25:29 | -26 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; +25 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:26:39 + --> $DIR/const_static_lifetime.rs:25:39 | -26 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; +25 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:28:20 + --> $DIR/const_static_lifetime.rs:27:20 | -28 | const VAR_HEIGHT: &'static Foo = &Foo {}; +27 | const VAR_HEIGHT: &'static Foo = &Foo {}; | -^^^^^^^---- help: consider removing `'static`: `&Foo` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:30:19 + --> $DIR/const_static_lifetime.rs:29:19 | -30 | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static. +29 | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static. | -^^^^^^^----- help: consider removing `'static`: `&[u8]` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:32:19 + --> $DIR/const_static_lifetime.rs:31:19 | -32 | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. +31 | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. | -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:34:19 + --> $DIR/const_static_lifetime.rs:33:19 | -34 | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. +33 | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` error: aborting due to 13 previous errors diff --git a/tests/ui/copies.stderr b/tests/ui/copies.stderr index e5f808218fe..e41fac0f686 100644 --- a/tests/ui/copies.stderr +++ b/tests/ui/copies.stderr @@ -1,385 +1,392 @@ error: this `if` has identical blocks - --> $DIR/copies.rs:41:10 + --> $DIR/copies.rs:50:12 | -41 | else { //~ ERROR same body as `if` block - | __________^ -42 | | Foo { bar: 42 }; -43 | | 0..10; -44 | | ..; +50 | } else { + | ____________^ +51 | | //~ ERROR same body as `if` block +52 | | Foo { bar: 42 }; +53 | | 0..10; ... | -48 | | foo(); -49 | | } +58 | | foo(); +59 | | } | |_____^ | = note: `-D clippy::if-same-then-else` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:32:13 + --> $DIR/copies.rs:42:13 | -32 | if true { +42 | if true { | _____________^ -33 | | Foo { bar: 42 }; -34 | | 0..10; -35 | | ..; +43 | | Foo { bar: 42 }; +44 | | 0..10; +45 | | ..; ... | -39 | | foo(); -40 | | } +49 | | foo(); +50 | | } else { | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:90:14 - | -90 | _ => { //~ ERROR match arms have same body - | ______________^ -91 | | foo(); -92 | | let mut a = 42 + [23].len() as i32; -93 | | if true { -... | -97 | | a -98 | | } - | |_________^ - | - = note: `-D clippy::match-same-arms` implied by `-D warnings` + --> $DIR/copies.rs:96:14 + | +96 | _ => { + | ______________^ +97 | | //~ ERROR match arms have same body +98 | | foo(); +99 | | let mut a = 42 + [23].len() as i32; +... | +104 | | a +105 | | }, + | |_________^ + | + = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:81:15 - | -81 | 42 => { - | _______________^ -82 | | foo(); -83 | | let mut a = 42 + [23].len() as i32; -84 | | if true { -... | -88 | | a -89 | | } - | |_________^ + --> $DIR/copies.rs:87:15 + | +87 | 42 => { + | _______________^ +88 | | foo(); +89 | | let mut a = 42 + [23].len() as i32; +90 | | if true { +... | +94 | | a +95 | | }, + | |_________^ note: `42` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:81:15 - | -81 | 42 => { - | _______________^ -82 | | foo(); -83 | | let mut a = 42 + [23].len() as i32; -84 | | if true { -... | -88 | | a -89 | | } - | |_________^ + --> $DIR/copies.rs:87:15 + | +87 | 42 => { + | _______________^ +88 | | foo(); +89 | | let mut a = 42 + [23].len() as i32; +90 | | if true { +... | +94 | | a +95 | | }, + | |_________^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:104:14 + --> $DIR/copies.rs:111:14 | -104 | _ => 0, //~ ERROR match arms have same body +111 | _ => 0, //~ ERROR match arms have same body | ^ | note: same as this - --> $DIR/copies.rs:102:19 + --> $DIR/copies.rs:109:19 | -102 | Abc::A => 0, +109 | Abc::A => 0, | ^ note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:102:19 + --> $DIR/copies.rs:109:19 | -102 | Abc::A => 0, +109 | Abc::A => 0, | ^ error: this `if` has identical blocks - --> $DIR/copies.rs:114:10 + --> $DIR/copies.rs:120:12 | -114 | else { //~ ERROR same body as `if` block - | __________^ -115 | | 42 -116 | | }; +120 | } else { + | ____________^ +121 | | //~ ERROR same body as `if` block +122 | | 42 +123 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:111:21 + --> $DIR/copies.rs:118:21 | -111 | let _ = if true { +118 | let _ = if true { | _____________________^ -112 | | 42 -113 | | } +119 | | 42 +120 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:128:10 + --> $DIR/copies.rs:134:12 | -128 | else { //~ ERROR same body as `if` block - | __________^ -129 | | for _ in &[42] { -130 | | let foo: &Option<_> = &Some::(42); -131 | | if true { +134 | } else { + | ____________^ +135 | | //~ ERROR same body as `if` block +136 | | for _ in &[42] { +137 | | let foo: &Option<_> = &Some::(42); ... | -136 | | } -137 | | } +143 | | } +144 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:118:13 + --> $DIR/copies.rs:125:13 | -118 | if true { +125 | if true { | _____________^ -119 | | for _ in &[42] { -120 | | let foo: &Option<_> = &Some::(42); -121 | | if true { +126 | | for _ in &[42] { +127 | | let foo: &Option<_> = &Some::(42); +128 | | if true { ... | -126 | | } -127 | | } +133 | | } +134 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:150:10 + --> $DIR/copies.rs:153:12 | -150 | else { //~ ERROR same body as `if` block - | __________^ -151 | | let bar = if true { -152 | | 42 -153 | | } +153 | } else { + | ____________^ +154 | | //~ ERROR same body as `if` block +155 | | let bar = if true { 42 } else { 43 }; +156 | | ... | -159 | | bar + 1; -160 | | } +160 | | bar + 1; +161 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:139:13 + --> $DIR/copies.rs:146:13 | -139 | if true { +146 | if true { | _____________^ -140 | | let bar = if true { -141 | | 42 -142 | | } +147 | | let bar = if true { 42 } else { 43 }; +148 | | +149 | | while foo() { ... | -148 | | bar + 1; -149 | | } +152 | | bar + 1; +153 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:185:10 + --> $DIR/copies.rs:183:12 | -185 | else { //~ ERROR same body as `if` block - | __________^ -186 | | if let Some(a) = Some(42) {} -187 | | } +183 | } else { + | ____________^ +184 | | //~ ERROR same body as `if` block +185 | | if let Some(a) = Some(42) {} +186 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:182:13 + --> $DIR/copies.rs:181:13 | -182 | if true { +181 | if true { | _____________^ -183 | | if let Some(a) = Some(42) {} -184 | | } +182 | | if let Some(a) = Some(42) {} +183 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:192:10 + --> $DIR/copies.rs:190:12 | -192 | else { //~ ERROR same body as `if` block - | __________^ -193 | | if let (1, .., 3) = (1, 2, 3) {} -194 | | } +190 | } else { + | ____________^ +191 | | //~ ERROR same body as `if` block +192 | | if let (1, .., 3) = (1, 2, 3) {} +193 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:189:13 + --> $DIR/copies.rs:188:13 | -189 | if true { +188 | if true { | _____________^ -190 | | if let (1, .., 3) = (1, 2, 3) {} -191 | | } +189 | | if let (1, .., 3) = (1, 2, 3) {} +190 | | } else { | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:247:15 + --> $DIR/copies.rs:239:15 | -247 | 51 => foo(), //~ ERROR match arms have same body +239 | 51 => foo(), //~ ERROR match arms have same body | ^^^^^ | note: same as this - --> $DIR/copies.rs:246:15 + --> $DIR/copies.rs:238:15 | -246 | 42 => foo(), +238 | 42 => foo(), | ^^^^^ note: consider refactoring into `42 | 51` - --> $DIR/copies.rs:246:15 + --> $DIR/copies.rs:238:15 | -246 | 42 => foo(), +238 | 42 => foo(), | ^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:253:17 + --> $DIR/copies.rs:245:17 | -253 | None => 24, //~ ERROR match arms have same body +245 | None => 24, //~ ERROR match arms have same body | ^^ | note: same as this - --> $DIR/copies.rs:252:20 + --> $DIR/copies.rs:244:20 | -252 | Some(_) => 24, +244 | Some(_) => 24, | ^^ note: consider refactoring into `Some(_) | None` - --> $DIR/copies.rs:252:20 + --> $DIR/copies.rs:244:20 | -252 | Some(_) => 24, +244 | Some(_) => 24, | ^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:275:28 + --> $DIR/copies.rs:267:28 | -275 | (None, Some(a)) => bar(a), //~ ERROR match arms have same body +267 | (None, Some(a)) => bar(a), //~ ERROR match arms have same body | ^^^^^^ | note: same as this - --> $DIR/copies.rs:274:28 + --> $DIR/copies.rs:266:28 | -274 | (Some(a), None) => bar(a), +266 | (Some(a), None) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), None) | (None, Some(a))` - --> $DIR/copies.rs:274:28 + --> $DIR/copies.rs:266:28 | -274 | (Some(a), None) => bar(a), +266 | (Some(a), None) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:281:26 + --> $DIR/copies.rs:273:26 | -281 | (.., Some(a)) => bar(a), //~ ERROR match arms have same body +273 | (.., Some(a)) => bar(a), //~ ERROR match arms have same body | ^^^^^^ | note: same as this - --> $DIR/copies.rs:280:26 + --> $DIR/copies.rs:272:26 | -280 | (Some(a), ..) => bar(a), +272 | (Some(a), ..) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), ..) | (.., Some(a))` - --> $DIR/copies.rs:280:26 + --> $DIR/copies.rs:272:26 | -280 | (Some(a), ..) => bar(a), +272 | (Some(a), ..) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:287:20 + --> $DIR/copies.rs:279:20 | -287 | (.., 3) => 42, //~ ERROR match arms have same body +279 | (.., 3) => 42, //~ ERROR match arms have same body | ^^ | note: same as this - --> $DIR/copies.rs:286:23 + --> $DIR/copies.rs:278:23 | -286 | (1, .., 3) => 42, +278 | (1, .., 3) => 42, | ^^ note: consider refactoring into `(1, .., 3) | (.., 3)` - --> $DIR/copies.rs:286:23 + --> $DIR/copies.rs:278:23 | -286 | (1, .., 3) => 42, +278 | (1, .., 3) => 42, | ^^ error: this `if` has identical blocks - --> $DIR/copies.rs:293:12 + --> $DIR/copies.rs:285:12 | -293 | } else { //~ ERROR same body as `if` block +285 | } else { | ____________^ -294 | | 0.0 +286 | | //~ ERROR same body as `if` block +287 | | 0.0 +288 | | }; + | |_____^ + | +note: same as this + --> $DIR/copies.rs:283:21 + | +283 | let _ = if true { + | _____________________^ +284 | | 0.0 +285 | | } else { + | |_____^ + +error: this `if` has identical blocks + --> $DIR/copies.rs:292:12 + | +292 | } else { + | ____________^ +293 | | //~ ERROR same body as `if` block +294 | | -0.0 295 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:291:21 + --> $DIR/copies.rs:290:21 | -291 | let _ = if true { +290 | let _ = if true { | _____________________^ -292 | | 0.0 -293 | | } else { //~ ERROR same body as `if` block +291 | | -0.0 +292 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:299:12 + --> $DIR/copies.rs:305:12 | -299 | } else { //~ ERROR same body as `if` block +305 | } else { | ____________^ -300 | | -0.0 -301 | | }; +306 | | //~ ERROR same body as `if` block +307 | | std::f32::NAN +308 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:297:21 + --> $DIR/copies.rs:303:21 | -297 | let _ = if true { +303 | let _ = if true { | _____________________^ -298 | | -0.0 -299 | | } else { //~ ERROR same body as `if` block +304 | | std::f32::NAN +305 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:319:12 + --> $DIR/copies.rs:323:12 | -319 | } else { //~ ERROR same body as `if` block +323 | } else { | ____________^ -320 | | std::f32::NAN -321 | | }; +324 | | //~ ERROR same body as `if` block +325 | | try!(Ok("foo")); +326 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:317:21 + --> $DIR/copies.rs:321:13 | -317 | let _ = if true { - | _____________________^ -318 | | std::f32::NAN -319 | | } else { //~ ERROR same body as `if` block - | |_____^ - -error: this `if` has identical blocks - --> $DIR/copies.rs:337:10 - | -337 | else { //~ ERROR same body as `if` block - | __________^ -338 | | try!(Ok("foo")); -339 | | } - | |_____^ - | -note: same as this - --> $DIR/copies.rs:334:13 - | -334 | if true { +321 | if true { | _____________^ -335 | | try!(Ok("foo")); -336 | | } +322 | | try!(Ok("foo")); +323 | | } else { | |_____^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:363:13 + --> $DIR/copies.rs:347:15 | -363 | else if b { //~ ERROR ifs same condition - | ^ +347 | } else if b { + | ^ | = note: `-D clippy::ifs-same-cond` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:361:8 + --> $DIR/copies.rs:346:8 | -361 | if b { +346 | if b { | ^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:368:13 + --> $DIR/copies.rs:352:15 | -368 | else if a == 1 { //~ ERROR ifs same condition - | ^^^^^^ +352 | } else if a == 1 { + | ^^^^^^ | note: same as this - --> $DIR/copies.rs:366:8 + --> $DIR/copies.rs:351:8 | -366 | if a == 1 { +351 | if a == 1 { | ^^^^^^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:375:13 + --> $DIR/copies.rs:358:15 | -375 | else if 2*a == 1 { //~ ERROR ifs same condition - | ^^^^^^^^ +358 | } else if 2 * a == 1 { + | ^^^^^^^^^^ | note: same as this - --> $DIR/copies.rs:371:8 + --> $DIR/copies.rs:356:8 | -371 | if 2*a == 1 { - | ^^^^^^^^ +356 | if 2 * a == 1 { + | ^^^^^^^^^^ error: aborting due to 20 previous errors diff --git a/tests/ui/copy_iterator.stderr b/tests/ui/copy_iterator.stderr index 4620958f47b..ced9293d1dc 100644 --- a/tests/ui/copy_iterator.stderr +++ b/tests/ui/copy_iterator.stderr @@ -1,13 +1,13 @@ error: you are implementing `Iterator` on a `Copy` type - --> $DIR/copy_iterator.rs:18:1 + --> $DIR/copy_iterator.rs:15:1 | -18 | / impl Iterator for Countdown { -19 | | type Item = u8; -20 | | -21 | | fn next(&mut self) -> Option { +15 | / impl Iterator for Countdown { +16 | | type Item = u8; +17 | | +18 | | fn next(&mut self) -> Option { ... | -26 | | } -27 | | } +23 | | } +24 | | } | |_^ | = note: `-D clippy::copy-iterator` implied by `-D warnings` diff --git a/tests/ui/cstring.stderr b/tests/ui/cstring.stderr index 74d6e864de4..490a655ca26 100644 --- a/tests/ui/cstring.stderr +++ b/tests/ui/cstring.stderr @@ -1,15 +1,15 @@ error: you are getting the inner pointer of a temporary `CString` - --> $DIR/cstring.rs:19:5 + --> $DIR/cstring.rs:16:5 | -19 | CString::new("foo").unwrap().as_ptr(); +16 | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(clippy::temporary_cstring_as_ptr)] on by default = note: that pointer will be invalid outside this expression help: assign the `CString` to a variable to extend its lifetime - --> $DIR/cstring.rs:19:5 + --> $DIR/cstring.rs:16:5 | -19 | CString::new("foo").unwrap().as_ptr(); +16 | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/cyclomatic_complexity.stderr b/tests/ui/cyclomatic_complexity.stderr index 390df2f5a5b..de9e5c77f1b 100644 --- a/tests/ui/cyclomatic_complexity.stderr +++ b/tests/ui/cyclomatic_complexity.stderr @@ -1,270 +1,269 @@ error: the function has a cyclomatic complexity of 28 - --> $DIR/cyclomatic_complexity.rs:16:1 + --> $DIR/cyclomatic_complexity.rs:15:1 | -16 | / fn main() { -17 | | if true { -18 | | println!("a"); -19 | | } +15 | / fn main() { +16 | | if true { +17 | | println!("a"); +18 | | } ... | -97 | | } -98 | | } +96 | | } +97 | | } | |_^ | = note: `-D clippy::cyclomatic-complexity` implied by `-D warnings` = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 7 - --> $DIR/cyclomatic_complexity.rs:101:1 + --> $DIR/cyclomatic_complexity.rs:100:1 | -101 | / fn kaboom() { -102 | | let n = 0; -103 | | 'a: for i in 0..20 { -104 | | 'b: for j in i..20 { +100 | / fn kaboom() { +101 | | let n = 0; +102 | | 'a: for i in 0..20 { +103 | | 'b: for j in i..20 { ... | -119 | | } -120 | | } +118 | | } +119 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:147:1 + --> $DIR/cyclomatic_complexity.rs:146:1 | -147 | / fn lots_of_short_circuits() -> bool { -148 | | true && false && true && false && true && false && true -149 | | } +146 | / fn lots_of_short_circuits() -> bool { +147 | | true && false && true && false && true && false && true +148 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:152:1 + --> $DIR/cyclomatic_complexity.rs:151:1 | -152 | / fn lots_of_short_circuits2() -> bool { -153 | | true || false || true || false || true || false || true -154 | | } +151 | / fn lots_of_short_circuits2() -> bool { +152 | | true || false || true || false || true || false || true +153 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:157:1 + --> $DIR/cyclomatic_complexity.rs:156:1 | -157 | / fn baa() { -158 | | let x = || match 99 { -159 | | 0 => 0, -160 | | 1 => 1, +156 | / fn baa() { +157 | | let x = || match 99 { +158 | | 0 => 0, +159 | | 1 => 1, ... | -171 | | } -172 | | } +170 | | } +171 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:158:13 + --> $DIR/cyclomatic_complexity.rs:157:13 | -158 | let x = || match 99 { +157 | let x = || match 99 { | _____________^ -159 | | 0 => 0, -160 | | 1 => 1, -161 | | 2 => 2, +158 | | 0 => 0, +159 | | 1 => 1, +160 | | 2 => 2, ... | -165 | | _ => 42, -166 | | }; +164 | | _ => 42, +165 | | }; | |_____^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:175:1 + --> $DIR/cyclomatic_complexity.rs:174:1 | -175 | / fn bar() { -176 | | match 99 { -177 | | 0 => println!("hi"), -178 | | _ => println!("bye"), -179 | | } -180 | | } +174 | / fn bar() { +175 | | match 99 { +176 | | 0 => println!("hi"), +177 | | _ => println!("bye"), +178 | | } +179 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:194:1 + --> $DIR/cyclomatic_complexity.rs:193:1 | -194 | / fn barr() { -195 | | match 99 { -196 | | 0 => println!("hi"), -197 | | 1 => println!("bla"), +193 | / fn barr() { +194 | | match 99 { +195 | | 0 => println!("hi"), +196 | | 1 => println!("bla"), ... | -200 | | } -201 | | } +199 | | } +200 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity.rs:204:1 + --> $DIR/cyclomatic_complexity.rs:203:1 | -204 | / fn barr2() { -205 | | match 99 { -206 | | 0 => println!("hi"), -207 | | 1 => println!("bla"), +203 | / fn barr2() { +204 | | match 99 { +205 | | 0 => println!("hi"), +206 | | 1 => println!("bla"), ... | -216 | | } -217 | | } +215 | | } +216 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:220:1 + --> $DIR/cyclomatic_complexity.rs:219:1 | -220 | / fn barrr() { -221 | | match 99 { -222 | | 0 => println!("hi"), -223 | | 1 => panic!("bla"), +219 | / fn barrr() { +220 | | match 99 { +221 | | 0 => println!("hi"), +222 | | 1 => panic!("bla"), ... | -226 | | } -227 | | } +225 | | } +226 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity.rs:230:1 + --> $DIR/cyclomatic_complexity.rs:229:1 | -230 | / fn barrr2() { -231 | | match 99 { -232 | | 0 => println!("hi"), -233 | | 1 => panic!("bla"), +229 | / fn barrr2() { +230 | | match 99 { +231 | | 0 => println!("hi"), +232 | | 1 => panic!("bla"), ... | -242 | | } -243 | | } +241 | | } +242 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:246:1 + --> $DIR/cyclomatic_complexity.rs:245:1 | -246 | / fn barrrr() { -247 | | match 99 { -248 | | 0 => println!("hi"), -249 | | 1 => println!("bla"), +245 | / fn barrrr() { +246 | | match 99 { +247 | | 0 => println!("hi"), +248 | | 1 => println!("bla"), ... | -252 | | } -253 | | } +251 | | } +252 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity.rs:256:1 + --> $DIR/cyclomatic_complexity.rs:255:1 | -256 | / fn barrrr2() { -257 | | match 99 { -258 | | 0 => println!("hi"), -259 | | 1 => println!("bla"), +255 | / fn barrrr2() { +256 | | match 99 { +257 | | 0 => println!("hi"), +258 | | 1 => println!("bla"), ... | -268 | | } -269 | | } +267 | | } +268 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:272:1 + --> $DIR/cyclomatic_complexity.rs:271:1 | -272 | / fn cake() { -273 | | if 4 == 5 { -274 | | println!("yea"); -275 | | } else { +271 | / fn cake() { +272 | | if 4 == 5 { +273 | | println!("yea"); +274 | | } else { ... | -278 | | println!("whee"); -279 | | } +277 | | println!("whee"); +278 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 4 - --> $DIR/cyclomatic_complexity.rs:283:1 + --> $DIR/cyclomatic_complexity.rs:281:1 | -283 | / pub fn read_file(input_path: &str) -> String { -284 | | use std::fs::File; -285 | | use std::io::{Read, Write}; -286 | | use std::path::Path; +281 | / pub fn read_file(input_path: &str) -> String { +282 | | use std::fs::File; +283 | | use std::io::{Read, Write}; +284 | | use std::path::Path; ... | -308 | | } -309 | | } +306 | | } +307 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:314:1 + --> $DIR/cyclomatic_complexity.rs:312:1 | -314 | / fn void(void: Void) { -315 | | if true { -316 | | match void { -317 | | } -318 | | } -319 | | } +312 | / fn void(void: Void) { +313 | | if true { +314 | | match void {} +315 | | } +316 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:328:1 + --> $DIR/cyclomatic_complexity.rs:325:1 | -328 | / fn try() -> Result { -329 | | match 5 { -330 | | 5 => Ok(5), -331 | | _ => return Err("bla"), -332 | | } -333 | | } +325 | / fn try() -> Result { +326 | | match 5 { +327 | | 5 => Ok(5), +328 | | _ => return Err("bla"), +329 | | } +330 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:336:1 + --> $DIR/cyclomatic_complexity.rs:333:1 | -336 | / fn try_again() -> Result { -337 | | let _ = try!(Ok(42)); -338 | | let _ = try!(Ok(43)); -339 | | let _ = try!(Ok(44)); +333 | / fn try_again() -> Result { +334 | | let _ = try!(Ok(42)); +335 | | let _ = try!(Ok(43)); +336 | | let _ = try!(Ok(44)); ... | -348 | | } -349 | | } +345 | | } +346 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:352:1 + --> $DIR/cyclomatic_complexity.rs:349:1 | -352 | / fn early() -> Result { -353 | | return Ok(5); -354 | | return Ok(5); -355 | | return Ok(5); +349 | / fn early() -> Result { +350 | | return Ok(5); +351 | | return Ok(5); +352 | | return Ok(5); ... | -361 | | return Ok(5); -362 | | } +358 | | return Ok(5); +359 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 8 - --> $DIR/cyclomatic_complexity.rs:366:1 + --> $DIR/cyclomatic_complexity.rs:363:1 | -366 | / fn early_ret() -> i32 { -367 | | let a = if true { 42 } else { return 0; }; -368 | | let a = if a < 99 { 42 } else { return 0; }; -369 | | let a = if a < 99 { 42 } else { return 0; }; +363 | / fn early_ret() -> i32 { +364 | | let a = if true { 42 } else { return 0; }; +365 | | let a = if a < 99 { 42 } else { return 0; }; +366 | | let a = if a < 99 { 42 } else { return 0; }; ... | -382 | | } -383 | | } +379 | | } +380 | | } | |_^ | = help: you could split it up into multiple smaller functions diff --git a/tests/ui/cyclomatic_complexity_attr_used.stderr b/tests/ui/cyclomatic_complexity_attr_used.stderr index f066e29ce75..3493c0d9ea5 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.stderr +++ b/tests/ui/cyclomatic_complexity_attr_used.stderr @@ -1,13 +1,13 @@ error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity_attr_used.rs:21:1 + --> $DIR/cyclomatic_complexity_attr_used.rs:18:1 | -21 | / fn kaboom() { -22 | | if 42 == 43 { -23 | | panic!(); -24 | | } else if "cake" == "lie" { -25 | | println!("what?"); -26 | | } -27 | | } +18 | / fn kaboom() { +19 | | if 42 == 43 { +20 | | panic!(); +21 | | } else if "cake" == "lie" { +22 | | println!("what?"); +23 | | } +24 | | } | |_^ | = note: `-D clippy::cyclomatic-complexity` implied by `-D warnings` diff --git a/tests/ui/decimal_literal_representation.stderr b/tests/ui/decimal_literal_representation.stderr index d944c49066a..42f8a6e3bc5 100644 --- a/tests/ui/decimal_literal_representation.stderr +++ b/tests/ui/decimal_literal_representation.stderr @@ -1,33 +1,33 @@ error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:28:9 + --> $DIR/decimal_literal_representation.rs:26:9 | -28 | 32_773, // 0x8005 +26 | 32_773, // 0x8005 | ^^^^^^ help: consider: `0x8005` | = note: `-D clippy::decimal-literal-representation` implied by `-D warnings` +error: integer literal has a better hexadecimal representation + --> $DIR/decimal_literal_representation.rs:27:9 + | +27 | 65_280, // 0xFF00 + | ^^^^^^ help: consider: `0xFF00` + +error: integer literal has a better hexadecimal representation + --> $DIR/decimal_literal_representation.rs:28:9 + | +28 | 2_131_750_927, // 0x7F0F_F00F + | ^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F` + error: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:29:9 | -29 | 65_280, // 0xFF00 - | ^^^^^^ help: consider: `0xFF00` +29 | 2_147_483_647, // 0x7FFF_FFFF + | ^^^^^^^^^^^^^ help: consider: `0x7FFF_FFFF` error: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:30:9 | -30 | 2_131_750_927, // 0x7F0F_F00F - | ^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F` - -error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:31:9 - | -31 | 2_147_483_647, // 0x7FFF_FFFF - | ^^^^^^^^^^^^^ help: consider: `0x7FFF_FFFF` - -error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:32:9 - | -32 | 4_042_322_160, // 0xF0F0_F0F0 +30 | 4_042_322_160, // 0xF0F0_F0F0 | ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0` error: aborting due to 5 previous errors diff --git a/tests/ui/default_trait_access.stderr b/tests/ui/default_trait_access.stderr index d6ae00214c0..b838f6a3bf4 100644 --- a/tests/ui/default_trait_access.stderr +++ b/tests/ui/default_trait_access.stderr @@ -1,51 +1,51 @@ error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:20:22 + --> $DIR/default_trait_access.rs:17:22 | -20 | let s1: String = Default::default(); +17 | let s1: String = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` | = note: `-D clippy::default-trait-access` implied by `-D warnings` error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:24:22 + --> $DIR/default_trait_access.rs:21:22 | -24 | let s3: String = D2::default(); +21 | let s3: String = D2::default(); | ^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:26:22 + --> $DIR/default_trait_access.rs:23:22 | -26 | let s4: String = std::default::Default::default(); +23 | let s4: String = std::default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:30:22 + --> $DIR/default_trait_access.rs:27:22 | -30 | let s6: String = default::Default::default(); +27 | let s6: String = default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling GenericDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:40:46 + --> $DIR/default_trait_access.rs:37:46 | -40 | let s11: GenericDerivedDefault = Default::default(); +37 | let s11: GenericDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault::default()` error: Calling TupleDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:46:36 + --> $DIR/default_trait_access.rs:43:36 | -46 | let s14: TupleDerivedDefault = Default::default(); +43 | let s14: TupleDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleDerivedDefault::default()` error: Calling ArrayDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:48:36 + --> $DIR/default_trait_access.rs:45:36 | -48 | let s15: ArrayDerivedDefault = Default::default(); +45 | let s15: ArrayDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `ArrayDerivedDefault::default()` error: Calling TupleStructDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:52:42 + --> $DIR/default_trait_access.rs:49:42 | -52 | let s17: TupleStructDerivedDefault = Default::default(); +49 | let s17: TupleStructDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleStructDerivedDefault::default()` error: aborting due to 8 previous errors diff --git a/tests/ui/deprecated.stderr b/tests/ui/deprecated.stderr index d44528ab28f..335f6451e59 100644 --- a/tests/ui/deprecated.stderr +++ b/tests/ui/deprecated.stderr @@ -1,33 +1,33 @@ error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon` - --> $DIR/deprecated.rs:14:8 + --> $DIR/deprecated.rs:10:8 | -14 | #[warn(str_to_string)] +10 | #[warn(str_to_string)] | ^^^^^^^^^^^^^ | = note: `-D renamed-and-removed-lints` implied by `-D warnings` error: lint `string_to_string` has been removed: `using `string::to_string` is common even today and specialization will likely happen soon` - --> $DIR/deprecated.rs:16:8 + --> $DIR/deprecated.rs:11:8 | -16 | #[warn(string_to_string)] +11 | #[warn(string_to_string)] | ^^^^^^^^^^^^^^^^ error: lint `unstable_as_slice` has been removed: ``Vec::as_slice` has been stabilized in 1.7` - --> $DIR/deprecated.rs:18:8 + --> $DIR/deprecated.rs:12:8 | -18 | #[warn(unstable_as_slice)] +12 | #[warn(unstable_as_slice)] | ^^^^^^^^^^^^^^^^^ error: lint `unstable_as_mut_slice` has been removed: ``Vec::as_mut_slice` has been stabilized in 1.7` - --> $DIR/deprecated.rs:20:8 + --> $DIR/deprecated.rs:13:8 | -20 | #[warn(unstable_as_mut_slice)] +13 | #[warn(unstable_as_mut_slice)] | ^^^^^^^^^^^^^^^^^^^^^ error: lint `misaligned_transmute` has been removed: `this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr` - --> $DIR/deprecated.rs:22:8 + --> $DIR/deprecated.rs:14:8 | -22 | #[warn(misaligned_transmute)] +14 | #[warn(misaligned_transmute)] | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/derive.stderr b/tests/ui/derive.stderr index 824b5b44cba..dd36f773337 100644 --- a/tests/ui/derive.stderr +++ b/tests/ui/derive.stderr @@ -1,15 +1,17 @@ error: you are deriving `Hash` but have implemented `PartialEq` explicitly - --> $DIR/derive.rs:27:10 + --> $DIR/derive.rs:25:10 | -27 | #[derive(Hash)] +25 | #[derive(Hash)] | ^^^^ | = note: #[deny(clippy::derive_hash_xor_eq)] on by default note: `PartialEq` implemented here - --> $DIR/derive.rs:30:1 + --> $DIR/derive.rs:28:1 | -30 | / impl PartialEq for Bar { -31 | | fn eq(&self, _: &Bar) -> bool { true } +28 | / impl PartialEq for Bar { +29 | | fn eq(&self, _: &Bar) -> bool { +30 | | true +31 | | } 32 | | } | |_^ @@ -23,88 +25,106 @@ note: `PartialEq` implemented here --> $DIR/derive.rs:37:1 | 37 | / impl PartialEq for Baz { -38 | | fn eq(&self, _: &Baz) -> bool { true } -39 | | } +38 | | fn eq(&self, _: &Baz) -> bool { +39 | | true +40 | | } +41 | | } | |_^ error: you are implementing `Hash` explicitly but have derived `PartialEq` - --> $DIR/derive.rs:44:1 + --> $DIR/derive.rs:46:1 | -44 | / impl Hash for Bah { -45 | | fn hash(&self, _: &mut H) {} -46 | | } +46 | / impl Hash for Bah { +47 | | fn hash(&self, _: &mut H) {} +48 | | } | |_^ | note: `PartialEq` implemented here - --> $DIR/derive.rs:41:10 + --> $DIR/derive.rs:43:10 | -41 | #[derive(PartialEq)] +43 | #[derive(PartialEq)] | ^^^^^^^^^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:51:1 + --> $DIR/derive.rs:53:1 | -51 | / impl Clone for Qux { -52 | | fn clone(&self) -> Self { Qux } -53 | | } +53 | / impl Clone for Qux { +54 | | fn clone(&self) -> Self { +55 | | Qux +56 | | } +57 | | } | |_^ | = note: `-D clippy::expl-impl-clone-on-copy` implied by `-D warnings` note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:51:1 + --> $DIR/derive.rs:53:1 | -51 | / impl Clone for Qux { -52 | | fn clone(&self) -> Self { Qux } -53 | | } +53 | / impl Clone for Qux { +54 | | fn clone(&self) -> Self { +55 | | Qux +56 | | } +57 | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:75:1 + --> $DIR/derive.rs:77:1 | -75 | / impl<'a> Clone for Lt<'a> { -76 | | fn clone(&self) -> Self { unimplemented!() } -77 | | } +77 | / impl<'a> Clone for Lt<'a> { +78 | | fn clone(&self) -> Self { +79 | | unimplemented!() +80 | | } +81 | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:75:1 + --> $DIR/derive.rs:77:1 | -75 | / impl<'a> Clone for Lt<'a> { -76 | | fn clone(&self) -> Self { unimplemented!() } -77 | | } +77 | / impl<'a> Clone for Lt<'a> { +78 | | fn clone(&self) -> Self { +79 | | unimplemented!() +80 | | } +81 | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:85:1 + --> $DIR/derive.rs:89:1 | -85 | / impl Clone for BigArray { -86 | | fn clone(&self) -> Self { unimplemented!() } -87 | | } +89 | / impl Clone for BigArray { +90 | | fn clone(&self) -> Self { +91 | | unimplemented!() +92 | | } +93 | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:85:1 + --> $DIR/derive.rs:89:1 | -85 | / impl Clone for BigArray { -86 | | fn clone(&self) -> Self { unimplemented!() } -87 | | } +89 | / impl Clone for BigArray { +90 | | fn clone(&self) -> Self { +91 | | unimplemented!() +92 | | } +93 | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:95:1 - | -95 | / impl Clone for FnPtr { -96 | | fn clone(&self) -> Self { unimplemented!() } -97 | | } - | |_^ - | + --> $DIR/derive.rs:101:1 + | +101 | / impl Clone for FnPtr { +102 | | fn clone(&self) -> Self { +103 | | unimplemented!() +104 | | } +105 | | } + | |_^ + | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:95:1 - | -95 | / impl Clone for FnPtr { -96 | | fn clone(&self) -> Self { unimplemented!() } -97 | | } - | |_^ + --> $DIR/derive.rs:101:1 + | +101 | / impl Clone for FnPtr { +102 | | fn clone(&self) -> Self { +103 | | unimplemented!() +104 | | } +105 | | } + | |_^ error: aborting due to 7 previous errors diff --git a/tests/ui/dlist.stderr b/tests/ui/dlist.stderr index b3dc6095cd8..f2ca4dab997 100644 --- a/tests/ui/dlist.stderr +++ b/tests/ui/dlist.stderr @@ -1,48 +1,48 @@ error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:24:16 + --> $DIR/dlist.rs:19:16 | -24 | type Baz = LinkedList; +19 | type Baz = LinkedList; | ^^^^^^^^^^^^^^ | = note: `-D clippy::linkedlist` implied by `-D warnings` = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:25:12 + --> $DIR/dlist.rs:20:12 | -25 | fn foo(LinkedList); +20 | fn foo(LinkedList); | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:26:24 + --> $DIR/dlist.rs:21:23 | -26 | const BAR : Option>; - | ^^^^^^^^^^^^^^ +21 | const BAR: Option>; + | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:37:15 + --> $DIR/dlist.rs:32:15 | -37 | fn foo(_: LinkedList) {} +32 | fn foo(_: LinkedList) {} | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:40:39 + --> $DIR/dlist.rs:35:39 | -40 | pub fn test(my_favourite_linked_list: LinkedList) { +35 | pub fn test(my_favourite_linked_list: LinkedList) { | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:44:29 + --> $DIR/dlist.rs:39:29 | -44 | pub fn test_ret() -> Option> { +39 | pub fn test_ret() -> Option> { | ^^^^^^^^^^^^^^ | = help: a VecDeque might work diff --git a/tests/ui/double_comparison.stderr b/tests/ui/double_comparison.stderr index 646b6f13fab..a06f278efc0 100644 --- a/tests/ui/double_comparison.stderr +++ b/tests/ui/double_comparison.stderr @@ -1,51 +1,51 @@ error: This binary expression can be simplified - --> $DIR/double_comparison.rs:14:8 + --> $DIR/double_comparison.rs:13:8 | -14 | if x == y || x < y { +13 | if x == y || x < y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` | = note: `-D clippy::double-comparisons` implied by `-D warnings` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:17:8 + --> $DIR/double_comparison.rs:16:8 | -17 | if x < y || x == y { +16 | if x < y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:20:8 + --> $DIR/double_comparison.rs:19:8 | -20 | if x == y || x > y { +19 | if x == y || x > y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:23:8 + --> $DIR/double_comparison.rs:22:8 | -23 | if x > y || x == y { +22 | if x > y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:26:8 + --> $DIR/double_comparison.rs:25:8 | -26 | if x < y || x > y { +25 | if x < y || x > y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:29:8 + --> $DIR/double_comparison.rs:28:8 | -29 | if x > y || x < y { +28 | if x > y || x < y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:32:8 + --> $DIR/double_comparison.rs:31:8 | -32 | if x <= y && x >= y { +31 | if x <= y && x >= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:35:8 + --> $DIR/double_comparison.rs:34:8 | -35 | if x >= y && x <= y { +34 | if x >= y && x <= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` error: aborting due to 8 previous errors diff --git a/tests/ui/double_neg.stderr b/tests/ui/double_neg.stderr index cf0292f7af1..11ad5601286 100644 --- a/tests/ui/double_neg.stderr +++ b/tests/ui/double_neg.stderr @@ -1,7 +1,7 @@ error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op - --> $DIR/double_neg.rs:19:5 + --> $DIR/double_neg.rs:15:5 | -19 | --x; +15 | --x; | ^^^ | = note: `-D clippy::double-neg` implied by `-D warnings` diff --git a/tests/ui/drop_forget_copy.stderr b/tests/ui/drop_forget_copy.stderr index ef337ae6691..3b950eaebe3 100644 --- a/tests/ui/drop_forget_copy.stderr +++ b/tests/ui/drop_forget_copy.stderr @@ -1,75 +1,75 @@ error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:43:5 + --> $DIR/drop_forget_copy.rs:42:5 | -43 | drop(s1); +42 | drop(s1); | ^^^^^^^^ | = note: `-D clippy::drop-copy` implied by `-D warnings` +note: argument has type SomeStruct + --> $DIR/drop_forget_copy.rs:42:10 + | +42 | drop(s1); + | ^^ + +error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact. + --> $DIR/drop_forget_copy.rs:43:5 + | +43 | drop(s2); + | ^^^^^^^^ + | note: argument has type SomeStruct --> $DIR/drop_forget_copy.rs:43:10 | -43 | drop(s1); +43 | drop(s2); | ^^ error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:44:5 + --> $DIR/drop_forget_copy.rs:45:5 | -44 | drop(s2); +45 | drop(s4); | ^^^^^^^^ | note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:44:10 + --> $DIR/drop_forget_copy.rs:45:10 | -44 | drop(s2); - | ^^ - -error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:46:5 - | -46 | drop(s4); - | ^^^^^^^^ - | -note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:46:10 - | -46 | drop(s4); +45 | drop(s4); | ^^ error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:49:5 + --> $DIR/drop_forget_copy.rs:48:5 | -49 | forget(s1); +48 | forget(s1); | ^^^^^^^^^^ | = note: `-D clippy::forget-copy` implied by `-D warnings` +note: argument has type SomeStruct + --> $DIR/drop_forget_copy.rs:48:12 + | +48 | forget(s1); + | ^^ + +error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact. + --> $DIR/drop_forget_copy.rs:49:5 + | +49 | forget(s2); + | ^^^^^^^^^^ + | note: argument has type SomeStruct --> $DIR/drop_forget_copy.rs:49:12 | -49 | forget(s1); +49 | forget(s2); | ^^ error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:50:5 + --> $DIR/drop_forget_copy.rs:51:5 | -50 | forget(s2); +51 | forget(s4); | ^^^^^^^^^^ | note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:50:12 + --> $DIR/drop_forget_copy.rs:51:12 | -50 | forget(s2); - | ^^ - -error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:52:5 - | -52 | forget(s4); - | ^^^^^^^^^^ - | -note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:52:12 - | -52 | forget(s4); +51 | forget(s4); | ^^ error: aborting due to 6 previous errors diff --git a/tests/ui/drop_forget_ref.stderr b/tests/ui/drop_forget_ref.stderr index 15661ef1d2b..972ab298c4c 100644 --- a/tests/ui/drop_forget_ref.stderr +++ b/tests/ui/drop_forget_ref.stderr @@ -1,219 +1,219 @@ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:22:5 + --> $DIR/drop_forget_ref.rs:18:5 | -22 | drop(&SomeStruct); +18 | drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::drop-ref` implied by `-D warnings` note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:22:10 + --> $DIR/drop_forget_ref.rs:18:10 | -22 | drop(&SomeStruct); +18 | drop(&SomeStruct); | ^^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:23:5 + --> $DIR/drop_forget_ref.rs:19:5 | -23 | forget(&SomeStruct); +19 | forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::forget-ref` implied by `-D warnings` note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:23:12 + --> $DIR/drop_forget_ref.rs:19:12 | -23 | forget(&SomeStruct); +19 | forget(&SomeStruct); | ^^^^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:26:5 + --> $DIR/drop_forget_ref.rs:22:5 | -26 | drop(&owned1); +22 | drop(&owned1); | ^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:26:10 + --> $DIR/drop_forget_ref.rs:22:10 | -26 | drop(&owned1); +22 | drop(&owned1); | ^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:27:5 + --> $DIR/drop_forget_ref.rs:23:5 | -27 | drop(&&owned1); +23 | drop(&&owned1); | ^^^^^^^^^^^^^^ | note: argument has type &&SomeStruct - --> $DIR/drop_forget_ref.rs:27:10 + --> $DIR/drop_forget_ref.rs:23:10 | -27 | drop(&&owned1); +23 | drop(&&owned1); | ^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:28:5 + --> $DIR/drop_forget_ref.rs:24:5 | -28 | drop(&mut owned1); +24 | drop(&mut owned1); | ^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:28:10 + --> $DIR/drop_forget_ref.rs:24:10 | -28 | drop(&mut owned1); +24 | drop(&mut owned1); | ^^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:31:5 + --> $DIR/drop_forget_ref.rs:27:5 | -31 | forget(&owned2); +27 | forget(&owned2); | ^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:31:12 + --> $DIR/drop_forget_ref.rs:27:12 | -31 | forget(&owned2); +27 | forget(&owned2); | ^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:32:5 + --> $DIR/drop_forget_ref.rs:28:5 | -32 | forget(&&owned2); +28 | forget(&&owned2); | ^^^^^^^^^^^^^^^^ | note: argument has type &&SomeStruct - --> $DIR/drop_forget_ref.rs:32:12 + --> $DIR/drop_forget_ref.rs:28:12 | -32 | forget(&&owned2); +28 | forget(&&owned2); | ^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:33:5 + --> $DIR/drop_forget_ref.rs:29:5 | -33 | forget(&mut owned2); +29 | forget(&mut owned2); | ^^^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:33:12 + --> $DIR/drop_forget_ref.rs:29:12 | -33 | forget(&mut owned2); +29 | forget(&mut owned2); | ^^^^^^^^^^^ +error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. + --> $DIR/drop_forget_ref.rs:33:5 + | +33 | drop(reference1); + | ^^^^^^^^^^^^^^^^ + | +note: argument has type &SomeStruct + --> $DIR/drop_forget_ref.rs:33:10 + | +33 | drop(reference1); + | ^^^^^^^^^^ + +error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. + --> $DIR/drop_forget_ref.rs:34:5 + | +34 | forget(&*reference1); + | ^^^^^^^^^^^^^^^^^^^^ + | +note: argument has type &SomeStruct + --> $DIR/drop_forget_ref.rs:34:12 + | +34 | forget(&*reference1); + | ^^^^^^^^^^^^ + error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. --> $DIR/drop_forget_ref.rs:37:5 | -37 | drop(reference1); - | ^^^^^^^^^^^^^^^^ - | -note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:37:10 - | -37 | drop(reference1); - | ^^^^^^^^^^ - -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:38:5 - | -38 | forget(&*reference1); - | ^^^^^^^^^^^^^^^^^^^^ - | -note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:38:12 - | -38 | forget(&*reference1); - | ^^^^^^^^^^^^ - -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:41:5 - | -41 | drop(reference2); +37 | drop(reference2); | ^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:41:10 + --> $DIR/drop_forget_ref.rs:37:10 | -41 | drop(reference2); +37 | drop(reference2); + | ^^^^^^^^^^ + +error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. + --> $DIR/drop_forget_ref.rs:39:5 + | +39 | forget(reference3); + | ^^^^^^^^^^^^^^^^^^ + | +note: argument has type &mut SomeStruct + --> $DIR/drop_forget_ref.rs:39:12 + | +39 | forget(reference3); + | ^^^^^^^^^^ + +error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. + --> $DIR/drop_forget_ref.rs:42:5 + | +42 | drop(reference4); + | ^^^^^^^^^^^^^^^^ + | +note: argument has type &SomeStruct + --> $DIR/drop_forget_ref.rs:42:10 + | +42 | drop(reference4); | ^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. --> $DIR/drop_forget_ref.rs:43:5 | -43 | forget(reference3); +43 | forget(reference4); | ^^^^^^^^^^^^^^^^^^ | -note: argument has type &mut SomeStruct +note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:43:12 | -43 | forget(reference3); +43 | forget(reference4); | ^^^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:46:5 + --> $DIR/drop_forget_ref.rs:48:5 | -46 | drop(reference4); - | ^^^^^^^^^^^^^^^^ - | -note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:46:10 - | -46 | drop(reference4); - | ^^^^^^^^^^ - -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:47:5 - | -47 | forget(reference4); - | ^^^^^^^^^^^^^^^^^^ - | -note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:47:12 - | -47 | forget(reference4); - | ^^^^^^^^^^ - -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:52:5 - | -52 | drop(&val); +48 | drop(&val); | ^^^^^^^^^^ | note: argument has type &T - --> $DIR/drop_forget_ref.rs:52:10 + --> $DIR/drop_forget_ref.rs:48:10 | -52 | drop(&val); +48 | drop(&val); | ^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:58:5 + --> $DIR/drop_forget_ref.rs:54:5 | -58 | forget(&val); +54 | forget(&val); | ^^^^^^^^^^^^ | note: argument has type &T - --> $DIR/drop_forget_ref.rs:58:12 + --> $DIR/drop_forget_ref.rs:54:12 | -58 | forget(&val); +54 | forget(&val); | ^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:66:5 + --> $DIR/drop_forget_ref.rs:62:5 | -66 | std::mem::drop(&SomeStruct); +62 | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:66:20 + --> $DIR/drop_forget_ref.rs:62:20 | -66 | std::mem::drop(&SomeStruct); +62 | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:69:5 + --> $DIR/drop_forget_ref.rs:65:5 | -69 | std::mem::forget(&SomeStruct); +65 | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:69:22 + --> $DIR/drop_forget_ref.rs:65:22 | -69 | std::mem::forget(&SomeStruct); +65 | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^ error: aborting due to 18 previous errors diff --git a/tests/ui/duplicate_underscore_argument.stderr b/tests/ui/duplicate_underscore_argument.stderr index 87b5c5e19d9..ba1b5b1ded7 100644 --- a/tests/ui/duplicate_underscore_argument.stderr +++ b/tests/ui/duplicate_underscore_argument.stderr @@ -1,7 +1,7 @@ error: `darth` already exists, having another argument having almost the same name makes code comprehension and documentation more difficult - --> $DIR/duplicate_underscore_argument.rs:17:23 + --> $DIR/duplicate_underscore_argument.rs:13:23 | -17 | fn join_the_dark_side(darth: i32, _darth: i32) {} +13 | fn join_the_dark_side(darth: i32, _darth: i32) {} | ^^^^^ | = note: `-D clippy::duplicate-underscore-argument` implied by `-D warnings` diff --git a/tests/ui/duration_subsec.stderr b/tests/ui/duration_subsec.stderr index 854af9dcb51..1310ac12340 100644 --- a/tests/ui/duration_subsec.stderr +++ b/tests/ui/duration_subsec.stderr @@ -1,33 +1,33 @@ error: Calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:20:24 + --> $DIR/duration_subsec.rs:17:24 | -20 | let bad_millis_1 = dur.subsec_micros() / 1_000; +17 | let bad_millis_1 = dur.subsec_micros() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` | = note: `-D clippy::duration-subsec` implied by `-D warnings` error: Calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:21:24 + --> $DIR/duration_subsec.rs:18:24 | -21 | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; +18 | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:26:22 + --> $DIR/duration_subsec.rs:23:22 | -26 | let bad_micros = dur.subsec_nanos() / 1_000; +23 | let bad_micros = dur.subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:31:13 + --> $DIR/duration_subsec.rs:28:13 | -31 | let _ = (&dur).subsec_nanos() / 1_000; +28 | let _ = (&dur).subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&dur).subsec_micros()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:35:13 + --> $DIR/duration_subsec.rs:32:13 | -35 | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; +32 | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` error: aborting due to 5 previous errors diff --git a/tests/ui/else_if_without_else.stderr b/tests/ui/else_if_without_else.stderr index 7c8afcf3ce1..8771df87297 100644 --- a/tests/ui/else_if_without_else.stderr +++ b/tests/ui/else_if_without_else.stderr @@ -1,22 +1,24 @@ error: if expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:51:12 + --> $DIR/else_if_without_else.rs:54:12 | -51 | } else if bla2() { //~ ERROR else if without else +54 | } else if bla2() { | ____________^ -52 | | println!("else if"); -53 | | } +55 | | //~ ERROR else if without else +56 | | println!("else if"); +57 | | } | |_____^ | = note: `-D clippy::else-if-without-else` implied by `-D warnings` = help: add an `else` block here error: if expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:59:12 + --> $DIR/else_if_without_else.rs:63:12 | -59 | } else if bla3() { //~ ERROR else if without else +63 | } else if bla3() { | ____________^ -60 | | println!("else if 2"); -61 | | } +64 | | //~ ERROR else if without else +65 | | println!("else if 2"); +66 | | } | |_____^ | = help: add an `else` block here diff --git a/tests/ui/empty_enum.stderr b/tests/ui/empty_enum.stderr index 9d6691c974d..fd981f2210f 100644 --- a/tests/ui/empty_enum.stderr +++ b/tests/ui/empty_enum.stderr @@ -1,14 +1,14 @@ error: enum with no variants - --> $DIR/empty_enum.rs:17:1 + --> $DIR/empty_enum.rs:13:1 | -17 | enum Empty {} +13 | enum Empty {} | ^^^^^^^^^^^^^ | = note: `-D clippy::empty-enum` implied by `-D warnings` help: consider using the uninhabited type `!` or a wrapper around it - --> $DIR/empty_enum.rs:17:1 + --> $DIR/empty_enum.rs:13:1 | -17 | enum Empty {} +13 | enum Empty {} | ^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index 60e5ae893b6..9a4e0ba31ee 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -1,46 +1,74 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:23:5 + --> $DIR/entry.rs:19:5 | -23 | if !m.contains_key(&k) { m.insert(k, v); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k).or_insert(v)` +19 | / if !m.contains_key(&k) { +20 | | m.insert(k, v); +21 | | } + | |_____^ help: consider using: `m.entry(k).or_insert(v)` | = note: `-D clippy::map-entry` implied by `-D warnings` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:27:5 + --> $DIR/entry.rs:25:5 | -27 | if !m.contains_key(&k) { foo(); m.insert(k, v); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +25 | / if !m.contains_key(&k) { +26 | | foo(); +27 | | m.insert(k, v); +28 | | } + | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:31:5 + --> $DIR/entry.rs:32:5 | -31 | if !m.contains_key(&k) { m.insert(k, v) } else { None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +32 | / if !m.contains_key(&k) { +33 | | m.insert(k, v) +34 | | } else { +35 | | None +36 | | }; + | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:35:5 + --> $DIR/entry.rs:40:5 | -35 | if m.contains_key(&k) { None } else { m.insert(k, v) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +40 | / if m.contains_key(&k) { +41 | | None +42 | | } else { +43 | | m.insert(k, v) +44 | | }; + | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:39:5 + --> $DIR/entry.rs:48:5 | -39 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +48 | / if !m.contains_key(&k) { +49 | | foo(); +50 | | m.insert(k, v) +51 | | } else { +52 | | None +53 | | }; + | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:43:5 + --> $DIR/entry.rs:57:5 | -43 | if m.contains_key(&k) { None } else { foo(); m.insert(k, v) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +57 | / if m.contains_key(&k) { +58 | | None +59 | | } else { +60 | | foo(); +61 | | m.insert(k, v) +62 | | }; + | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `BTreeMap` - --> $DIR/entry.rs:47:5 + --> $DIR/entry.rs:66:5 | -47 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +66 | / if !m.contains_key(&k) { +67 | | foo(); +68 | | m.insert(k, v) +69 | | } else { +70 | | None +71 | | }; + | |_____^ help: consider using: `m.entry(k)` error: aborting due to 7 previous errors diff --git a/tests/ui/enum_glob_use.stderr b/tests/ui/enum_glob_use.stderr index 2dac4a2b106..58c6f4d3301 100644 --- a/tests/ui/enum_glob_use.stderr +++ b/tests/ui/enum_glob_use.stderr @@ -1,15 +1,15 @@ error: don't use glob imports for enum variants - --> $DIR/enum_glob_use.rs:16:1 + --> $DIR/enum_glob_use.rs:13:1 | -16 | use std::cmp::Ordering::*; +13 | use std::cmp::Ordering::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::enum-glob-use` implied by `-D warnings` error: don't use glob imports for enum variants - --> $DIR/enum_glob_use.rs:22:1 + --> $DIR/enum_glob_use.rs:19:1 | -22 | use self::Enum::*; +19 | use self::Enum::*; | ^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/enum_variants.stderr b/tests/ui/enum_variants.stderr index 7b63fab3a99..ff8f9b82ae6 100644 --- a/tests/ui/enum_variants.stderr +++ b/tests/ui/enum_variants.stderr @@ -1,61 +1,61 @@ error: Variant name ends with the enum's name - --> $DIR/enum_variants.rs:26:5 + --> $DIR/enum_variants.rs:24:5 | -26 | cFoo, +24 | cFoo, | ^^^^ | = note: `-D clippy::enum-variant-names` implied by `-D warnings` error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:37:5 + --> $DIR/enum_variants.rs:35:5 | -37 | FoodGood, +35 | FoodGood, | ^^^^^^^^ error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:38:5 + --> $DIR/enum_variants.rs:36:5 | -38 | FoodMiddle, +36 | FoodMiddle, | ^^^^^^^^^^ error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:39:5 + --> $DIR/enum_variants.rs:37:5 | -39 | FoodBad, +37 | FoodBad, | ^^^^^^^ error: All variants have the same prefix: `Food` - --> $DIR/enum_variants.rs:36:1 + --> $DIR/enum_variants.rs:34:1 | -36 | / enum Food { -37 | | FoodGood, -38 | | FoodMiddle, -39 | | FoodBad, -40 | | } +34 | / enum Food { +35 | | FoodGood, +36 | | FoodMiddle, +37 | | FoodBad, +38 | | } | |_^ | = 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:46:1 + --> $DIR/enum_variants.rs:44:1 | -46 | / enum BadCallType { -47 | | CallTypeCall, -48 | | CallTypeCreate, -49 | | CallTypeDestroy, -50 | | } +44 | / enum BadCallType { +45 | | CallTypeCall, +46 | | CallTypeCreate, +47 | | CallTypeDestroy, +48 | | } | |_^ | = 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:57:1 + --> $DIR/enum_variants.rs:56:1 | -57 | / enum Consts { -58 | | ConstantInt, -59 | | ConstantCake, -60 | | ConstantLie, -61 | | } +56 | / enum Consts { +57 | | ConstantInt, +58 | | ConstantCake, +59 | | ConstantLie, +60 | | } | |_^ | = help: remove the prefixes and use full paths to the variants instead of glob imports diff --git a/tests/ui/enums_clike.stderr b/tests/ui/enums_clike.stderr index 27b184ea3cc..0756b9a80d4 100644 --- a/tests/ui/enums_clike.stderr +++ b/tests/ui/enums_clike.stderr @@ -1,51 +1,51 @@ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:22:5 + --> $DIR/enums_clike.rs:17:5 | -22 | X = 0x1_0000_0000, +17 | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::enum-clike-unportable-variant` implied by `-D warnings` error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:29:5 + --> $DIR/enums_clike.rs:24:5 | -29 | X = 0x1_0000_0000, +24 | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:32:5 + --> $DIR/enums_clike.rs:27:5 | -32 | A = 0xFFFF_FFFF, +27 | A = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:39:5 + --> $DIR/enums_clike.rs:34:5 | -39 | Z = 0xFFFF_FFFF, +34 | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:40:5 + --> $DIR/enums_clike.rs:35:5 | -40 | A = 0x1_0000_0000, +35 | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:42:5 + --> $DIR/enums_clike.rs:37:5 | -42 | C = (std::i32::MIN as isize) - 1, +37 | C = (std::i32::MIN as isize) - 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:48:5 + --> $DIR/enums_clike.rs:43:5 | -48 | Z = 0xFFFF_FFFF, +43 | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:49:5 + --> $DIR/enums_clike.rs:44:5 | -49 | A = 0x1_0000_0000, +44 | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/erasing_op.stderr b/tests/ui/erasing_op.stderr index 2cc3db7c268..a500a132af7 100644 --- a/tests/ui/erasing_op.stderr +++ b/tests/ui/erasing_op.stderr @@ -1,21 +1,21 @@ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:19:5 + --> $DIR/erasing_op.rs:15:5 | -19 | x * 0; +15 | x * 0; | ^^^^^ | = note: `-D clippy::erasing-op` implied by `-D warnings` error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:20:5 + --> $DIR/erasing_op.rs:16:5 | -20 | 0 & x; +16 | 0 & x; | ^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:21:5 + --> $DIR/erasing_op.rs:17:5 | -21 | 0 / x; +17 | 0 / x; | ^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/escape_analysis.stderr b/tests/ui/escape_analysis.stderr index 25ba413b75a..ec9b7317eed 100644 --- a/tests/ui/escape_analysis.stderr +++ b/tests/ui/escape_analysis.stderr @@ -1,15 +1,15 @@ error: local variable doesn't need to be boxed here - --> $DIR/escape_analysis.rs:45:13 + --> $DIR/escape_analysis.rs:43:13 | -45 | fn warn_arg(x: Box) { +43 | fn warn_arg(x: Box) { | ^ | = note: `-D clippy::boxed-local` implied by `-D warnings` error: local variable doesn't need to be boxed here - --> $DIR/escape_analysis.rs:137:12 + --> $DIR/escape_analysis.rs:134:12 | -137 | pub fn new(_needs_name: Box>) -> () { +134 | pub fn new(_needs_name: Box>) -> () {} | ^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index dcdf0699ff7..cd14855c49d 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -1,35 +1,35 @@ error: redundant closure found - --> $DIR/eta.rs:17:27 + --> $DIR/eta.rs:22:27 | -17 | let a = Some(1u8).map(|a| foo(a)); +22 | let a = Some(1u8).map(|a| foo(a)); | ^^^^^^^^^^ help: remove closure as shown: `foo` | = note: `-D clippy::redundant-closure` implied by `-D warnings` error: redundant closure found - --> $DIR/eta.rs:18:10 + --> $DIR/eta.rs:23:10 | -18 | meta(|a| foo(a)); +23 | meta(|a| foo(a)); | ^^^^^^^^^^ help: remove closure as shown: `foo` error: redundant closure found - --> $DIR/eta.rs:19:27 + --> $DIR/eta.rs:24:27 | -19 | let c = Some(1u8).map(|a| {1+2; foo}(a)); +24 | let c = Some(1u8).map(|a| {1+2; foo}(a)); | ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}` error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/eta.rs:21:21 + --> $DIR/eta.rs:26:21 | -21 | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted +26 | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted | ^^^ help: change this to: `&2` | = note: `-D clippy::needless-borrow` implied by `-D warnings` error: redundant closure found - --> $DIR/eta.rs:28:27 + --> $DIR/eta.rs:33:27 | -28 | let e = Some(1u8).map(|a| generic(a)); +33 | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: remove closure as shown: `generic` error: aborting due to 5 previous errors diff --git a/tests/ui/eval_order_dependence.stderr b/tests/ui/eval_order_dependence.stderr index d5be92e993f..38317376fc4 100644 --- a/tests/ui/eval_order_dependence.stderr +++ b/tests/ui/eval_order_dependence.stderr @@ -1,51 +1,51 @@ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:18:28 + --> $DIR/eval_order_dependence.rs:24:9 | -18 | let a = { x = 1; 1 } + x; - | ^ +24 | } + x; + | ^ | = note: `-D clippy::eval-order-dependence` implied by `-D warnings` note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:18:15 + --> $DIR/eval_order_dependence.rs:22:9 | -18 | let a = { x = 1; 1 } + x; - | ^^^^^ +22 | x = 1; + | ^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:21:5 + --> $DIR/eval_order_dependence.rs:27:5 | -21 | x += { x = 20; 2 }; +27 | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:21:12 + --> $DIR/eval_order_dependence.rs:28:9 | -21 | x += { x = 20; 2 }; - | ^^^^^^ +28 | x = 20; + | ^^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:27:24 + --> $DIR/eval_order_dependence.rs:40:12 | -27 | let foo = Foo { a: x, .. { x = 6; base } }; - | ^ +40 | a: x, + | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:27:32 + --> $DIR/eval_order_dependence.rs:42:13 | -27 | let foo = Foo { a: x, .. { x = 6; base } }; - | ^^^^^ +42 | x = 6; + | ^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:31:9 + --> $DIR/eval_order_dependence.rs:49:9 | -31 | x += { x = 20; 2 }; +49 | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:31:16 + --> $DIR/eval_order_dependence.rs:50:13 | -31 | x += { x = 20; 2 }; - | ^^^^^^ +50 | x = 20; + | ^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/excessive_precision.stderr b/tests/ui/excessive_precision.stderr index 783e41f2b50..a69652373d5 100644 --- a/tests/ui/excessive_precision.stderr +++ b/tests/ui/excessive_precision.stderr @@ -1,111 +1,111 @@ error: float has excessive precision - --> $DIR/excessive_precision.rs:25:26 + --> $DIR/excessive_precision.rs:23:26 | -25 | const BAD32_1: f32 = 0.123_456_789_f32; +23 | const BAD32_1: f32 = 0.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` | = note: `-D clippy::excessive-precision` implied by `-D warnings` error: float has excessive precision - --> $DIR/excessive_precision.rs:26:26 + --> $DIR/excessive_precision.rs:24:26 | -26 | const BAD32_2: f32 = 0.123_456_789; +24 | const BAD32_2: f32 = 0.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` error: float has excessive precision - --> $DIR/excessive_precision.rs:27:26 + --> $DIR/excessive_precision.rs:25:26 | -27 | const BAD32_3: f32 = 0.100_000_000_000_1; +25 | const BAD32_3: f32 = 0.100_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` error: float has excessive precision - --> $DIR/excessive_precision.rs:28:29 + --> $DIR/excessive_precision.rs:26:29 | -28 | const BAD32_EDGE: f32 = 1.000_000_9; +26 | const BAD32_EDGE: f32 = 1.000_000_9; | ^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.000_001` +error: float has excessive precision + --> $DIR/excessive_precision.rs:28:26 + | +28 | const BAD64_1: f64 = 0.123_456_789_012_345_67f64; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` + +error: float has excessive precision + --> $DIR/excessive_precision.rs:29:26 + | +29 | const BAD64_2: f64 = 0.123_456_789_012_345_67; + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` + error: float has excessive precision --> $DIR/excessive_precision.rs:30:26 | -30 | const BAD64_1: f64 = 0.123_456_789_012_345_67f64; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` - -error: float has excessive precision - --> $DIR/excessive_precision.rs:31:26 - | -31 | const BAD64_2: f64 = 0.123_456_789_012_345_67; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` - -error: float has excessive precision - --> $DIR/excessive_precision.rs:32:26 - | -32 | const BAD64_3: f64 = 0.100_000_000_000_000_000_1; +30 | const BAD64_3: f64 = 0.100_000_000_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` error: float has excessive precision - --> $DIR/excessive_precision.rs:35:22 + --> $DIR/excessive_precision.rs:33:22 | -35 | println!("{:?}", 8.888_888_888_888_888_888_888); +33 | println!("{:?}", 8.888_888_888_888_888_888_888); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `8.888_888_888_888_89` error: float has excessive precision - --> $DIR/excessive_precision.rs:46:22 + --> $DIR/excessive_precision.rs:44:22 | -46 | let bad32: f32 = 1.123_456_789; +44 | let bad32: f32 = 1.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:47:26 + --> $DIR/excessive_precision.rs:45:26 | -47 | let bad32_suf: f32 = 1.123_456_789_f32; +45 | let bad32_suf: f32 = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:48:21 + --> $DIR/excessive_precision.rs:46:21 | -48 | let bad32_inf = 1.123_456_789_f32; +46 | let bad32_inf = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:50:22 + --> $DIR/excessive_precision.rs:48:22 | -50 | let bad64: f64 = 0.123_456_789_012_345_67; +48 | let bad64: f64 = 0.123_456_789_012_345_67; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:51:26 + --> $DIR/excessive_precision.rs:49:26 | -51 | let bad64_suf: f64 = 0.123_456_789_012_345_67f64; +49 | let bad64_suf: f64 = 0.123_456_789_012_345_67f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:52:21 + --> $DIR/excessive_precision.rs:50:21 | -52 | let bad64_inf = 0.123_456_789_012_345_67; +50 | let bad64_inf = 0.123_456_789_012_345_67; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:58:36 + --> $DIR/excessive_precision.rs:56:36 | -58 | let bad_vec32: Vec = vec![0.123_456_789]; +56 | let bad_vec32: Vec = vec![0.123_456_789]; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` error: float has excessive precision - --> $DIR/excessive_precision.rs:59:36 + --> $DIR/excessive_precision.rs:57:36 | -59 | let bad_vec64: Vec = vec![0.123_456_789_123_456_789]; +57 | let bad_vec64: Vec = vec![0.123_456_789_123_456_789]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_123_456_78` error: float has excessive precision - --> $DIR/excessive_precision.rs:63:24 + --> $DIR/excessive_precision.rs:61:24 | -63 | let bad_e32: f32 = 1.123_456_788_888e-10; +61 | let bad_e32: f32 = 1.123_456_788_888e-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8e-10` error: float has excessive precision - --> $DIR/excessive_precision.rs:66:27 + --> $DIR/excessive_precision.rs:64:27 | -66 | let bad_bige32: f32 = 1.123_456_788_888E-10; +64 | let bad_bige32: f32 = 1.123_456_788_888E-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8E-10` error: aborting due to 18 previous errors diff --git a/tests/ui/expect_fun_call.stderr b/tests/ui/expect_fun_call.stderr index 6b1550b2195..ad8fe14e9a0 100644 --- a/tests/ui/expect_fun_call.stderr +++ b/tests/ui/expect_fun_call.stderr @@ -1,39 +1,39 @@ error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:34:26 + --> $DIR/expect_fun_call.rs:36:26 | -34 | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); +36 | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` | = note: `-D clippy::expect-fun-call` implied by `-D warnings` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:37:26 + --> $DIR/expect_fun_call.rs:39:26 | -37 | with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); +39 | with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:47:25 + --> $DIR/expect_fun_call.rs:49:25 | -47 | with_err_and_format.expect(&format!("Error {}: fake error", error_code)); +49 | with_err_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:50:25 + --> $DIR/expect_fun_call.rs:52:25 | -50 | with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); +52 | with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:65:17 + --> $DIR/expect_fun_call.rs:67:17 | -65 | Some("foo").expect({ &format!("error") }); +67 | Some("foo").expect({ &format!("error") }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { let msg = { &format!("error") }; panic!(msg) }))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:66:17 + --> $DIR/expect_fun_call.rs:68:17 | -66 | Some("foo").expect(format!("error").as_ref()); +68 | Some("foo").expect(format!("error").as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("error"))` error: aborting due to 6 previous errors diff --git a/tests/ui/explicit_counter_loop.stderr b/tests/ui/explicit_counter_loop.stderr index 023f7f299a7..caafd2375f0 100644 --- a/tests/ui/explicit_counter_loop.stderr +++ b/tests/ui/explicit_counter_loop.stderr @@ -13,15 +13,15 @@ error: the variable `_index` is used as a loop counter. Consider using `for (_in | ^^^^ error: the variable `count` is used as a loop counter. Consider using `for (count, item) in text.chars().enumerate()` or similar iterators - --> $DIR/explicit_counter_loop.rs:58:19 + --> $DIR/explicit_counter_loop.rs:60:19 | -58 | for ch in text.chars() { +60 | for ch in text.chars() { | ^^^^^^^^^^^^ error: the variable `count` is used as a loop counter. Consider using `for (count, item) in text.chars().enumerate()` or similar iterators - --> $DIR/explicit_counter_loop.rs:69:19 + --> $DIR/explicit_counter_loop.rs:71:19 | -69 | for ch in text.chars() { +71 | for ch in text.chars() { | ^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/explicit_write.stderr b/tests/ui/explicit_write.stderr index fadc12c7594..171bf312a9b 100644 --- a/tests/ui/explicit_write.stderr +++ b/tests/ui/explicit_write.stderr @@ -1,39 +1,39 @@ error: use of `write!(stdout(), ...).unwrap()`. Consider using `print!` instead - --> $DIR/explicit_write.rs:28:9 + --> $DIR/explicit_write.rs:24:9 | -28 | write!(std::io::stdout(), "test").unwrap(); +24 | write!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::explicit-write` implied by `-D warnings` error: use of `write!(stderr(), ...).unwrap()`. Consider using `eprint!` instead - --> $DIR/explicit_write.rs:29:9 + --> $DIR/explicit_write.rs:25:9 | -29 | write!(std::io::stderr(), "test").unwrap(); +25 | write!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `writeln!(stdout(), ...).unwrap()`. Consider using `println!` instead - --> $DIR/explicit_write.rs:30:9 + --> $DIR/explicit_write.rs:26:9 | -30 | writeln!(std::io::stdout(), "test").unwrap(); +26 | writeln!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `writeln!(stderr(), ...).unwrap()`. Consider using `eprintln!` instead - --> $DIR/explicit_write.rs:31:9 + --> $DIR/explicit_write.rs:27:9 | -31 | writeln!(std::io::stderr(), "test").unwrap(); +27 | writeln!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `stdout().write_fmt(...).unwrap()`. Consider using `print!` instead - --> $DIR/explicit_write.rs:32:9 + --> $DIR/explicit_write.rs:28:9 | -32 | std::io::stdout().write_fmt(format_args!("test")).unwrap(); +28 | std::io::stdout().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `stderr().write_fmt(...).unwrap()`. Consider using `eprint!` instead - --> $DIR/explicit_write.rs:33:9 + --> $DIR/explicit_write.rs:29:9 | -33 | std::io::stderr().write_fmt(format_args!("test")).unwrap(); +29 | std::io::stderr().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/fallible_impl_from.stderr b/tests/ui/fallible_impl_from.stderr index 97ece931464..8af5933a9f8 100644 --- a/tests/ui/fallible_impl_from.stderr +++ b/tests/ui/fallible_impl_from.stderr @@ -1,91 +1,91 @@ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:17:1 + --> $DIR/fallible_impl_from.rs:14:1 | -17 | / impl From for Foo { -18 | | fn from(s: String) -> Self { -19 | | Foo(s.parse().unwrap()) -20 | | } -21 | | } +14 | / impl From for Foo { +15 | | fn from(s: String) -> Self { +16 | | Foo(s.parse().unwrap()) +17 | | } +18 | | } | |_^ | note: lint level defined here - --> $DIR/fallible_impl_from.rs:13:9 + --> $DIR/fallible_impl_from.rs:10:9 | -13 | #![deny(clippy::fallible_impl_from)] +10 | #![deny(clippy::fallible_impl_from)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:19:13 + --> $DIR/fallible_impl_from.rs:16:13 | -19 | Foo(s.parse().unwrap()) +16 | Foo(s.parse().unwrap()) | ^^^^^^^^^^^^^^^^^^ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:40:1 + --> $DIR/fallible_impl_from.rs:35:1 | -40 | / impl From for Invalid { -41 | | fn from(i: usize) -> Invalid { -42 | | if i != 42 { -43 | | panic!(); +35 | / impl From for Invalid { +36 | | fn from(i: usize) -> Invalid { +37 | | if i != 42 { +38 | | panic!(); ... | -46 | | } -47 | | } +41 | | } +42 | | } | |_^ | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:43:13 + --> $DIR/fallible_impl_from.rs:38:13 | -43 | panic!(); +38 | panic!(); | ^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:49:1 + --> $DIR/fallible_impl_from.rs:44:1 | -49 | / impl From> for Invalid { -50 | | fn from(s: Option) -> Invalid { -51 | | let s = s.unwrap(); -52 | | if !s.is_empty() { +44 | / impl From> for Invalid { +45 | | fn from(s: Option) -> Invalid { +46 | | let s = s.unwrap(); +47 | | if !s.is_empty() { ... | -58 | | } -59 | | } +53 | | } +54 | | } | |_^ | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:51:17 + --> $DIR/fallible_impl_from.rs:46:17 | -51 | let s = s.unwrap(); +46 | let s = s.unwrap(); | ^^^^^^^^^^ -52 | if !s.is_empty() { -53 | panic!(42); +47 | if !s.is_empty() { +48 | panic!(42); | ^^^^^^^^^^^ -54 | } else if s.parse::().unwrap() != 42 { +49 | } else if s.parse::().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -55 | panic!("{:?}", s); +50 | panic!("{:?}", s); | ^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:67:1 + --> $DIR/fallible_impl_from.rs:62:1 | -67 | / impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { -68 | | fn from(s: &'a mut as ProjStrTrait>::ProjString) -> Invalid { -69 | | if s.parse::().ok().unwrap() != 42 { -70 | | panic!("{:?}", s); +62 | / impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { +63 | | fn from(s: &'a mut as ProjStrTrait>::ProjString) -> Invalid { +64 | | if s.parse::().ok().unwrap() != 42 { +65 | | panic!("{:?}", s); ... | -73 | | } -74 | | } +68 | | } +69 | | } | |_^ | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:69:12 + --> $DIR/fallible_impl_from.rs:64:12 | -69 | if s.parse::().ok().unwrap() != 42 { +64 | if s.parse::().ok().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -70 | panic!("{:?}", s); +65 | panic!("{:?}", s); | ^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) diff --git a/tests/ui/filter_methods.stderr b/tests/ui/filter_methods.stderr index 6adbec44cf9..8fde78ca5a7 100644 --- a/tests/ui/filter_methods.stderr +++ b/tests/ui/filter_methods.stderr @@ -1,40 +1,40 @@ error: called `filter(p).map(q)` on an `Iterator`. This is more succinctly expressed by calling `.filter_map(..)` instead. - --> $DIR/filter_methods.rs:18:21 + --> $DIR/filter_methods.rs:14:21 | -18 | let _: Vec<_> = vec![5; 6].into_iter() - | _____________________^ -19 | | .filter(|&x| x == 0) -20 | | .map(|x| x * 2) - | |_____________________________________________^ +14 | let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * 2).collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::filter-map` implied by `-D warnings` error: called `filter(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator. - --> $DIR/filter_methods.rs:23:21 + --> $DIR/filter_methods.rs:16:21 | -23 | let _: Vec<_> = vec![5_i8; 6].into_iter() +16 | let _: Vec<_> = vec![5_i8; 6] | _____________________^ -24 | | .filter(|&x| x == 0) -25 | | .flat_map(|x| x.checked_mul(2)) - | |_______________________________________________________________^ +17 | | .into_iter() +18 | | .filter(|&x| x == 0) +19 | | .flat_map(|x| x.checked_mul(2)) + | |_______________________________________^ error: called `filter_map(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator. - --> $DIR/filter_methods.rs:28:21 + --> $DIR/filter_methods.rs:22:21 | -28 | let _: Vec<_> = vec![5_i8; 6].into_iter() +22 | let _: Vec<_> = vec![5_i8; 6] | _____________________^ -29 | | .filter_map(|x| x.checked_mul(2)) -30 | | .flat_map(|x| x.checked_mul(2)) - | |_______________________________________________________________^ +23 | | .into_iter() +24 | | .filter_map(|x| x.checked_mul(2)) +25 | | .flat_map(|x| x.checked_mul(2)) + | |_______________________________________^ error: called `filter_map(p).map(q)` on an `Iterator`. This is more succinctly expressed by only calling `.filter_map(..)` instead. - --> $DIR/filter_methods.rs:33:21 + --> $DIR/filter_methods.rs:28:21 | -33 | let _: Vec<_> = vec![5_i8; 6].into_iter() +28 | let _: Vec<_> = vec![5_i8; 6] | _____________________^ -34 | | .filter_map(|x| x.checked_mul(2)) -35 | | .map(|x| x.checked_mul(2)) - | |__________________________________________________________^ +29 | | .into_iter() +30 | | .filter_map(|x| x.checked_mul(2)) +31 | | .map(|x| x.checked_mul(2)) + | |__________________________________^ error: aborting due to 4 previous errors diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index 52ec0e3ed78..3acd71eb99b 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -1,38 +1,38 @@ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:59:5 + --> $DIR/float_cmp.rs:69:5 | -59 | ONE as f64 != 2.0; +69 | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(ONE as f64 - 2.0).abs() < error` | = note: `-D clippy::float-cmp` implied by `-D warnings` note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:59:5 + --> $DIR/float_cmp.rs:69:5 | -59 | ONE as f64 != 2.0; +69 | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:64:5 + --> $DIR/float_cmp.rs:74:5 | -64 | x == 1.0; +74 | x == 1.0; | ^^^^^^^^ help: consider comparing them within some error: `(x - 1.0).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:64:5 + --> $DIR/float_cmp.rs:74:5 | -64 | x == 1.0; +74 | x == 1.0; | ^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:67:5 + --> $DIR/float_cmp.rs:77:5 | -67 | twice(x) != twice(ONE as f64); +77 | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(twice(x) - twice(ONE as f64)).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:67:5 + --> $DIR/float_cmp.rs:77:5 | -67 | twice(x) != twice(ONE as f64); +77 | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index f70a6d3b32f..640cee1bc2f 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -1,420 +1,420 @@ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:38:14 + --> $DIR/for_loop.rs:50:14 | -38 | for i in 0..vec.len() { +50 | for i in 0..vec.len() { | ^^^^^^^^^^^^ | = note: `-D clippy::needless-range-loop` implied by `-D warnings` help: consider using an iterator | -38 | for in &vec { +50 | for in &vec { | ^^^^^^ ^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:47:14 + --> $DIR/for_loop.rs:59:14 | -47 | for i in 0..vec.len() { +59 | for i in 0..vec.len() { | ^^^^^^^^^^^^ help: consider using an iterator | -47 | for in &vec { +59 | for in &vec { | ^^^^^^ ^^^^ error: the loop variable `j` is only used to index `STATIC`. - --> $DIR/for_loop.rs:52:14 + --> $DIR/for_loop.rs:64:14 | -52 | for j in 0..4 { +64 | for j in 0..4 { | ^^^^ help: consider using an iterator | -52 | for in &STATIC { +64 | for in &STATIC { | ^^^^^^ ^^^^^^^ error: the loop variable `j` is only used to index `CONST`. - --> $DIR/for_loop.rs:56:14 + --> $DIR/for_loop.rs:68:14 | -56 | for j in 0..4 { +68 | for j in 0..4 { | ^^^^ help: consider using an iterator | -56 | for in &CONST { +68 | for in &CONST { | ^^^^^^ ^^^^^^ error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:60:14 + --> $DIR/for_loop.rs:72:14 | -60 | for i in 0..vec.len() { +72 | for i in 0..vec.len() { | ^^^^^^^^^^^^ help: consider using an iterator | -60 | for (i, ) in vec.iter().enumerate() { +72 | for (i, ) in vec.iter().enumerate() { | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec2`. - --> $DIR/for_loop.rs:68:14 - | -68 | for i in 0..vec.len() { - | ^^^^^^^^^^^^ -help: consider using an iterator - | -68 | for in vec2.iter().take(vec.len()) { - | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:72:14 - | -72 | for i in 5..vec.len() { - | ^^^^^^^^^^^^ -help: consider using an iterator - | -72 | for in vec.iter().skip(5) { - | ^^^^^^ ^^^^^^^^^^^^^^^^^^ - -error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:76:14 - | -76 | for i in 0..MAX_LEN { - | ^^^^^^^^^^ -help: consider using an iterator - | -76 | for in vec.iter().take(MAX_LEN) { - | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:80:14 | -80 | for i in 0..=MAX_LEN { - | ^^^^^^^^^^^ +80 | for i in 0..vec.len() { + | ^^^^^^^^^^^^ help: consider using an iterator | -80 | for in vec.iter().take(MAX_LEN + 1) { - | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +80 | for in vec2.iter().take(vec.len()) { + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:84:14 | -84 | for i in 5..10 { - | ^^^^^ +84 | for i in 5..vec.len() { + | ^^^^^^^^^^^^ help: consider using an iterator | -84 | for in vec.iter().take(10).skip(5) { - | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +84 | for in vec.iter().skip(5) { + | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:88:14 | -88 | for i in 5..=10 { - | ^^^^^^ +88 | for i in 0..MAX_LEN { + | ^^^^^^^^^^ help: consider using an iterator | -88 | for in vec.iter().take(10 + 1).skip(5) { - | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +88 | for in vec.iter().take(MAX_LEN) { + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ -error: the loop variable `i` is used to index `vec` +error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:92:14 | -92 | for i in 5..vec.len() { - | ^^^^^^^^^^^^ +92 | for i in 0..=MAX_LEN { + | ^^^^^^^^^^^ help: consider using an iterator | -92 | for (i, ) in vec.iter().enumerate().skip(5) { - | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +92 | for in vec.iter().take(MAX_LEN + 1) { + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the loop variable `i` is used to index `vec` +error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:96:14 | 96 | for i in 5..10 { | ^^^^^ help: consider using an iterator | -96 | for (i, ) in vec.iter().enumerate().take(10).skip(5) { - | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +96 | for in vec.iter().take(10).skip(5) { + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this range is empty so this for loop will never run +error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:100:14 | -100 | for i in 10..0 { +100 | for i in 5..=10 { + | ^^^^^^ +help: consider using an iterator + | +100 | for in vec.iter().take(10 + 1).skip(5) { + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the loop variable `i` is used to index `vec` + --> $DIR/for_loop.rs:104:14 + | +104 | for i in 5..vec.len() { + | ^^^^^^^^^^^^ +help: consider using an iterator + | +104 | for (i, ) in vec.iter().enumerate().skip(5) { + | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the loop variable `i` is used to index `vec` + --> $DIR/for_loop.rs:108:14 + | +108 | for i in 5..10 { + | ^^^^^ +help: consider using an iterator + | +108 | for (i, ) in vec.iter().enumerate().take(10).skip(5) { + | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this range is empty so this for loop will never run + --> $DIR/for_loop.rs:112:14 + | +112 | for i in 10..0 { | ^^^^^ | = note: `-D clippy::reverse-range-loop` implied by `-D warnings` help: consider using the following if you are attempting to iterate over this range in reverse | -100 | for i in (0..10).rev() { +112 | for i in (0..10).rev() { | ^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:104:14 + --> $DIR/for_loop.rs:116:14 | -104 | for i in 10..=0 { +116 | for i in 10..=0 { | ^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | -104 | for i in (0...10).rev() { +116 | for i in (0...10).rev() { | ^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:108:14 + --> $DIR/for_loop.rs:120:14 | -108 | for i in MAX_LEN..0 { +120 | for i in MAX_LEN..0 { | ^^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | -108 | for i in (0..MAX_LEN).rev() { +120 | for i in (0..MAX_LEN).rev() { | ^^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:112:14 + --> $DIR/for_loop.rs:124:14 | -112 | for i in 5..5 { +124 | for i in 5..5 { | ^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:137:14 + --> $DIR/for_loop.rs:149:14 | -137 | for i in 10..5 + 4 { +149 | for i in 10..5 + 4 { | ^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | -137 | for i in (5 + 4..10).rev() { +149 | for i in (5 + 4..10).rev() { | ^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:141:14 + --> $DIR/for_loop.rs:153:14 | -141 | for i in (5 + 2)..(3 - 1) { +153 | for i in (5 + 2)..(3 - 1) { | ^^^^^^^^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | -141 | for i in ((3 - 1)..(5 + 2)).rev() { +153 | for i in ((3 - 1)..(5 + 2)).rev() { | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:145:14 + --> $DIR/for_loop.rs:157:14 | -145 | for i in (5 + 2)..(8 - 1) { +157 | for i in (5 + 2)..(8 - 1) { | ^^^^^^^^^^^^^^^^ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:167:15 + --> $DIR/for_loop.rs:179:15 | -167 | for _v in vec.iter() {} +179 | for _v in vec.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `&vec` | = note: `-D clippy::explicit-iter-loop` implied by `-D warnings` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:169:15 + --> $DIR/for_loop.rs:181:15 | -169 | for _v in vec.iter_mut() {} +181 | for _v in vec.iter_mut() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec` error: it is more concise to loop over containers instead of using explicit iteration methods` - --> $DIR/for_loop.rs:172:15 + --> $DIR/for_loop.rs:184:15 | -172 | for _v in out_vec.into_iter() {} +184 | for _v in out_vec.into_iter() {} | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec` | = note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:175:15 + --> $DIR/for_loop.rs:187:15 | -175 | for _v in array.into_iter() {} +187 | for _v in array.into_iter() {} | ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&array` -error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:180:15 - | -180 | for _v in [1, 2, 3].iter() {} - | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]` - -error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:184:15 - | -184 | for _v in [0; 32].iter() {} - | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]` - -error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:189:15 - | -189 | for _v in ll.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&ll` - error: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:192:15 | -192 | for _v in vd.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&vd` +192 | for _v in [1, 2, 3].iter() {} + | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:195:15 + --> $DIR/for_loop.rs:196:15 | -195 | for _v in bh.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&bh` - -error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:198:15 - | -198 | for _v in hm.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&hm` +196 | for _v in [0; 32].iter() {} + | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]` error: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:201:15 | -201 | for _v in bt.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&bt` +201 | for _v in ll.iter() {} + | ^^^^^^^^^ help: to write this more concisely, try: `&ll` error: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:204:15 | -204 | for _v in hs.iter() {} - | ^^^^^^^^^ help: to write this more concisely, try: `&hs` +204 | for _v in vd.iter() {} + | ^^^^^^^^^ help: to write this more concisely, try: `&vd` error: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:207:15 | -207 | for _v in bs.iter() {} +207 | for _v in bh.iter() {} + | ^^^^^^^^^ help: to write this more concisely, try: `&bh` + +error: it is more concise to loop over references to containers instead of using explicit iteration methods + --> $DIR/for_loop.rs:210:15 + | +210 | for _v in hm.iter() {} + | ^^^^^^^^^ help: to write this more concisely, try: `&hm` + +error: it is more concise to loop over references to containers instead of using explicit iteration methods + --> $DIR/for_loop.rs:213:15 + | +213 | for _v in bt.iter() {} + | ^^^^^^^^^ help: to write this more concisely, try: `&bt` + +error: it is more concise to loop over references to containers instead of using explicit iteration methods + --> $DIR/for_loop.rs:216:15 + | +216 | for _v in hs.iter() {} + | ^^^^^^^^^ help: to write this more concisely, try: `&hs` + +error: it is more concise to loop over references to containers instead of using explicit iteration methods + --> $DIR/for_loop.rs:219:15 + | +219 | for _v in bs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bs` error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want - --> $DIR/for_loop.rs:209:15 + --> $DIR/for_loop.rs:221:15 | -209 | for _v in vec.iter().next() {} +221 | for _v in vec.iter().next() {} | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::iter-next-loop` implied by `-D warnings` error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator - --> $DIR/for_loop.rs:216:5 + --> $DIR/for_loop.rs:228:5 | -216 | vec.iter().cloned().map(|x| out.push(x)).collect::>(); +228 | vec.iter().cloned().map(|x| out.push(x)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unused-collect` implied by `-D warnings` error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:325:19 + --> $DIR/for_loop.rs:337:19 | -325 | for (_, v) in &m { +337 | for (_, v) in &m { | ^^ | = note: `-D clippy::for-kv-map` implied by `-D warnings` help: use the corresponding method | -325 | for v in m.values() { +337 | for v in m.values() { | ^ ^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:330:19 + --> $DIR/for_loop.rs:342:19 | -330 | for (_, v) in &*m { +342 | for (_, v) in &*m { | ^^^ help: use the corresponding method | -330 | for v in (*m).values() { +342 | for v in (*m).values() { | ^ ^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:338:19 + --> $DIR/for_loop.rs:350:19 | -338 | for (_, v) in &mut m { +350 | for (_, v) in &mut m { | ^^^^^^ help: use the corresponding method | -338 | for v in m.values_mut() { +350 | for v in m.values_mut() { | ^ ^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:343:19 + --> $DIR/for_loop.rs:355:19 | -343 | for (_, v) in &mut *m { +355 | for (_, v) in &mut *m { | ^^^^^^^ help: use the corresponding method | -343 | for v in (*m).values_mut() { +355 | for v in (*m).values_mut() { | ^ ^^^^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's keys - --> $DIR/for_loop.rs:349:24 + --> $DIR/for_loop.rs:361:24 | -349 | for (k, _value) in rm { +361 | for (k, _value) in rm { | ^^ help: use the corresponding method | -349 | for k in rm.keys() { +361 | for k in rm.keys() { | ^ ^^^^^^^^^ error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:402:14 + --> $DIR/for_loop.rs:414:14 | -402 | for i in 0..src.len() { +414 | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` | = note: `-D clippy::manual-memcpy` implied by `-D warnings` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:407:14 + --> $DIR/for_loop.rs:419:14 | -407 | for i in 0..src.len() { +419 | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[10..(src.len() + 10)].clone_from_slice(&src[..])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:412:14 + --> $DIR/for_loop.rs:424:14 | -412 | for i in 0..src.len() { +424 | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[10..])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:417:14 + --> $DIR/for_loop.rs:429:14 | -417 | for i in 11..src.len() { +429 | for i in 11..src.len() { | ^^^^^^^^^^^^^ help: try replacing the loop by: `dst[11..src.len()].clone_from_slice(&src[(11 - 10)..(src.len() - 10)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:422:14 + --> $DIR/for_loop.rs:434:14 | -422 | for i in 0..dst.len() { +434 | for i in 0..dst.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst.clone_from_slice(&src[..dst.len()])` -error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:435:14 - | -435 | for i in 10..256 { - | ^^^^^^^ -help: try replacing the loop by - | -435 | for i in dst[10..256].clone_from_slice(&src[(10 - 5)..(256 - 5)]) -436 | dst2[(10 + 500)..(256 + 500)].clone_from_slice(&src[10..256]) { - | - error: it looks like you're manually copying between slices --> $DIR/for_loop.rs:447:14 | -447 | for i in 10..LOOP_OFFSET { +447 | for i in 10..256 { + | ^^^^^^^ +help: try replacing the loop by + | +447 | for i in dst[10..256].clone_from_slice(&src[(10 - 5)..(256 - 5)]) +448 | dst2[(10 + 500)..(256 + 500)].clone_from_slice(&src[10..256]) { + | + +error: it looks like you're manually copying between slices + --> $DIR/for_loop.rs:459:14 + | +459 | for i in 10..LOOP_OFFSET { | ^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[(10 + LOOP_OFFSET)..(LOOP_OFFSET + LOOP_OFFSET)].clone_from_slice(&src[(10 - some_var)..(LOOP_OFFSET - some_var)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:460:14 + --> $DIR/for_loop.rs:472:14 | -460 | for i in 0..src_vec.len() { +472 | for i in 0..src_vec.len() { | ^^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst_vec[..src_vec.len()].clone_from_slice(&src_vec[..])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:489:14 + --> $DIR/for_loop.rs:501:14 | -489 | for i in from..from + src.len() { +501 | for i in from..from + src.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[from..from + src.len()].clone_from_slice(&src[0..(from + src.len() - from)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:493:14 + --> $DIR/for_loop.rs:505:14 | -493 | for i in from..from + 3 { +505 | for i in from..from + 3 { | ^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[from..from + 3].clone_from_slice(&src[0..(from + 3 - from)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:500:14 + --> $DIR/for_loop.rs:512:14 | -500 | for i in 0..src.len() { +512 | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` error: aborting due to 51 previous errors diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index e1620b22125..84749b6caac 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -1,90 +1,19 @@ -error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:25:6 - | -25 | } if foo() { - | ^ - | - = note: `-D clippy::suspicious-else-formatting` implied by `-D warnings` - = note: to remove this lint, add the missing `else` or add a new line before the second `if` - -error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:32:10 - | -32 | } if foo() { - | ^ - | - = note: to remove this lint, add the missing `else` or add a new line before the second `if` - -error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:40:10 - | -40 | } if foo() { - | ^ - | - = note: to remove this lint, add the missing `else` or add a new line before the second `if` - -error: this is an `else if` but the formatting might hide it - --> $DIR/formatting.rs:49:6 - | -49 | } else - | ______^ -50 | | if foo() { // the span of the above error should continue here - | |____^ - | - = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` - -error: this is an `else if` but the formatting might hide it - --> $DIR/formatting.rs:54:6 - | -54 | } - | ______^ -55 | | else -56 | | if foo() { // the span of the above error should continue here - | |____^ - | - = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` - -error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` - --> $DIR/formatting.rs:81:6 - | -81 | a =- 35; - | ^^^^ - | - = note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings` - = note: to remove this lint, use either `-=` or `= -` - -error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` - --> $DIR/formatting.rs:82:6 - | -82 | a =* &191; - | ^^^^ - | - = note: to remove this lint, use either `*=` or `= *` - -error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` - --> $DIR/formatting.rs:85:6 - | -85 | b =! false; - | ^^^^ - | - = note: to remove this lint, use either `!=` or `= !` - error: possibly missing a comma here - --> $DIR/formatting.rs:94:19 + --> $DIR/formatting.rs:88:11 | -94 | -1, -2, -3 // <= no comma here - | ^ +88 | -3 // <= no comma here + | ^ | = note: `-D clippy::possible-missing-comma` implied by `-D warnings` = note: to remove this lint, add a comma or write the expr in a single line error: possibly missing a comma here - --> $DIR/formatting.rs:98:19 + --> $DIR/formatting.rs:96:11 | -98 | -1, -2, -3 // <= no comma here - | ^ +96 | -3 // <= no comma here + | ^ | = note: to remove this lint, add a comma or write the expr in a single line -error: aborting due to 10 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index 9c45eb033ea..206d04d6a39 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -1,78 +1,77 @@ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:21:1 + --> $DIR/functions.rs:17:1 | -21 | / fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) { -22 | | } - | |_^ +17 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::too-many-arguments` implied by `-D warnings` error: this function has too many arguments (8/7) - --> $DIR/functions.rs:29:5 + --> $DIR/functions.rs:34:5 | -29 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); +34 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:38:5 + --> $DIR/functions.rs:43:5 | -38 | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} +43 | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:47:34 + --> $DIR/functions.rs:52:34 | -47 | println!("{}", unsafe { *p }); +52 | println!("{}", unsafe { *p }); | ^ | = note: `-D clippy::not-unsafe-ptr-arg-deref` implied by `-D warnings` error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:48:35 + --> $DIR/functions.rs:53:35 | -48 | println!("{:?}", unsafe { p.as_ref() }); +53 | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:49:33 + --> $DIR/functions.rs:54:33 | -49 | unsafe { std::ptr::read(p) }; +54 | unsafe { std::ptr::read(p) }; | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:60:30 + --> $DIR/functions.rs:65:30 | -60 | println!("{}", unsafe { *p }); +65 | println!("{}", unsafe { *p }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:61:31 + --> $DIR/functions.rs:66:31 | -61 | println!("{:?}", unsafe { p.as_ref() }); +66 | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:62:29 + --> $DIR/functions.rs:67:29 | -62 | unsafe { std::ptr::read(p) }; +67 | unsafe { std::ptr::read(p) }; | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:71:34 + --> $DIR/functions.rs:76:34 | -71 | println!("{}", unsafe { *p }); +76 | println!("{}", unsafe { *p }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:72:35 + --> $DIR/functions.rs:77:35 | -72 | println!("{:?}", unsafe { p.as_ref() }); +77 | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:73:33 + --> $DIR/functions.rs:78:33 | -73 | unsafe { std::ptr::read(p) }; +78 | unsafe { std::ptr::read(p) }; | ^ error: aborting due to 12 previous errors diff --git a/tests/ui/fxhash.stderr b/tests/ui/fxhash.stderr index f5f8ae7e801..a1e50401b46 100644 --- a/tests/ui/fxhash.stderr +++ b/tests/ui/fxhash.stderr @@ -1,39 +1,39 @@ error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:18:24 + --> $DIR/fxhash.rs:16:24 | -18 | use std::collections::{HashMap, HashSet}; +16 | use std::collections::{HashMap, HashSet}; | ^^^^^^^ help: use: `FxHashMap` | = note: `-D clippy::default-hash-types` implied by `-D warnings` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:18:33 + --> $DIR/fxhash.rs:16:33 | -18 | use std::collections::{HashMap, HashSet}; +16 | use std::collections::{HashMap, HashSet}; | ^^^^^^^ help: use: `FxHashSet` error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:22:15 + --> $DIR/fxhash.rs:19:15 | -22 | let _map: HashMap = HashMap::default(); +19 | let _map: HashMap = HashMap::default(); | ^^^^^^^ help: use: `FxHashMap` error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:22:41 + --> $DIR/fxhash.rs:19:41 | -22 | let _map: HashMap = HashMap::default(); +19 | let _map: HashMap = HashMap::default(); | ^^^^^^^ help: use: `FxHashMap` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:23:15 + --> $DIR/fxhash.rs:20:15 | -23 | let _set: HashSet = HashSet::default(); +20 | let _set: HashSet = HashSet::default(); | ^^^^^^^ help: use: `FxHashSet` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:23:33 + --> $DIR/fxhash.rs:20:33 | -23 | let _set: HashSet = HashSet::default(); +20 | let _set: HashSet = HashSet::default(); | ^^^^^^^ help: use: `FxHashSet` error: aborting due to 6 previous errors diff --git a/tests/ui/get_unwrap.stderr b/tests/ui/get_unwrap.stderr index 90b46e960f4..8b07e740a9a 100644 --- a/tests/ui/get_unwrap.stderr +++ b/tests/ui/get_unwrap.stderr @@ -1,75 +1,75 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:37:17 + --> $DIR/get_unwrap.rs:41:17 | -37 | let _ = boxed_slice.get(1).unwrap(); +41 | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]` | = note: `-D clippy::get-unwrap` implied by `-D warnings` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:38:17 + --> $DIR/get_unwrap.rs:42:17 | -38 | let _ = some_slice.get(0).unwrap(); +42 | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_slice[0]` error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:39:17 + --> $DIR/get_unwrap.rs:43:17 | -39 | let _ = some_vec.get(0).unwrap(); +43 | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vec[0]` error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:40:17 + --> $DIR/get_unwrap.rs:44:17 | -40 | let _ = some_vecdeque.get(0).unwrap(); +44 | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vecdeque[0]` error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:41:17 + --> $DIR/get_unwrap.rs:45:17 | -41 | let _ = some_hashmap.get(&1).unwrap(); +45 | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_hashmap[&1]` error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:42:17 + --> $DIR/get_unwrap.rs:46:17 | -42 | let _ = some_btreemap.get(&1).unwrap(); +46 | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_btreemap[&1]` error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:47:10 + --> $DIR/get_unwrap.rs:52:10 | -47 | *boxed_slice.get_mut(0).unwrap() = 1; +52 | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut boxed_slice[0]` error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:48:10 + --> $DIR/get_unwrap.rs:53:10 | -48 | *some_slice.get_mut(0).unwrap() = 1; +53 | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut some_slice[0]` error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:49:10 + --> $DIR/get_unwrap.rs:54:10 | -49 | *some_vec.get_mut(0).unwrap() = 1; +54 | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut some_vec[0]` error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:50:10 + --> $DIR/get_unwrap.rs:55:10 | -50 | *some_vecdeque.get_mut(0).unwrap() = 1; +55 | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut some_vecdeque[0]` error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:58:17 + --> $DIR/get_unwrap.rs:64:17 | -58 | let _ = some_vec.get(0..1).unwrap().to_vec(); +64 | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:59:17 + --> $DIR/get_unwrap.rs:65:17 | -59 | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); +65 | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` error: aborting due to 12 previous errors diff --git a/tests/ui/identity_conversion.stderr b/tests/ui/identity_conversion.stderr index 15bef8b125e..aab6bf7f218 100644 --- a/tests/ui/identity_conversion.stderr +++ b/tests/ui/identity_conversion.stderr @@ -1,67 +1,67 @@ error: identical conversion - --> $DIR/identity_conversion.rs:16:13 + --> $DIR/identity_conversion.rs:13:13 | -16 | let _ = T::from(val); +13 | let _ = T::from(val); | ^^^^^^^^^^^^ help: consider removing `T::from()`: `val` | note: lint level defined here - --> $DIR/identity_conversion.rs:13:9 + --> $DIR/identity_conversion.rs:10:9 | -13 | #![deny(clippy::identity_conversion)] +10 | #![deny(clippy::identity_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: identical conversion - --> $DIR/identity_conversion.rs:17:5 + --> $DIR/identity_conversion.rs:14:5 | -17 | val.into() +14 | val.into() | ^^^^^^^^^^ help: consider removing `.into()`: `val` error: identical conversion - --> $DIR/identity_conversion.rs:29:22 + --> $DIR/identity_conversion.rs:26:22 | -29 | let _: i32 = 0i32.into(); +26 | let _: i32 = 0i32.into(); | ^^^^^^^^^^^ help: consider removing `.into()`: `0i32` error: identical conversion - --> $DIR/identity_conversion.rs:50:21 + --> $DIR/identity_conversion.rs:47:21 | -50 | let _: String = "foo".to_string().into(); +47 | let _: String = "foo".to_string().into(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()` error: identical conversion - --> $DIR/identity_conversion.rs:51:21 + --> $DIR/identity_conversion.rs:48:21 | -51 | let _: String = From::from("foo".to_string()); +48 | let _: String = From::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()` +error: identical conversion + --> $DIR/identity_conversion.rs:49:13 + | +49 | let _ = String::from("foo".to_string()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` + +error: identical conversion + --> $DIR/identity_conversion.rs:50:13 + | +50 | let _ = String::from(format!("A: {:04}", 123)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)` + +error: identical conversion + --> $DIR/identity_conversion.rs:51:13 + | +51 | let _ = "".lines().into_iter(); + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()` + error: identical conversion --> $DIR/identity_conversion.rs:52:13 | -52 | let _ = String::from("foo".to_string()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` - -error: identical conversion - --> $DIR/identity_conversion.rs:53:13 - | -53 | let _ = String::from(format!("A: {:04}", 123)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)` - -error: identical conversion - --> $DIR/identity_conversion.rs:54:13 - | -54 | let _ = "".lines().into_iter(); - | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()` - -error: identical conversion - --> $DIR/identity_conversion.rs:55:13 - | -55 | let _ = vec![1, 2, 3].into_iter().into_iter(); +52 | let _ = vec![1, 2, 3].into_iter().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()` error: identical conversion - --> $DIR/identity_conversion.rs:56:21 + --> $DIR/identity_conversion.rs:53:21 | -56 | let _: String = format!("Hello {}", "world").into(); +53 | let _: String = format!("Hello {}", "world").into(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")` error: aborting due to 10 previous errors diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index 332350fd1d8..e2b6efa7dbe 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -1,51 +1,51 @@ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:23:5 + --> $DIR/identity_op.rs:24:5 | -23 | x + 0; +24 | x + 0; | ^^^^^ | = note: `-D clippy::identity-op` implied by `-D warnings` error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:24:5 + --> $DIR/identity_op.rs:25:5 | -24 | x + (1 - 1); +25 | x + (1 - 1); | ^^^^^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:26:5 + --> $DIR/identity_op.rs:27:5 | -26 | 0 + x; +27 | 0 + x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:29:5 + --> $DIR/identity_op.rs:30:5 | -29 | x | (0); +30 | x | (0); | ^^^^^^^ -error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:32:5 - | -32 | x * 1; - | ^^^^^ - error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:33:5 | -33 | 1 * x; +33 | x * 1; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:39:5 + --> $DIR/identity_op.rs:34:5 | -39 | -1 & x; +34 | 1 * x; + | ^^^^^ + +error: the operation is ineffective. Consider reducing it to `x` + --> $DIR/identity_op.rs:40:5 + | +40 | -1 & x; | ^^^^^^ error: the operation is ineffective. Consider reducing it to `u` - --> $DIR/identity_op.rs:42:5 + --> $DIR/identity_op.rs:43:5 | -42 | u & 255; +43 | u & 255; | ^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/if_not_else.stderr b/tests/ui/if_not_else.stderr index a054ac6223d..0393e49a2ee 100644 --- a/tests/ui/if_not_else.stderr +++ b/tests/ui/if_not_else.stderr @@ -1,24 +1,24 @@ error: Unnecessary boolean `not` operation - --> $DIR/if_not_else.rs:19:5 + --> $DIR/if_not_else.rs:18:5 | -19 | / if !bla() { -20 | | println!("Bugs"); -21 | | } else { -22 | | println!("Bunny"); -23 | | } +18 | / if !bla() { +19 | | println!("Bugs"); +20 | | } else { +21 | | println!("Bunny"); +22 | | } | |_____^ | = note: `-D clippy::if-not-else` implied by `-D warnings` = help: remove the `!` and swap the blocks of the if/else error: Unnecessary `!=` operation - --> $DIR/if_not_else.rs:24:5 + --> $DIR/if_not_else.rs:23:5 | -24 | / if 4 != 5 { -25 | | println!("Bugs"); -26 | | } else { -27 | | println!("Bunny"); -28 | | } +23 | / if 4 != 5 { +24 | | println!("Bugs"); +25 | | } else { +26 | | println!("Bunny"); +27 | | } | |_____^ | = help: change to `==` and swap the blocks of the if/else diff --git a/tests/ui/impl.stderr b/tests/ui/impl.stderr index c24a96e8aa7..adad754bffe 100644 --- a/tests/ui/impl.stderr +++ b/tests/ui/impl.stderr @@ -1,34 +1,34 @@ error: Multiple implementations of this structure - --> $DIR/impl.rs:22:1 + --> $DIR/impl.rs:19:1 | -22 | / impl MyStruct { -23 | | fn second() {} -24 | | } +19 | / impl MyStruct { +20 | | fn second() {} +21 | | } | |_^ | = note: `-D clippy::multiple-inherent-impl` implied by `-D warnings` note: First implementation here - --> $DIR/impl.rs:18:1 + --> $DIR/impl.rs:15:1 | -18 | / impl MyStruct { -19 | | fn first() {} -20 | | } +15 | / impl MyStruct { +16 | | fn first() {} +17 | | } | |_^ error: Multiple implementations of this structure - --> $DIR/impl.rs:36:5 + --> $DIR/impl.rs:33:5 | -36 | / impl super::MyStruct { -37 | | fn third() {} -38 | | } +33 | / impl super::MyStruct { +34 | | fn third() {} +35 | | } | |_____^ | note: First implementation here - --> $DIR/impl.rs:18:1 + --> $DIR/impl.rs:15:1 | -18 | / impl MyStruct { -19 | | fn first() {} -20 | | } +15 | / impl MyStruct { +16 | | fn first() {} +17 | | } | |_^ error: aborting due to 2 previous errors diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index c561e0a3dfb..58b823e6ca1 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -1,136 +1,136 @@ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:21:35 + --> $DIR/implicit_hasher.rs:20:35 | -21 | impl Foo for HashMap { +20 | impl Foo for HashMap { | ^^^^^^^^^^^^^ | = note: `-D clippy::implicit-hasher` implied by `-D warnings` help: consider adding a type parameter | -21 | impl Foo for HashMap { +20 | impl Foo for HashMap { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -27 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) +26 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:30:36 + --> $DIR/implicit_hasher.rs:29:36 | -30 | impl Foo for (HashMap,) { +29 | impl Foo for (HashMap,) { | ^^^^^^^^^^^^^ help: consider adding a type parameter | -30 | impl Foo for (HashMap,) { +29 | impl Foo for (HashMap,) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -32 | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) +31 | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:35:19 + --> $DIR/implicit_hasher.rs:34:19 | -35 | impl Foo for HashMap { +34 | impl Foo for HashMap { | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider adding a type parameter | -35 | impl Foo for HashMap { +34 | impl Foo for HashMap { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -37 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) +36 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:53:32 + --> $DIR/implicit_hasher.rs:51:32 | -53 | impl Foo for HashSet { +51 | impl Foo for HashSet { | ^^^^^^^^^^ help: consider adding a type parameter | -53 | impl Foo for HashSet { +51 | impl Foo for HashSet { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ help: ...and use generic constructor | -55 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) +53 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:58:19 + --> $DIR/implicit_hasher.rs:56:19 | -58 | impl Foo for HashSet { +56 | impl Foo for HashSet { | ^^^^^^^^^^^^^^^ help: consider adding a type parameter | -58 | impl Foo for HashSet { +56 | impl Foo for HashSet { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -60 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) +58 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:75:23 + --> $DIR/implicit_hasher.rs:73:23 | -75 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { +73 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^ help: consider adding a type parameter | -75 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { +73 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:75:53 + --> $DIR/implicit_hasher.rs:73:53 | -75 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { +73 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^ help: consider adding a type parameter | -75 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { +73 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:80:43 + --> $DIR/implicit_hasher.rs:77:43 | -80 | impl Foo for HashMap { +77 | impl Foo for HashMap { | ^^^^^^^^^^^^^ ... -93 | gen!(impl); - | ----------- in this macro invocation +89 | gen!(impl ); + | ------------ in this macro invocation help: consider adding a type parameter | -80 | impl Foo for HashMap { +77 | impl Foo for HashMap { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -82 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) +79 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:88:33 + --> $DIR/implicit_hasher.rs:85:33 | -88 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { +85 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^ ... -94 | gen!(fn bar); +90 | gen!(fn bar); | ------------- in this macro invocation help: consider adding a type parameter | -88 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { +85 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:88:63 + --> $DIR/implicit_hasher.rs:85:63 | -88 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { +85 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^ ... -94 | gen!(fn bar); +90 | gen!(fn bar); | ------------- in this macro invocation help: consider adding a type parameter | -88 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { +85 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ error: aborting due to 10 previous errors diff --git a/tests/ui/implicit_return.stderr b/tests/ui/implicit_return.stderr index 6f4fe12757a..26474aab4b8 100644 --- a/tests/ui/implicit_return.stderr +++ b/tests/ui/implicit_return.stderr @@ -1,51 +1,51 @@ error: missing return statement - --> $DIR/implicit_return.rs:21:5 + --> $DIR/implicit_return.rs:17:5 | -21 | true +17 | true | ^^^^ help: add `return` as shown: `return true` | = note: `-D clippy::implicit-return` implied by `-D warnings` error: missing return statement - --> $DIR/implicit_return.rs:27:9 + --> $DIR/implicit_return.rs:23:9 | -27 | true +23 | true | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:29:9 + --> $DIR/implicit_return.rs:25:9 | -29 | false +25 | false | ^^^^^ help: add `return` as shown: `return false` error: missing return statement - --> $DIR/implicit_return.rs:36:17 + --> $DIR/implicit_return.rs:32:17 | -36 | true => false, +32 | true => false, | ^^^^^ help: add `return` as shown: `return false` error: missing return statement - --> $DIR/implicit_return.rs:38:13 + --> $DIR/implicit_return.rs:33:18 | -38 | true - | ^^^^ help: add `return` as shown: `return true` +33 | false => true, + | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:46:9 + --> $DIR/implicit_return.rs:40:9 | -46 | break true; +40 | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:52:9 + --> $DIR/implicit_return.rs:45:16 | -52 | true - | ^^^^ help: add `return` as shown: `return true` +45 | let _ = || true; + | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:54:16 + --> $DIR/implicit_return.rs:46:16 | -54 | let _ = || true; +46 | let _ = || true; | ^^^^ help: add `return` as shown: `return true` error: aborting due to 8 previous errors diff --git a/tests/ui/inconsistent_digit_grouping.stderr b/tests/ui/inconsistent_digit_grouping.stderr index a417394629e..77e2f3bd41b 100644 --- a/tests/ui/inconsistent_digit_grouping.stderr +++ b/tests/ui/inconsistent_digit_grouping.stderr @@ -1,33 +1,33 @@ error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:17:16 + --> $DIR/inconsistent_digit_grouping.rs:22:16 | -17 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `123_456` | = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:17:26 + --> $DIR/inconsistent_digit_grouping.rs:22:26 | -17 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^ help: consider: `12_345_678` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:17:38 + --> $DIR/inconsistent_digit_grouping.rs:22:38 | -17 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `1_234_567` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:17:48 + --> $DIR/inconsistent_digit_grouping.rs:22:48 | -17 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1_234.567_8_f32` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:17:64 + --> $DIR/inconsistent_digit_grouping.rs:22:64 | -17 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1.234_567_8_f32` error: aborting due to 5 previous errors diff --git a/tests/ui/indexing_slicing.stderr b/tests/ui/indexing_slicing.stderr index 14e9627e573..c9a45bc4084 100644 --- a/tests/ui/indexing_slicing.stderr +++ b/tests/ui/indexing_slicing.stderr @@ -1,308 +1,308 @@ error: index out of bounds: the len is 4 but the index is 4 - --> $DIR/indexing_slicing.rs:28:5 + --> $DIR/indexing_slicing.rs:25:5 | -28 | x[4]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +25 | x[4]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^ | = note: #[deny(const_err)] on by default error: index out of bounds: the len is 4 but the index is 8 - --> $DIR/indexing_slicing.rs:29:5 + --> $DIR/indexing_slicing.rs:26:5 | -29 | x[1 << 3]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +26 | x[1 << 3]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^^^^^^ error: index out of bounds: the len is 0 but the index is 0 - --> $DIR/indexing_slicing.rs:59:5 + --> $DIR/indexing_slicing.rs:56:5 | -59 | empty[0]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +56 | empty[0]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^^^^^ error: index out of bounds: the len is 4 but the index is 15 - --> $DIR/indexing_slicing.rs:90:5 + --> $DIR/indexing_slicing.rs:87:5 | -90 | x[N]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +87 | x[N]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^ error: indexing may panic. - --> $DIR/indexing_slicing.rs:23:5 + --> $DIR/indexing_slicing.rs:20:5 | -23 | x[index]; +20 | x[index]; | ^^^^^^^^ | = note: `-D clippy::indexing-slicing` implied by `-D warnings` = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:24:6 + --> $DIR/indexing_slicing.rs:21:6 | -24 | &x[index..]; +21 | &x[index..]; | ^^^^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:25:6 + --> $DIR/indexing_slicing.rs:22:6 | -25 | &x[..index]; +22 | &x[..index]; | ^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:26:6 + --> $DIR/indexing_slicing.rs:23:6 | -26 | &x[index_from..index_to]; +23 | &x[index_from..index_to]; | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:27:6 + --> $DIR/indexing_slicing.rs:24:6 | -27 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. +24 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:27:6 + --> $DIR/indexing_slicing.rs:24:6 | -27 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. +24 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. | ^^^^^^^^^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:30:11 + --> $DIR/indexing_slicing.rs:27:11 | -30 | &x[..=4]; +27 | &x[..=4]; | ^ | = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` error: range is out of bounds - --> $DIR/indexing_slicing.rs:31:11 + --> $DIR/indexing_slicing.rs:28:11 | -31 | &x[1..5]; +28 | &x[1..5]; | ^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:32:6 + --> $DIR/indexing_slicing.rs:29:6 | -32 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. +29 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. | ^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:32:8 + --> $DIR/indexing_slicing.rs:29:8 | -32 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. +29 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:33:8 + --> $DIR/indexing_slicing.rs:30:8 | -33 | &x[5..]; +30 | &x[5..]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:34:10 + --> $DIR/indexing_slicing.rs:31:10 | -34 | &x[..5]; +31 | &x[..5]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:35:8 + --> $DIR/indexing_slicing.rs:32:8 | -35 | &x[5..].iter().map(|x| 2 * x).collect::>(); +32 | &x[5..].iter().map(|x| 2 * x).collect::>(); | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:36:12 + --> $DIR/indexing_slicing.rs:33:12 | -36 | &x[0..=4]; +33 | &x[0..=4]; | ^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:37:6 + --> $DIR/indexing_slicing.rs:34:6 | -37 | &x[0..][..3]; +34 | &x[0..][..3]; | ^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:38:6 + --> $DIR/indexing_slicing.rs:35:6 | -38 | &x[1..][..5]; +35 | &x[1..][..5]; | ^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:51:5 + --> $DIR/indexing_slicing.rs:48:5 | -51 | y[0]; +48 | y[0]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:52:6 + --> $DIR/indexing_slicing.rs:49:6 | -52 | &y[1..2]; +49 | &y[1..2]; | ^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:53:6 + --> $DIR/indexing_slicing.rs:50:6 | -53 | &y[0..=4]; +50 | &y[0..=4]; | ^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:54:6 + --> $DIR/indexing_slicing.rs:51:6 | -54 | &y[..=4]; +51 | &y[..=4]; | ^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:60:12 + --> $DIR/indexing_slicing.rs:57:12 | -60 | &empty[1..5]; +57 | &empty[1..5]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:61:16 + --> $DIR/indexing_slicing.rs:58:16 | -61 | &empty[0..=4]; +58 | &empty[0..=4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:62:15 + --> $DIR/indexing_slicing.rs:59:15 | -62 | &empty[..=4]; +59 | &empty[..=4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:63:12 + --> $DIR/indexing_slicing.rs:60:12 | -63 | &empty[1..]; +60 | &empty[1..]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:64:14 + --> $DIR/indexing_slicing.rs:61:14 | -64 | &empty[..4]; +61 | &empty[..4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:65:16 + --> $DIR/indexing_slicing.rs:62:16 | -65 | &empty[0..=0]; +62 | &empty[0..=0]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:66:15 + --> $DIR/indexing_slicing.rs:63:15 | -66 | &empty[..=0]; +63 | &empty[..=0]; | ^ error: indexing may panic. - --> $DIR/indexing_slicing.rs:74:5 + --> $DIR/indexing_slicing.rs:71:5 | -74 | v[0]; +71 | v[0]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:75:5 + --> $DIR/indexing_slicing.rs:72:5 | -75 | v[10]; +72 | v[10]; | ^^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:76:5 + --> $DIR/indexing_slicing.rs:73:5 | -76 | v[1 << 3]; +73 | v[1 << 3]; | ^^^^^^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:77:6 + --> $DIR/indexing_slicing.rs:74:6 | -77 | &v[10..100]; +74 | &v[10..100]; | ^^^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:78:6 + --> $DIR/indexing_slicing.rs:75:6 | -78 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. +75 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:78:8 + --> $DIR/indexing_slicing.rs:75:8 | -78 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. +75 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:79:6 + --> $DIR/indexing_slicing.rs:76:6 | -79 | &v[10..]; +76 | &v[10..]; | ^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:80:6 + --> $DIR/indexing_slicing.rs:77:6 | -80 | &v[..100]; +77 | &v[..100]; | ^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:92:5 + --> $DIR/indexing_slicing.rs:89:5 | -92 | v[N]; +89 | v[N]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:93:5 + --> $DIR/indexing_slicing.rs:90:5 | -93 | v[M]; +90 | v[M]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:97:13 + --> $DIR/indexing_slicing.rs:94:13 | -97 | &x[num..10]; // should trigger out of bounds error +94 | &x[num..10]; // should trigger out of bounds error | ^^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:98:8 + --> $DIR/indexing_slicing.rs:95:8 | -98 | &x[10..num]; // should trigger out of bounds error +95 | &x[10..num]; // should trigger out of bounds error | ^^ error: aborting due to 43 previous errors diff --git a/tests/ui/infallible_destructuring_match.stderr b/tests/ui/infallible_destructuring_match.stderr index bce83b91242..62588a2ad7c 100644 --- a/tests/ui/infallible_destructuring_match.stderr +++ b/tests/ui/infallible_destructuring_match.stderr @@ -1,27 +1,27 @@ error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:28:5 + --> $DIR/infallible_destructuring_match.rs:25:5 | -28 | / let data = match wrapper { -29 | | SingleVariantEnum::Variant(i) => i, -30 | | }; +25 | / let data = match wrapper { +26 | | SingleVariantEnum::Variant(i) => i, +27 | | }; | |______^ help: try this: `let SingleVariantEnum::Variant(data) = wrapper;` | = note: `-D clippy::infallible-destructuring-match` implied by `-D warnings` error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:49:5 + --> $DIR/infallible_destructuring_match.rs:46:5 | -49 | / let data = match wrapper { -50 | | TupleStruct(i) => i, -51 | | }; +46 | / let data = match wrapper { +47 | | TupleStruct(i) => i, +48 | | }; | |______^ help: try this: `let TupleStruct(data) = wrapper;` error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:70:5 + --> $DIR/infallible_destructuring_match.rs:67:5 | -70 | / let data = match wrapper { -71 | | Ok(i) => i, -72 | | }; +67 | / let data = match wrapper { +68 | | Ok(i) => i, +69 | | }; | |______^ help: try this: `let Ok(data) = wrapper;` error: aborting due to 3 previous errors diff --git a/tests/ui/infinite_iter.stderr b/tests/ui/infinite_iter.stderr index 5b783c2b8b9..2c3b05aaff3 100644 --- a/tests/ui/infinite_iter.stderr +++ b/tests/ui/infinite_iter.stderr @@ -1,99 +1,108 @@ error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator - --> $DIR/infinite_iter.rs:20:5 + --> $DIR/infinite_iter.rs:19:5 | -20 | repeat(0_u8).collect::>(); // infinite iter +19 | repeat(0_u8).collect::>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unused-collect` implied by `-D warnings` error: infinite iteration detected - --> $DIR/infinite_iter.rs:20:5 + --> $DIR/infinite_iter.rs:19:5 | -20 | repeat(0_u8).collect::>(); // infinite iter +19 | repeat(0_u8).collect::>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/infinite_iter.rs:18:8 + --> $DIR/infinite_iter.rs:17:8 | -18 | #[deny(clippy::infinite_iter)] +17 | #[deny(clippy::infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^ +error: infinite iteration detected + --> $DIR/infinite_iter.rs:20:5 + | +20 | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: infinite iteration detected --> $DIR/infinite_iter.rs:21:5 | -21 | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: infinite iteration detected - --> $DIR/infinite_iter.rs:22:5 - | -22 | (0..8_u64).chain(0..).max(); // infinite iter +21 | (0..8_u64).chain(0..).max(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: infinite iteration detected - --> $DIR/infinite_iter.rs:24:5 - | -24 | (0..8_u32).rev().cycle().map(|x| x + 1_u32).for_each(|x| println!("{}", x)); // infinite iter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: infinite iteration detected --> $DIR/infinite_iter.rs:26:5 | -26 | (0_usize..).flat_map(|x| 0..x).product::(); // infinite iter +26 | / (0..8_u32) +27 | | .rev() +28 | | .cycle() +29 | | .map(|x| x + 1_u32) +30 | | .for_each(|x| println!("{}", x)); // infinite iter + | |________________________________________^ + +error: infinite iteration detected + --> $DIR/infinite_iter.rs:32:5 + | +32 | (0_usize..).flat_map(|x| 0..x).product::(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:27:5 + --> $DIR/infinite_iter.rs:33:5 | -27 | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter +33 | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:34:5 - | -34 | (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/infinite_iter.rs:32:8 - | -32 | #[deny(clippy::maybe_infinite_iter)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:35:5 - | -35 | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:36:5 - | -36 | (1..).scan(0, |state, x| { *state += x; Some(*state) }).min(); // maybe infinite iter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:37:5 - | -37 | (0..).find(|x| *x == 24); // maybe infinite iter - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:38:5 - | -38 | (0..).position(|x| x == 24); // maybe infinite iter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:39:5 - | -39 | (0..).any(|x| x == 24); // maybe infinite iter - | ^^^^^^^^^^^^^^^^^^^^^^ - error: possible infinite iteration detected --> $DIR/infinite_iter.rs:40:5 | -40 | (0..).all(|x| x == 24); // maybe infinite iter +40 | (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/infinite_iter.rs:38:8 + | +38 | #[deny(clippy::maybe_infinite_iter)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: possible infinite iteration detected + --> $DIR/infinite_iter.rs:41:5 + | +41 | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: possible infinite iteration detected + --> $DIR/infinite_iter.rs:42:5 + | +42 | / (1..) +43 | | .scan(0, |state, x| { +44 | | *state += x; +45 | | Some(*state) +46 | | }) +47 | | .min(); // maybe infinite iter + | |______________^ + +error: possible infinite iteration detected + --> $DIR/infinite_iter.rs:48:5 + | +48 | (0..).find(|x| *x == 24); // maybe infinite iter + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: possible infinite iteration detected + --> $DIR/infinite_iter.rs:49:5 + | +49 | (0..).position(|x| x == 24); // maybe infinite iter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: possible infinite iteration detected + --> $DIR/infinite_iter.rs:50:5 + | +50 | (0..).any(|x| x == 24); // maybe infinite iter + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: possible infinite iteration detected + --> $DIR/infinite_iter.rs:51:5 + | +51 | (0..).all(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/infinite_loop.stderr b/tests/ui/infinite_loop.stderr index fdbdd13fd8f..de7851519ec 100644 --- a/tests/ui/infinite_loop.stderr +++ b/tests/ui/infinite_loop.stderr @@ -1,57 +1,57 @@ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:26:11 + --> $DIR/infinite_loop.rs:32:11 | -26 | while y < 10 { +32 | while y < 10 { | ^^^^^^ | = note: #[deny(clippy::while_immutable_condition)] on by default error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:31:11 + --> $DIR/infinite_loop.rs:37:11 | -31 | while y < 10 && x < 3 { +37 | while y < 10 && x < 3 { | ^^^^^^^^^^^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:38:11 + --> $DIR/infinite_loop.rs:44:11 | -38 | while !cond { +44 | while !cond { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:82:11 + --> $DIR/infinite_loop.rs:88:11 | -82 | while i < 3 { +88 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:87:11 + --> $DIR/infinite_loop.rs:93:11 | -87 | while i < 3 && j > 0 { +93 | while i < 3 && j > 0 { | ^^^^^^^^^^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:91:11 + --> $DIR/infinite_loop.rs:97:11 | -91 | while i < 3 { +97 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:106:11 + --> $DIR/infinite_loop.rs:112:11 | -106 | while i < 3 { +112 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:111:11 + --> $DIR/infinite_loop.rs:117:11 | -111 | while i < 3 { +117 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:174:15 + --> $DIR/infinite_loop.rs:183:15 | -174 | while self.count < n { +183 | while self.count < n { | ^^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/inline_fn_without_body.stderr b/tests/ui/inline_fn_without_body.stderr index 112fad812e5..0eaee7c7b25 100644 --- a/tests/ui/inline_fn_without_body.stderr +++ b/tests/ui/inline_fn_without_body.stderr @@ -1,25 +1,27 @@ error: use of `#[inline]` on trait method `default_inline` which has no body - --> $DIR/inline_fn_without_body.rs:18:5 + --> $DIR/inline_fn_without_body.rs:14:5 | -18 | #[inline] +14 | #[inline] | _____-^^^^^^^^ -19 | | fn default_inline(); +15 | | fn default_inline(); | |____- help: remove | = note: `-D clippy::inline-fn-without-body` implied by `-D warnings` error: use of `#[inline]` on trait method `always_inline` which has no body - --> $DIR/inline_fn_without_body.rs:21:5 + --> $DIR/inline_fn_without_body.rs:17:5 | -21 | #[inline(always)]fn always_inline(); - | ^^^^^^^^^^^^^^^^^ help: remove +17 | #[inline(always)] + | _____-^^^^^^^^^^^^^^^^ +18 | | fn always_inline(); + | |____- help: remove error: use of `#[inline]` on trait method `never_inline` which has no body - --> $DIR/inline_fn_without_body.rs:23:5 + --> $DIR/inline_fn_without_body.rs:20:5 | -23 | #[inline(never)] +20 | #[inline(never)] | _____-^^^^^^^^^^^^^^^ -24 | | fn never_inline(); +21 | | fn never_inline(); | |____- help: remove error: aborting due to 3 previous errors diff --git a/tests/ui/int_plus_one.stderr b/tests/ui/int_plus_one.stderr index 5612b203290..4a81e911157 100644 --- a/tests/ui/int_plus_one.stderr +++ b/tests/ui/int_plus_one.stderr @@ -1,43 +1,43 @@ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:20:5 + --> $DIR/int_plus_one.rs:16:5 | -20 | x >= y + 1; +16 | x >= y + 1; | ^^^^^^^^^^ | = note: `-D clippy::int-plus-one` implied by `-D warnings` help: change `>= y + 1` to `> y` as shown | -20 | x > y; +16 | x > y; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:21:5 + --> $DIR/int_plus_one.rs:17:5 | -21 | y + 1 <= x; +17 | y + 1 <= x; | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -21 | y < x; +17 | y < x; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:23:5 + --> $DIR/int_plus_one.rs:19:5 | -23 | x - 1 >= y; +19 | x - 1 >= y; | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -23 | x > y; +19 | x > y; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:24:5 + --> $DIR/int_plus_one.rs:20:5 | -24 | y <= x - 1; +20 | y <= x - 1; | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -24 | y < x; +20 | y < x; | ^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/into_iter_on_ref.stderr b/tests/ui/into_iter_on_ref.stderr index 39055423048..f6d6fe35d7f 100644 --- a/tests/ui/into_iter_on_ref.stderr +++ b/tests/ui/into_iter_on_ref.stderr @@ -1,8 +1,8 @@ error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:11:22 + --> $DIR/into_iter_on_ref.rs:11:24 | -11 | for _ in [1,2,3].into_iter() {} //~ ERROR equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +11 | for _ in [1, 2, 3].into_iter() {} //~ ERROR equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` | note: lint level defined here --> $DIR/into_iter_on_ref.rs:2:9 @@ -11,24 +11,24 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:13:21 + --> $DIR/into_iter_on_ref.rs:13:23 | -13 | let _ = [1,2,3].into_iter(); //~ ERROR equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +13 | let _ = [1, 2, 3].into_iter(); //~ ERROR equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the Vec - --> $DIR/into_iter_on_ref.rs:15:28 + --> $DIR/into_iter_on_ref.rs:15:30 | -15 | let _ = (&vec![1,2,3]).into_iter(); //~ WARN equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +15 | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` | = note: `-D clippy::into-iter-on-ref` implied by `-D warnings` error: this .into_iter() call is equivalent to .iter() and will not move the slice - --> $DIR/into_iter_on_ref.rs:16:44 + --> $DIR/into_iter_on_ref.rs:16:46 | -16 | let _ = vec![1,2,3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +16 | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the slice --> $DIR/into_iter_on_ref.rs:17:41 @@ -43,22 +43,22 @@ error: this .into_iter() call is equivalent to .iter() and will not move the sli | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:20:30 + --> $DIR/into_iter_on_ref.rs:20:32 | -20 | let _ = (&&&&&&&[1,2,3]).into_iter(); //~ ERROR equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +20 | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:21:34 + --> $DIR/into_iter_on_ref.rs:21:36 | -21 | let _ = (&&&&mut &&&[1,2,3]).into_iter(); //~ ERROR equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +21 | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the array - --> $DIR/into_iter_on_ref.rs:22:38 + --> $DIR/into_iter_on_ref.rs:22:40 | -22 | let _ = (&mut &mut &mut [1,2,3]).into_iter(); //~ ERROR equivalent to .iter_mut() - | ^^^^^^^^^ help: call directly: `iter_mut` +22 | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut() + | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the Option --> $DIR/into_iter_on_ref.rs:24:24 diff --git a/tests/ui/invalid_ref.stderr b/tests/ui/invalid_ref.stderr index 52868e908ca..a5142596aeb 100644 --- a/tests/ui/invalid_ref.stderr +++ b/tests/ui/invalid_ref.stderr @@ -1,48 +1,48 @@ error: reference to zeroed memory - --> $DIR/invalid_ref.rs:37:24 + --> $DIR/invalid_ref.rs:33:24 | -37 | let ref_zero: &T = std::mem::zeroed(); // warning +33 | let ref_zero: &T = std::mem::zeroed(); // warning | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(clippy::invalid_ref)] on by default = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to zeroed memory - --> $DIR/invalid_ref.rs:41:24 + --> $DIR/invalid_ref.rs:37:24 | -41 | let ref_zero: &T = core::mem::zeroed(); // warning +37 | let ref_zero: &T = core::mem::zeroed(); // warning | ^^^^^^^^^^^^^^^^^^^ | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to zeroed memory - --> $DIR/invalid_ref.rs:45:24 + --> $DIR/invalid_ref.rs:41:24 | -45 | let ref_zero: &T = std::intrinsics::init(); // warning +41 | let ref_zero: &T = std::intrinsics::init(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html +error: reference to uninitialized memory + --> $DIR/invalid_ref.rs:45:26 + | +45 | let ref_uninit: &T = std::mem::uninitialized(); // warning + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html + error: reference to uninitialized memory --> $DIR/invalid_ref.rs:49:26 | -49 | let ref_uninit: &T = std::mem::uninitialized(); // warning - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +49 | let ref_uninit: &T = core::mem::uninitialized(); // warning + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to uninitialized memory --> $DIR/invalid_ref.rs:53:26 | -53 | let ref_uninit: &T = core::mem::uninitialized(); // warning - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html - -error: reference to uninitialized memory - --> $DIR/invalid_ref.rs:57:26 - | -57 | let ref_uninit: &T = std::intrinsics::uninit(); // warning +53 | let ref_uninit: &T = std::intrinsics::uninit(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html diff --git a/tests/ui/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index e41132dfc8b..2ac4a48b862 100644 --- a/tests/ui/invalid_upcast_comparisons.stderr +++ b/tests/ui/invalid_upcast_comparisons.stderr @@ -1,165 +1,165 @@ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:26:5 + --> $DIR/invalid_upcast_comparisons.rs:30:5 | -26 | (u8 as u32) > 300; +30 | (u8 as u32) > 300; | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::invalid-upcast-comparisons` implied by `-D warnings` -error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:27:5 - | -27 | (u8 as i32) > 300; - | ^^^^^^^^^^^^^^^^^ - -error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:28:5 - | -28 | (u8 as u32) == 300; - | ^^^^^^^^^^^^^^^^^^ - -error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:29:5 - | -29 | (u8 as i32) == 300; - | ^^^^^^^^^^^^^^^^^^ - -error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:30:5 - | -30 | 300 < (u8 as u32); - | ^^^^^^^^^^^^^^^^^ - error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:31:5 | -31 | 300 < (u8 as i32); +31 | (u8 as i32) > 300; | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:32:5 | -32 | 300 == (u8 as u32); +32 | (u8 as u32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:33:5 | -33 | 300 == (u8 as i32); +33 | (u8 as i32) == 300; | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +error: because of the numeric bounds on `u8` prior to casting, this expression is always false + --> $DIR/invalid_upcast_comparisons.rs:34:5 + | +34 | 300 < (u8 as u32); + | ^^^^^^^^^^^^^^^^^ + +error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:35:5 | -35 | (u8 as u32) <= 300; - | ^^^^^^^^^^^^^^^^^^ +35 | 300 < (u8 as i32); + | ^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:36:5 | -36 | (u8 as i32) <= 300; +36 | 300 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:37:5 | -37 | (u8 as u32) != 300; - | ^^^^^^^^^^^^^^^^^^ - -error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:38:5 - | -38 | (u8 as i32) != 300; +37 | 300 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:39:5 | -39 | 300 >= (u8 as u32); +39 | (u8 as u32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:40:5 | -40 | 300 >= (u8 as i32); +40 | (u8 as i32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:41:5 | -41 | 300 != (u8 as u32); +41 | (u8 as u32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:42:5 | -42 | 300 != (u8 as i32); +42 | (u8 as i32) != 300; | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +error: because of the numeric bounds on `u8` prior to casting, this expression is always true + --> $DIR/invalid_upcast_comparisons.rs:43:5 + | +43 | 300 >= (u8 as u32); + | ^^^^^^^^^^^^^^^^^^ + +error: because of the numeric bounds on `u8` prior to casting, this expression is always true + --> $DIR/invalid_upcast_comparisons.rs:44:5 + | +44 | 300 >= (u8 as i32); + | ^^^^^^^^^^^^^^^^^^ + +error: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:45:5 | -45 | (u8 as i32) < 0; - | ^^^^^^^^^^^^^^^ +45 | 300 != (u8 as u32); + | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:46:5 | -46 | -5 != (u8 as i32); - | ^^^^^^^^^^^^^^^^^ - -error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:48:5 - | -48 | (u8 as i32) >= 0; - | ^^^^^^^^^^^^^^^^ +46 | 300 != (u8 as i32); + | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:49:5 | -49 | -5 == (u8 as i32); +49 | (u8 as i32) < 0; + | ^^^^^^^^^^^^^^^ + +error: because of the numeric bounds on `u8` prior to casting, this expression is always true + --> $DIR/invalid_upcast_comparisons.rs:50:5 + | +50 | -5 != (u8 as i32); | ^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +error: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:52:5 | -52 | 1337 == (u8 as i32); - | ^^^^^^^^^^^^^^^^^^^ +52 | (u8 as i32) >= 0; + | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:53:5 | -53 | 1337 == (u8 as u32); - | ^^^^^^^^^^^^^^^^^^^ +53 | -5 == (u8 as i32); + | ^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:55:5 - | -55 | 1337 != (u8 as i32); - | ^^^^^^^^^^^^^^^^^^^ - -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:56:5 | -56 | 1337 != (u8 as u32); +56 | 1337 == (u8 as i32); + | ^^^^^^^^^^^^^^^^^^^ + +error: because of the numeric bounds on `u8` prior to casting, this expression is always false + --> $DIR/invalid_upcast_comparisons.rs:57:5 + | +57 | 1337 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:71:5 + --> $DIR/invalid_upcast_comparisons.rs:59:5 | -71 | (u8 as i32) > -1; +59 | 1337 != (u8 as i32); + | ^^^^^^^^^^^^^^^^^^^ + +error: because of the numeric bounds on `u8` prior to casting, this expression is always true + --> $DIR/invalid_upcast_comparisons.rs:60:5 + | +60 | 1337 != (u8 as u32); + | ^^^^^^^^^^^^^^^^^^^ + +error: because of the numeric bounds on `u8` prior to casting, this expression is always true + --> $DIR/invalid_upcast_comparisons.rs:74:5 + | +74 | (u8 as i32) > -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:72:5 + --> $DIR/invalid_upcast_comparisons.rs:75:5 | -72 | (u8 as i32) < -1; +75 | (u8 as i32) < -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:88:5 + --> $DIR/invalid_upcast_comparisons.rs:91:5 | -88 | -5 >= (u8 as i32); +91 | -5 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: aborting due to 27 previous errors diff --git a/tests/ui/issue-3145.stderr b/tests/ui/issue-3145.stderr index 2086f11463f..6f9f88a8d67 100644 --- a/tests/ui/issue-3145.stderr +++ b/tests/ui/issue-3145.stderr @@ -1,7 +1,7 @@ error: expected token: `,` - --> $DIR/issue-3145.rs:12:19 + --> $DIR/issue-3145.rs:11:19 | -12 | println!("{}" a); //~ERROR expected token: `,` +11 | println!("{}" a); //~ERROR expected token: `,` | ^ error: aborting due to previous error diff --git a/tests/ui/issue_2356.stderr b/tests/ui/issue_2356.stderr index 291e64bec6f..28b67cbc9fa 100644 --- a/tests/ui/issue_2356.stderr +++ b/tests/ui/issue_2356.stderr @@ -1,13 +1,13 @@ error: this loop could be written as a `for` loop - --> $DIR/issue_2356.rs:27:29 + --> $DIR/issue_2356.rs:24:29 | -27 | while let Some(e) = it.next() { +24 | while let Some(e) = it.next() { | ^^^^^^^^^ help: try: `for e in it { .. }` | note: lint level defined here - --> $DIR/issue_2356.rs:13:9 + --> $DIR/issue_2356.rs:10:9 | -13 | #![deny(clippy::while_let_on_iterator)] +10 | #![deny(clippy::while_let_on_iterator)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/item_after_statement.stderr b/tests/ui/item_after_statement.stderr index 15c0cc3af4c..c988fca3827 100644 --- a/tests/ui/item_after_statement.stderr +++ b/tests/ui/item_after_statement.stderr @@ -1,16 +1,20 @@ error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/item_after_statement.rs:22:5 + --> $DIR/item_after_statement.rs:21:5 | -22 | fn foo() { println!("foo"); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +21 | / fn foo() { +22 | | println!("foo"); +23 | | } + | |_____^ | = note: `-D clippy::items-after-statements` implied by `-D warnings` error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/item_after_statement.rs:27:5 + --> $DIR/item_after_statement.rs:28:5 | -27 | fn foo() { println!("foo"); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +28 | / fn foo() { +29 | | println!("foo"); +30 | | } + | |_____^ error: aborting due to 2 previous errors diff --git a/tests/ui/large_digit_groups.stderr b/tests/ui/large_digit_groups.stderr index c38abb8887c..47587f5423a 100644 --- a/tests/ui/large_digit_groups.stderr +++ b/tests/ui/large_digit_groups.stderr @@ -1,40 +1,40 @@ error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:16 + --> $DIR/large_digit_groups.rs:24:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^^^ help: consider: `0b11_0110_i64` +24 | 0b1_10110_i64, + | ^^^^^^^^^^^^^ help: consider: `0b11_0110_i64` | = note: `-D clippy::large-digit-groups` implied by `-D warnings` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:31 + --> $DIR/large_digit_groups.rs:25:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` +25 | 0x1_23456_78901_usize, + | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:54 + --> $DIR/large_digit_groups.rs:26:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^ help: consider: `123_456_f32` +26 | 1_23456_f32, + | ^^^^^^^^^^^ help: consider: `123_456_f32` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:67 + --> $DIR/large_digit_groups.rs:27:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^^^^ help: consider: `123_456.12_f32` +27 | 1_23456.12_f32, + | ^^^^^^^^^^^^^^ help: consider: `123_456.12_f32` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:83 + --> $DIR/large_digit_groups.rs:28:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_45_f32` +28 | 1_23456.12345_f32, + | ^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_45_f32` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:102 + --> $DIR/large_digit_groups.rs:29:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_456_f32` +29 | 1_23456.12345_6_f32, + | ^^^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_456_f32` error: aborting due to 6 previous errors diff --git a/tests/ui/large_enum_variant.stderr b/tests/ui/large_enum_variant.stderr index 4bb25dd855a..c9c46ced5e2 100644 --- a/tests/ui/large_enum_variant.stderr +++ b/tests/ui/large_enum_variant.stderr @@ -1,69 +1,69 @@ error: large size difference between variants - --> $DIR/large_enum_variant.rs:20:5 + --> $DIR/large_enum_variant.rs:16:5 | -20 | B([i32; 8000]), +16 | B([i32; 8000]), | ^^^^^^^^^^^^^^ | = note: `-D clippy::large-enum-variant` implied by `-D warnings` help: consider boxing the large fields to reduce the total size of the enum | -20 | B(Box<[i32; 8000]>), +16 | B(Box<[i32; 8000]>), | ^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:31:5 + --> $DIR/large_enum_variant.rs:27:5 | -31 | C(T, [i32; 8000]), +27 | C(T, [i32; 8000]), | ^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:31:5 + --> $DIR/large_enum_variant.rs:27:5 | -31 | C(T, [i32; 8000]), +27 | C(T, [i32; 8000]), | ^^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:44:5 + --> $DIR/large_enum_variant.rs:40:5 | -44 | ContainingLargeEnum(LargeEnum), +40 | ContainingLargeEnum(LargeEnum), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum | -44 | ContainingLargeEnum(Box), +40 | ContainingLargeEnum(Box), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:47:5 + --> $DIR/large_enum_variant.rs:43:5 | -47 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), +43 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:47:5 + --> $DIR/large_enum_variant.rs:43:5 | -47 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), +43 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:54:5 + --> $DIR/large_enum_variant.rs:50:5 | -54 | StructLikeLarge { x: [i32; 8000], y: i32 }, +50 | StructLikeLarge { x: [i32; 8000], y: i32 }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:54:5 + --> $DIR/large_enum_variant.rs:50:5 | -54 | StructLikeLarge { x: [i32; 8000], y: i32 }, +50 | StructLikeLarge { x: [i32; 8000], y: i32 }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:59:5 + --> $DIR/large_enum_variant.rs:55:5 | -59 | StructLikeLarge2 { x: [i32; 8000] }, +55 | StructLikeLarge2 { x: [i32; 8000] }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum | -59 | StructLikeLarge2 { x: Box<[i32; 8000]> }, +55 | StructLikeLarge2 { x: Box<[i32; 8000]> }, | ^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index 1f937bafdef..bc5cd0e595b 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -1,139 +1,139 @@ error: item `PubOne` has a public `len` method but no corresponding `is_empty` method - --> $DIR/len_zero.rs:18:1 + --> $DIR/len_zero.rs:15:1 | -18 | / impl PubOne { -19 | | pub fn len(self: &Self) -> isize { -20 | | 1 -21 | | } -22 | | } +15 | / impl PubOne { +16 | | pub fn len(self: &Self) -> isize { +17 | | 1 +18 | | } +19 | | } | |_^ | = note: `-D clippy::len-without-is-empty` implied by `-D warnings` error: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_zero.rs:67:1 + --> $DIR/len_zero.rs:64:1 | -67 | / pub trait PubTraitsToo { -68 | | fn len(self: &Self) -> isize; -69 | | } +64 | / pub trait PubTraitsToo { +65 | | fn len(self: &Self) -> isize; +66 | | } | |_^ error: item `HasIsEmpty` has a public `len` method but a private `is_empty` method - --> $DIR/len_zero.rs:101:1 + --> $DIR/len_zero.rs:98:1 | -101 | / impl HasIsEmpty { -102 | | pub fn len(self: &Self) -> isize { -103 | | 1 -104 | | } +98 | / impl HasIsEmpty { +99 | | pub fn len(self: &Self) -> isize { +100 | | 1 +101 | | } ... | -108 | | } -109 | | } +105 | | } +106 | | } | |_^ error: item `HasWrongIsEmpty` has a public `len` method but no corresponding `is_empty` method - --> $DIR/len_zero.rs:130:1 + --> $DIR/len_zero.rs:127:1 | -130 | / impl HasWrongIsEmpty { -131 | | pub fn len(self: &Self) -> isize { -132 | | 1 -133 | | } +127 | / impl HasWrongIsEmpty { +128 | | pub fn len(self: &Self) -> isize { +129 | | 1 +130 | | } ... | -137 | | } -138 | | } +134 | | } +135 | | } | |_^ error: length comparison to zero - --> $DIR/len_zero.rs:151:8 + --> $DIR/len_zero.rs:148:8 | -151 | if x.len() == 0 { +148 | if x.len() == 0 { | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `x.is_empty()` | = note: `-D clippy::len-zero` implied by `-D warnings` error: length comparison to zero - --> $DIR/len_zero.rs:155:8 + --> $DIR/len_zero.rs:152:8 | -155 | if "".len() == 0 {} +152 | if "".len() == 0 {} | ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `"".is_empty()` +error: length comparison to zero + --> $DIR/len_zero.rs:167:8 + | +167 | if has_is_empty.len() == 0 { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` + error: length comparison to zero --> $DIR/len_zero.rs:170:8 | -170 | if has_is_empty.len() == 0 { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` +170 | if has_is_empty.len() != 0 { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero --> $DIR/len_zero.rs:173:8 | -173 | if has_is_empty.len() != 0 { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` +173 | if has_is_empty.len() > 0 { + | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` -error: length comparison to zero +error: length comparison to one --> $DIR/len_zero.rs:176:8 | -176 | if has_is_empty.len() > 0 { - | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` +176 | if has_is_empty.len() < 1 { + | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to one --> $DIR/len_zero.rs:179:8 | -179 | if has_is_empty.len() < 1 { - | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` - -error: length comparison to one - --> $DIR/len_zero.rs:182:8 - | -182 | if has_is_empty.len() >= 1 { +179 | if has_is_empty.len() >= 1 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` +error: length comparison to zero + --> $DIR/len_zero.rs:190:8 + | +190 | if 0 == has_is_empty.len() { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` + error: length comparison to zero --> $DIR/len_zero.rs:193:8 | -193 | if 0 == has_is_empty.len() { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` +193 | if 0 != has_is_empty.len() { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero --> $DIR/len_zero.rs:196:8 | -196 | if 0 != has_is_empty.len() { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` +196 | if 0 < has_is_empty.len() { + | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` -error: length comparison to zero +error: length comparison to one --> $DIR/len_zero.rs:199:8 | -199 | if 0 < has_is_empty.len() { - | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` +199 | if 1 <= has_is_empty.len() { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one --> $DIR/len_zero.rs:202:8 | -202 | if 1 <= has_is_empty.len() { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` - -error: length comparison to one - --> $DIR/len_zero.rs:205:8 - | -205 | if 1 > has_is_empty.len() { +202 | if 1 > has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:219:8 + --> $DIR/len_zero.rs:216:8 | -219 | if with_is_empty.len() == 0 { +216 | if with_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `with_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:232:8 + --> $DIR/len_zero.rs:229:8 | -232 | if b.len() != 0 {} +229 | if b.len() != 0 {} | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!b.is_empty()` error: trait `DependsOnFoo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_zero.rs:238:1 + --> $DIR/len_zero.rs:235:1 | -238 | / pub trait DependsOnFoo: Foo { -239 | | fn len(&mut self) -> usize; -240 | | } +235 | / pub trait DependsOnFoo: Foo { +236 | | fn len(&mut self) -> usize; +237 | | } | |_^ error: aborting due to 19 previous errors diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index 6e2ec6d4aaa..91acf6dcb30 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -1,47 +1,47 @@ error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:67:5 + --> $DIR/let_if_seq.rs:72:5 | -67 | / let mut foo = 0; -68 | | if f() { -69 | | foo = 42; -70 | | } +72 | / let mut foo = 0; +73 | | if f() { +74 | | foo = 42; +75 | | } | |_____^ help: it is more idiomatic to write: `let foo = if f() { 42 } else { 0 };` | = note: `-D clippy::useless-let-if-seq` implied by `-D warnings` = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:72:5 + --> $DIR/let_if_seq.rs:77:5 | -72 | / let mut bar = 0; -73 | | if f() { -74 | | f(); -75 | | bar = 42; -... | -78 | | f(); -79 | | } +77 | / let mut bar = 0; +78 | | if f() { +79 | | f(); +80 | | bar = 42; +81 | | } else { +82 | | f(); +83 | | } | |_____^ help: it is more idiomatic to write: `let bar = if f() { ..; 42 } else { ..; 0 };` | = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:81:5 + --> $DIR/let_if_seq.rs:85:5 | -81 | / let quz; -82 | | if f() { -83 | | quz = 42; -84 | | } else { -85 | | quz = 0; -86 | | } +85 | / let quz; +86 | | if f() { +87 | | quz = 42; +88 | | } else { +89 | | quz = 0; +90 | | } | |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };` error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:110:5 + --> $DIR/let_if_seq.rs:114:5 | -110 | / let mut baz = 0; -111 | | if f() { -112 | | baz = 42; -113 | | } +114 | / let mut baz = 0; +115 | | if f() { +116 | | baz = 42; +117 | | } | |_____^ help: it is more idiomatic to write: `let baz = if f() { 42 } else { 0 };` | = note: you might not need `mut` at all diff --git a/tests/ui/let_return.stderr b/tests/ui/let_return.stderr index cdd4b6bd537..894c15c2d6d 100644 --- a/tests/ui/let_return.stderr +++ b/tests/ui/let_return.stderr @@ -1,26 +1,26 @@ error: returning the result of a let binding from a block. Consider returning the expression directly. - --> $DIR/let_return.rs:20:5 + --> $DIR/let_return.rs:16:5 | -20 | x +16 | x | ^ | = note: `-D clippy::let-and-return` implied by `-D warnings` note: this expression can be directly returned - --> $DIR/let_return.rs:19:13 + --> $DIR/let_return.rs:15:13 | -19 | let x = 5; +15 | let x = 5; | ^ error: returning the result of a let binding from a block. Consider returning the expression directly. - --> $DIR/let_return.rs:26:9 + --> $DIR/let_return.rs:22:9 | -26 | x +22 | x | ^ | note: this expression can be directly returned - --> $DIR/let_return.rs:25:17 + --> $DIR/let_return.rs:21:17 | -25 | let x = 5; +21 | let x = 5; | ^ error: aborting due to 2 previous errors diff --git a/tests/ui/let_unit.stderr b/tests/ui/let_unit.stderr index e8c7bb37e73..a8771dd5f47 100644 --- a/tests/ui/let_unit.stderr +++ b/tests/ui/let_unit.stderr @@ -1,15 +1,15 @@ error: this let-binding has unit value. Consider omitting `let _x =` - --> $DIR/let_unit.rs:24:5 + --> $DIR/let_unit.rs:20:5 | -24 | let _x = println!("x"); +20 | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::let-unit-value` implied by `-D warnings` error: this let-binding has unit value. Consider omitting `let _a =` - --> $DIR/let_unit.rs:28:9 + --> $DIR/let_unit.rs:24:9 | -28 | let _a = (); +24 | let _a = (); | ^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/lifetimes.stderr b/tests/ui/lifetimes.stderr index 46dbf6cce09..5bddf5aa746 100644 --- a/tests/ui/lifetimes.stderr +++ b/tests/ui/lifetimes.stderr @@ -1,96 +1,122 @@ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:17:1 + --> $DIR/lifetimes.rs:13:1 | -17 | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::needless-lifetimes` implied by `-D warnings` error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:19:1 + --> $DIR/lifetimes.rs:15:1 | -19 | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:27:1 - | -27 | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { x } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:39:1 - | -39 | fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { Ok(x) } +15 | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:42:1 + --> $DIR/lifetimes.rs:23:1 | -42 | fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> where T: Copy { Ok(x) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +23 | / fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { +24 | | x +25 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:48:1 + --> $DIR/lifetimes.rs:47:1 | -48 | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +47 | / fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { +48 | | Ok(x) +49 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:62:1 + --> $DIR/lifetimes.rs:52:1 | -62 | / fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> -63 | | where for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I> -64 | | { unreachable!() } - | |__________________^ +52 | / fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> +53 | | where +54 | | T: Copy, +55 | | { +56 | | Ok(x) +57 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:87:5 + --> $DIR/lifetimes.rs:63:1 | -87 | fn self_and_out<'s>(&'s self) -> &'s u8 { &self.x } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +63 | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:91:5 + --> $DIR/lifetimes.rs:84:1 | -91 | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +84 | / fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> +85 | | where +86 | | for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I>, +87 | | { +88 | | unreachable!() +89 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:107:1 + --> $DIR/lifetimes.rs:117:5 | -107 | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +117 | / fn self_and_out<'s>(&'s self) -> &'s u8 { +118 | | &self.x +119 | | } + | |_____^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:127:1 + --> $DIR/lifetimes.rs:125:5 | -127 | fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +125 | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:131:1 + --> $DIR/lifetimes.rs:141:1 | -131 | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +141 | / fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { +142 | | unimplemented!() +143 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:142:1 + --> $DIR/lifetimes.rs:171:1 | -142 | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +171 | / fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { +172 | | unimplemented!() +173 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:146:1 + --> $DIR/lifetimes.rs:177:1 | -146 | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +177 | / fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { +178 | | unimplemented!() +179 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:176:1 + --> $DIR/lifetimes.rs:196:1 | -176 | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +196 | / fn named_input_elided_output<'a>(_arg: &'a str) -> &str { +197 | | unimplemented!() +198 | | } + | |_^ + +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) + --> $DIR/lifetimes.rs:204:1 + | +204 | / fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { +205 | | unimplemented!() +206 | | } + | |_^ + +error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) + --> $DIR/lifetimes.rs:241:1 + | +241 | / fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { +242 | | unimplemented!() +243 | | } + | |_^ error: aborting due to 15 previous errors diff --git a/tests/ui/lint_without_lint_pass.stderr b/tests/ui/lint_without_lint_pass.stderr index 65d1283a6e3..d0d65df21f0 100644 --- a/tests/ui/lint_without_lint_pass.stderr +++ b/tests/ui/lint_without_lint_pass.stderr @@ -1,11 +1,11 @@ error: the lint `TEST_LINT` is not added to any `LintPass` - --> $DIR/lint_without_lint_pass.rs:12:1 + --> $DIR/lint_without_lint_pass.rs:11:1 | -12 | / declare_clippy_lint! { -13 | | pub TEST_LINT, -14 | | correctness, -15 | | "" -16 | | } +11 | / declare_clippy_lint! { +12 | | pub TEST_LINT, +13 | | correctness, +14 | | "" +15 | | } | |_^ | note: lint level defined here diff --git a/tests/ui/map_clone.stderr b/tests/ui/map_clone.stderr index 50856f6a937..603819de16e 100644 --- a/tests/ui/map_clone.stderr +++ b/tests/ui/map_clone.stderr @@ -1,21 +1,21 @@ error: You are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:16:22 + --> $DIR/map_clone.rs:14:22 | -16 | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); +14 | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![5_i8; 6].iter().cloned()` | = note: `-D clippy::map-clone` implied by `-D warnings` error: You are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:17:26 + --> $DIR/map_clone.rs:15:26 | -17 | let _: Vec = vec![String::new()].iter().map(|x| x.clone()).collect(); +15 | let _: Vec = vec![String::new()].iter().map(|x| x.clone()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()` error: You are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:18:23 + --> $DIR/map_clone.rs:16:23 | -18 | let _: Vec = vec![42, 43].iter().map(|&x| x).collect(); +16 | let _: Vec = vec![42, 43].iter().map(|&x| x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![42, 43].iter().cloned()` error: aborting due to 3 previous errors diff --git a/tests/ui/map_flatten.stderr b/tests/ui/map_flatten.stderr index d41e6297758..488797173f6 100644 --- a/tests/ui/map_flatten.stderr +++ b/tests/ui/map_flatten.stderr @@ -1,7 +1,7 @@ error: called `map(..).flatten()` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` - --> $DIR/map_flatten.rs:16:21 + --> $DIR/map_flatten.rs:14:21 | -16 | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect(); +14 | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using flat_map instead: `vec![5_i8; 6].into_iter().flat_map(|x| 0..x)` | = note: `-D clippy::map-flatten` implied by `-D warnings` diff --git a/tests/ui/match_bool.stderr b/tests/ui/match_bool.stderr index 9bef0d823e2..a073f995498 100644 --- a/tests/ui/match_bool.stderr +++ b/tests/ui/match_bool.stderr @@ -1,74 +1,109 @@ error: this boolean expression can be simplified - --> $DIR/match_bool.rs:35:11 + --> $DIR/match_bool.rs:38:11 | -35 | match test && test { +38 | match test && test { | ^^^^^^^^^^^^ help: try: `test` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:14:5 + --> $DIR/match_bool.rs:13:5 | -14 | / match test { -15 | | true => 0, -16 | | false => 42, -17 | | }; +13 | / match test { +14 | | true => 0, +15 | | false => 42, +16 | | }; | |_____^ help: consider using an if/else expression: `if test { 0 } else { 42 }` | = note: `-D clippy::match-bool` implied by `-D warnings` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:20:5 + --> $DIR/match_bool.rs:19:5 | -20 | / match option == 1 { -21 | | true => 1, -22 | | false => 0, -23 | | }; +19 | / match option == 1 { +20 | | true => 1, +21 | | false => 0, +22 | | }; | |_____^ help: consider using an if/else expression: `if option == 1 { 1 } else { 0 }` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:25:5 + --> $DIR/match_bool.rs:24:5 + | +24 | / match test { +25 | | true => (), +26 | | false => { +27 | | println!("Noooo!"); +28 | | }, +29 | | }; + | |_____^ +help: consider using an if/else expression + | +24 | if !test { +25 | println!("Noooo!"); +26 | }; | -25 | / match test { -26 | | true => (), -27 | | false => { println!("Noooo!"); } -28 | | }; - | |_____^ help: consider using an if/else expression: `if !test { println!("Noooo!"); }` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:30:5 + --> $DIR/match_bool.rs:31:5 + | +31 | / match test { +32 | | false => { +33 | | println!("Noooo!"); +34 | | }, +35 | | _ => (), +36 | | }; + | |_____^ +help: consider using an if/else expression + | +31 | if !test { +32 | println!("Noooo!"); +33 | }; | -30 | / match test { -31 | | false => { println!("Noooo!"); } -32 | | _ => (), -33 | | }; - | |_____^ help: consider using an if/else expression: `if !test { println!("Noooo!"); }` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:35:5 + --> $DIR/match_bool.rs:38:5 + | +38 | / match test && test { +39 | | false => { +40 | | println!("Noooo!"); +41 | | }, +42 | | _ => (), +43 | | }; + | |_____^ +help: consider using an if/else expression + | +38 | if !(test && test) { +39 | println!("Noooo!"); +40 | }; | -35 | / match test && test { -36 | | false => { println!("Noooo!"); } -37 | | _ => (), -38 | | }; - | |_____^ help: consider using an if/else expression: `if !(test && test) { println!("Noooo!"); }` error: equal expressions as operands to `&&` - --> $DIR/match_bool.rs:35:11 + --> $DIR/match_bool.rs:38:11 | -35 | match test && test { +38 | match test && test { | ^^^^^^^^^^^^ | = note: #[deny(clippy::eq_op)] on by default error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:40:5 + --> $DIR/match_bool.rs:45:5 + | +45 | / match test { +46 | | false => { +47 | | println!("Noooo!"); +48 | | }, +... | +51 | | }, +52 | | }; + | |_____^ +help: consider using an if/else expression + | +45 | if test { +46 | println!("Yes!"); +47 | } else { +48 | println!("Noooo!"); +49 | }; | -40 | / match test { -41 | | false => { println!("Noooo!"); } -42 | | true => { println!("Yes!"); } -43 | | }; - | |_____^ help: consider using an if/else expression: `if test { println!("Yes!"); } else { println!("Noooo!"); }` error: aborting due to 8 previous errors diff --git a/tests/ui/match_overlapping_arm.stderr b/tests/ui/match_overlapping_arm.stderr index 4f9d8ac7683..ef8fc08f95b 100644 --- a/tests/ui/match_overlapping_arm.stderr +++ b/tests/ui/match_overlapping_arm.stderr @@ -1,33 +1,33 @@ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:20:9 | -20 | 0 ... 10 => println!("0 ... 10"), - | ^^^^^^^^ +20 | 0...10 => println!("0 ... 10"), + | ^^^^^^ | = note: `-D clippy::match-overlapping-arm` implied by `-D warnings` note: overlaps with this --> $DIR/match_overlapping_arm.rs:21:9 | -21 | 0 ... 11 => println!("0 ... 11"), - | ^^^^^^^^ +21 | 0...11 => println!("0 ... 11"), + | ^^^^^^ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:26:9 | -26 | 0 ... 5 => println!("0 ... 5"), - | ^^^^^^^ +26 | 0...5 => println!("0 ... 5"), + | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:28:9 | -28 | FOO ... 11 => println!("0 ... 11"), - | ^^^^^^^^^^ +28 | FOO...11 => println!("0 ... 11"), + | ^^^^^^^^ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:34:9 | -34 | 0 ... 5 => println!("0 ... 5"), - | ^^^^^^^ +34 | 0...5 => println!("0 ... 5"), + | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:33:9 @@ -38,8 +38,8 @@ note: overlaps with this error: some ranges overlap --> $DIR/match_overlapping_arm.rs:40:9 | -40 | 0 ... 2 => println!("0 ... 2"), - | ^^^^^^^ +40 | 0...2 => println!("0 ... 2"), + | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:39:9 @@ -50,14 +50,14 @@ note: overlaps with this error: some ranges overlap --> $DIR/match_overlapping_arm.rs:63:9 | -63 | 0 .. 11 => println!("0 .. 11"), - | ^^^^^^^ +63 | 0..11 => println!("0 .. 11"), + | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:64:9 | -64 | 0 ... 11 => println!("0 ... 11"), - | ^^^^^^^^ +64 | 0...11 => println!("0 ... 11"), + | ^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index 53e61efa83a..3ed70168c6e 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -1,281 +1,281 @@ error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:26:9 + --> $DIR/matches.rs:20:9 | -26 | / match v { -27 | | &Some(v) => println!("{:?}", v), -28 | | &None => println!("none"), -29 | | } +20 | / match v { +21 | | &Some(v) => println!("{:?}", v), +22 | | &None => println!("none"), +23 | | } | |_________^ | = note: `-D clippy::match-ref-pats` implied by `-D warnings` help: instead of prefixing all patterns with `&`, you can dereference the expression | -26 | match *v { -27 | Some(v) => println!("{:?}", v), -28 | None => println!("none"), +20 | match *v { +21 | Some(v) => println!("{:?}", v), +22 | None => println!("none"), | error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:36:5 + --> $DIR/matches.rs:31:5 | -36 | / match tup { -37 | | &(v, 1) => println!("{}", v), -38 | | _ => println!("none"), -39 | | } +31 | / match tup { +32 | | &(v, 1) => println!("{}", v), +33 | | _ => println!("none"), +34 | | } | |_____^ help: instead of prefixing all patterns with `&`, you can dereference the expression | -36 | match *tup { -37 | (v, 1) => println!("{}", v), +31 | match *tup { +32 | (v, 1) => println!("{}", v), | error: you don't need to add `&` to both the expression and the patterns - --> $DIR/matches.rs:42:5 + --> $DIR/matches.rs:37:5 | -42 | / match &w { -43 | | &Some(v) => println!("{:?}", v), -44 | | &None => println!("none"), -45 | | } +37 | / match &w { +38 | | &Some(v) => println!("{:?}", v), +39 | | &None => println!("none"), +40 | | } | |_____^ help: try | -42 | match w { -43 | Some(v) => println!("{:?}", v), -44 | None => println!("none"), +37 | match w { +38 | Some(v) => println!("{:?}", v), +39 | None => println!("none"), | error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:53:5 + --> $DIR/matches.rs:48:5 | -53 | / if let &None = a { -54 | | println!("none"); -55 | | } +48 | / if let &None = a { +49 | | println!("none"); +50 | | } | |_____^ help: instead of prefixing all patterns with `&`, you can dereference the expression | -53 | if let None = *a { +48 | if let None = *a { | ^^^^ ^^ error: you don't need to add `&` to both the expression and the patterns - --> $DIR/matches.rs:58:5 + --> $DIR/matches.rs:53:5 | -58 | / if let &None = &b { -59 | | println!("none"); -60 | | } +53 | / if let &None = &b { +54 | | println!("none"); +55 | | } | |_____^ help: try | -58 | if let None = b { +53 | if let None = b { | ^^^^ ^ error: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:69:9 + --> $DIR/matches.rs:64:9 | -69 | Err(_) => panic!("err") +64 | Err(_) => panic!("err"), | ^^^^^^ | = note: `-D clippy::match-wild-err-arm` implied by `-D warnings` = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies - --> $DIR/matches.rs:68:18 + --> $DIR/matches.rs:63:18 | -68 | Ok(_) => println!("ok"), +63 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this - --> $DIR/matches.rs:67:18 + --> $DIR/matches.rs:62:18 | -67 | Ok(3) => println!("ok"), +62 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:67:18 + --> $DIR/matches.rs:62:18 | -67 | Ok(3) => println!("ok"), +62 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:75:9 + --> $DIR/matches.rs:70:9 | -75 | Err(_) => {panic!()} +70 | Err(_) => panic!(), | ^^^^^^ | = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies + --> $DIR/matches.rs:69:18 + | +69 | Ok(_) => println!("ok"), + | ^^^^^^^^^^^^^^ + | +note: same as this + --> $DIR/matches.rs:68:18 + | +68 | Ok(3) => println!("ok"), + | ^^^^^^^^^^^^^^ +note: consider refactoring into `Ok(3) | Ok(_)` + --> $DIR/matches.rs:68:18 + | +68 | Ok(3) => println!("ok"), + | ^^^^^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: Err(_) will match all errors, maybe not a good idea + --> $DIR/matches.rs:76:9 + | +76 | Err(_) => { + | ^^^^^^ + | + = note: to remove this warning, match each error separately or use unreachable macro + +error: this `match` has identical arm bodies + --> $DIR/matches.rs:75:18 + | +75 | Ok(_) => println!("ok"), + | ^^^^^^^^^^^^^^ + | +note: same as this --> $DIR/matches.rs:74:18 | -74 | Ok(_) => println!("ok"), - | ^^^^^^^^^^^^^^ - | -note: same as this - --> $DIR/matches.rs:73:18 - | -73 | Ok(3) => println!("ok"), +74 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:73:18 + --> $DIR/matches.rs:74:18 | -73 | Ok(3) => println!("ok"), - | ^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:81:9 - | -81 | Err(_) => {panic!();} - | ^^^^^^ - | - = note: to remove this warning, match each error separately or use unreachable macro - -error: this `match` has identical arm bodies - --> $DIR/matches.rs:80:18 - | -80 | Ok(_) => println!("ok"), - | ^^^^^^^^^^^^^^ - | -note: same as this - --> $DIR/matches.rs:79:18 - | -79 | Ok(3) => println!("ok"), - | ^^^^^^^^^^^^^^ -note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:79:18 - | -79 | Ok(3) => println!("ok"), +74 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:87:18 + --> $DIR/matches.rs:84:18 | -87 | Ok(_) => println!("ok"), +84 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:86:18 + --> $DIR/matches.rs:83:18 | -86 | Ok(3) => println!("ok"), +83 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:86:18 + --> $DIR/matches.rs:83:18 | -86 | Ok(3) => println!("ok"), +83 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:94:18 + --> $DIR/matches.rs:91:18 | -94 | Ok(_) => println!("ok"), +91 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:93:18 + --> $DIR/matches.rs:90:18 | -93 | Ok(3) => println!("ok"), +90 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:93:18 + --> $DIR/matches.rs:90:18 | -93 | Ok(3) => println!("ok"), +90 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:100:18 + --> $DIR/matches.rs:97:18 + | +97 | Ok(_) => println!("ok"), + | ^^^^^^^^^^^^^^ + | +note: same as this + --> $DIR/matches.rs:96:18 + | +96 | Ok(3) => println!("ok"), + | ^^^^^^^^^^^^^^ +note: consider refactoring into `Ok(3) | Ok(_)` + --> $DIR/matches.rs:96:18 + | +96 | Ok(3) => println!("ok"), + | ^^^^^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: this `match` has identical arm bodies + --> $DIR/matches.rs:103:18 | -100 | Ok(_) => println!("ok"), +103 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:99:18 + --> $DIR/matches.rs:102:18 | -99 | Ok(3) => println!("ok"), +102 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:99:18 + --> $DIR/matches.rs:102:18 | -99 | Ok(3) => println!("ok"), +102 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:106:18 + --> $DIR/matches.rs:126:29 | -106 | Ok(_) => println!("ok"), - | ^^^^^^^^^^^^^^ - | -note: same as this - --> $DIR/matches.rs:105:18 - | -105 | Ok(3) => println!("ok"), - | ^^^^^^^^^^^^^^ -note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:105:18 - | -105 | Ok(3) => println!("ok"), - | ^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error: this `match` has identical arm bodies - --> $DIR/matches.rs:127:29 - | -127 | (Ok(_), Some(x)) => println!("ok {}", x), +126 | (Ok(_), Some(x)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:126:29 + --> $DIR/matches.rs:125:29 | -126 | (Ok(x), Some(_)) => println!("ok {}", x), +125 | (Ok(x), Some(_)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^ note: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))` - --> $DIR/matches.rs:126:29 + --> $DIR/matches.rs:125:29 | -126 | (Ok(x), Some(_)) => println!("ok {}", x), +125 | (Ok(x), Some(_)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:142:18 + --> $DIR/matches.rs:141:18 | -142 | Ok(_) => println!("ok"), +141 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:141:18 + --> $DIR/matches.rs:140:18 | -141 | Ok(3) => println!("ok"), +140 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:141:18 + --> $DIR/matches.rs:140:18 | -141 | Ok(3) => println!("ok"), +140 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: use as_ref() instead - --> $DIR/matches.rs:149:33 + --> $DIR/matches.rs:150:33 | -149 | let borrowed: Option<&()> = match owned { +150 | let borrowed: Option<&()> = match owned { | _________________________________^ -150 | | None => None, -151 | | Some(ref v) => Some(v), -152 | | }; +151 | | None => None, +152 | | Some(ref v) => Some(v), +153 | | }; | |_____^ help: try this: `owned.as_ref()` | = note: `-D clippy::match-as-ref` implied by `-D warnings` error: use as_mut() instead - --> $DIR/matches.rs:155:39 + --> $DIR/matches.rs:156:39 | -155 | let borrow_mut: Option<&mut ()> = match mut_owned { +156 | let borrow_mut: Option<&mut ()> = match mut_owned { | _______________________________________^ -156 | | None => None, -157 | | Some(ref mut v) => Some(v), -158 | | }; +157 | | None => None, +158 | | Some(ref mut v) => Some(v), +159 | | }; | |_____^ help: try this: `mut_owned.as_mut()` error: aborting due to 19 previous errors diff --git a/tests/ui/mem_discriminant.stderr b/tests/ui/mem_discriminant.stderr index 6414e4c96d6..a00f7ab30e1 100644 --- a/tests/ui/mem_discriminant.stderr +++ b/tests/ui/mem_discriminant.stderr @@ -1,101 +1,101 @@ error: calling `mem::discriminant` on non-enum type `&str` - --> $DIR/mem_discriminant.rs:24:5 + --> $DIR/mem_discriminant.rs:23:5 | -24 | mem::discriminant(&"hello"); +23 | mem::discriminant(&"hello"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/mem_discriminant.rs:11:9 + --> $DIR/mem_discriminant.rs:10:9 | -11 | #![deny(clippy::mem_discriminant_non_enum)] +10 | #![deny(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:25:5 + --> $DIR/mem_discriminant.rs:24:5 | -25 | mem::discriminant(&&Some(2)); +24 | mem::discriminant(&&Some(2)); | ^^^^^^^^^^^^^^^^^^---------^ | | | help: try dereferencing: `&Some(2)` error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:26:5 + --> $DIR/mem_discriminant.rs:25:5 | -26 | mem::discriminant(&&None::); +25 | mem::discriminant(&&None::); | ^^^^^^^^^^^^^^^^^^------------^ | | | help: try dereferencing: `&None::` error: calling `mem::discriminant` on non-enum type `&Foo` - --> $DIR/mem_discriminant.rs:27:5 + --> $DIR/mem_discriminant.rs:26:5 | -27 | mem::discriminant(&&Foo::One(5)); +26 | mem::discriminant(&&Foo::One(5)); | ^^^^^^^^^^^^^^^^^^-------------^ | | | help: try dereferencing: `&Foo::One(5)` error: calling `mem::discriminant` on non-enum type `&Foo` - --> $DIR/mem_discriminant.rs:28:5 + --> $DIR/mem_discriminant.rs:27:5 | -28 | mem::discriminant(&&Foo::Two(5)); +27 | mem::discriminant(&&Foo::Two(5)); | ^^^^^^^^^^^^^^^^^^-------------^ | | | help: try dereferencing: `&Foo::Two(5)` error: calling `mem::discriminant` on non-enum type `A` - --> $DIR/mem_discriminant.rs:29:5 + --> $DIR/mem_discriminant.rs:28:5 | -29 | mem::discriminant(&A(Foo::One(0))); +28 | mem::discriminant(&A(Foo::One(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:33:5 + --> $DIR/mem_discriminant.rs:32:5 | -33 | mem::discriminant(&ro); +32 | mem::discriminant(&ro); | ^^^^^^^^^^^^^^^^^^---^ | | | help: try dereferencing: `ro` error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:34:5 + --> $DIR/mem_discriminant.rs:33:5 | -34 | mem::discriminant(rro); +33 | mem::discriminant(rro); | ^^^^^^^^^^^^^^^^^^---^ | | | help: try dereferencing: `*rro` error: calling `mem::discriminant` on non-enum type `&&std::option::Option` - --> $DIR/mem_discriminant.rs:35:5 + --> $DIR/mem_discriminant.rs:34:5 | -35 | mem::discriminant(&rro); +34 | mem::discriminant(&rro); | ^^^^^^^^^^^^^^^^^^----^ | | | help: try dereferencing: `*rro` error: calling `mem::discriminant` on non-enum type `&&std::option::Option` - --> $DIR/mem_discriminant.rs:38:27 + --> $DIR/mem_discriminant.rs:38:13 | -38 | ($param:expr) => (mem::discriminant($param)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +38 | mem::discriminant($param) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ ... -41 | mem_discriminant_but_in_a_macro!(&rro); +42 | mem_discriminant_but_in_a_macro!(&rro); | --------------------------------------- | | | | | help: try dereferencing: `*rro` | in this macro invocation error: calling `mem::discriminant` on non-enum type `&&&&&std::option::Option` - --> $DIR/mem_discriminant.rs:44:5 + --> $DIR/mem_discriminant.rs:45:5 | -44 | mem::discriminant(&rrrrro); +45 | mem::discriminant(&rrrrro); | ^^^^^^^^^^^^^^^^^^-------^ | | | help: try dereferencing: `****rrrrro` error: calling `mem::discriminant` on non-enum type `&&&std::option::Option` - --> $DIR/mem_discriminant.rs:45:5 + --> $DIR/mem_discriminant.rs:46:5 | -45 | mem::discriminant(*rrrrro); +46 | mem::discriminant(*rrrrro); | ^^^^^^^^^^^^^^^^^^-------^ | | | help: try dereferencing: `****rrrrro` diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index 06ac6a3679d..479cd4934ab 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -1,21 +1,21 @@ error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:28:5 + --> $DIR/mem_forget.rs:23:5 | -28 | memstuff::forget(six); +23 | memstuff::forget(six); | ^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::mem-forget` implied by `-D warnings` error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:31:5 + --> $DIR/mem_forget.rs:26:5 | -31 | std::mem::forget(seven); +26 | std::mem::forget(seven); | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:34:5 + --> $DIR/mem_forget.rs:29:5 | -34 | forgetSomething(eight); +29 | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/mem_replace.stderr b/tests/ui/mem_replace.stderr index 64a1690156c..06d8f5f74c0 100644 --- a/tests/ui/mem_replace.stderr +++ b/tests/ui/mem_replace.stderr @@ -1,15 +1,15 @@ error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:18:13 + --> $DIR/mem_replace.rs:16:13 | -18 | let _ = mem::replace(&mut an_option, None); +16 | let _ = mem::replace(&mut an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` | = note: `-D clippy::mem-replace-option-with-none` implied by `-D warnings` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:20:13 + --> $DIR/mem_replace.rs:18:13 | -20 | let _ = mem::replace(an_option, None); +18 | let _ = mem::replace(an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` error: aborting due to 2 previous errors diff --git a/tests/ui/min_max.stderr b/tests/ui/min_max.stderr index 3ed67ad258e..74a93e350de 100644 --- a/tests/ui/min_max.stderr +++ b/tests/ui/min_max.stderr @@ -1,45 +1,45 @@ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:25:5 + --> $DIR/min_max.rs:21:5 | -25 | min(1, max(3, x)); +21 | min(1, max(3, x)); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::min-max` implied by `-D warnings` +error: this min/max combination leads to constant result + --> $DIR/min_max.rs:22:5 + | +22 | min(max(3, x), 1); + | ^^^^^^^^^^^^^^^^^ + +error: this min/max combination leads to constant result + --> $DIR/min_max.rs:23:5 + | +23 | max(min(x, 1), 3); + | ^^^^^^^^^^^^^^^^^ + +error: this min/max combination leads to constant result + --> $DIR/min_max.rs:24:5 + | +24 | max(3, min(x, 1)); + | ^^^^^^^^^^^^^^^^^ + error: this min/max combination leads to constant result --> $DIR/min_max.rs:26:5 | -26 | min(max(3, x), 1); - | ^^^^^^^^^^^^^^^^^ - -error: this min/max combination leads to constant result - --> $DIR/min_max.rs:27:5 - | -27 | max(min(x, 1), 3); - | ^^^^^^^^^^^^^^^^^ - -error: this min/max combination leads to constant result - --> $DIR/min_max.rs:28:5 - | -28 | max(3, min(x, 1)); - | ^^^^^^^^^^^^^^^^^ - -error: this min/max combination leads to constant result - --> $DIR/min_max.rs:30:5 - | -30 | my_max(3, my_min(x, 1)); +26 | my_max(3, my_min(x, 1)); | ^^^^^^^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:42:5 + --> $DIR/min_max.rs:38:5 | -42 | min("Apple", max("Zoo", s)); +38 | min("Apple", max("Zoo", s)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:43:5 + --> $DIR/min_max.rs:39:5 | -43 | max(min(s, "Apple"), "Zoo"); +39 | max(min(s, "Apple"), "Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/missing-doc.stderr b/tests/ui/missing-doc.stderr index 67f50152c73..b50305ab9ee 100644 --- a/tests/ui/missing-doc.stderr +++ b/tests/ui/missing-doc.stderr @@ -1,116 +1,128 @@ error: missing documentation for a type alias - --> $DIR/missing-doc.rs:38:1 + --> $DIR/missing-doc.rs:32:1 | -38 | type Typedef = String; +32 | type Typedef = String; | ^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` error: missing documentation for a type alias - --> $DIR/missing-doc.rs:39:1 + --> $DIR/missing-doc.rs:33:1 | -39 | pub type PubTypedef = String; +33 | pub type PubTypedef = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct - --> $DIR/missing-doc.rs:41:1 + --> $DIR/missing-doc.rs:35:1 | -41 | / struct Foo { -42 | | a: isize, -43 | | b: isize, -44 | | } +35 | / struct Foo { +36 | | a: isize, +37 | | b: isize, +38 | | } | |_^ +error: missing documentation for a struct field + --> $DIR/missing-doc.rs:36:5 + | +36 | a: isize, + | ^^^^^^^^ + +error: missing documentation for a struct field + --> $DIR/missing-doc.rs:37:5 + | +37 | b: isize, + | ^^^^^^^^ + +error: missing documentation for a struct + --> $DIR/missing-doc.rs:40:1 + | +40 | / pub struct PubFoo { +41 | | pub a: isize, +42 | | b: isize, +43 | | } + | |_^ + +error: missing documentation for a struct field + --> $DIR/missing-doc.rs:41:5 + | +41 | pub a: isize, + | ^^^^^^^^^^^^ + error: missing documentation for a struct field --> $DIR/missing-doc.rs:42:5 | -42 | a: isize, - | ^^^^^^^^ - -error: missing documentation for a struct field - --> $DIR/missing-doc.rs:43:5 - | -43 | b: isize, - | ^^^^^^^^ - -error: missing documentation for a struct - --> $DIR/missing-doc.rs:46:1 - | -46 | / pub struct PubFoo { -47 | | pub a: isize, -48 | | b: isize, -49 | | } - | |_^ - -error: missing documentation for a struct field - --> $DIR/missing-doc.rs:47:5 - | -47 | pub a: isize, - | ^^^^^^^^^^^^ - -error: missing documentation for a struct field - --> $DIR/missing-doc.rs:48:5 - | -48 | b: isize, +42 | b: isize, | ^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:57:1 + --> $DIR/missing-doc.rs:51:1 | -57 | mod module_no_dox {} +51 | mod module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:58:1 + --> $DIR/missing-doc.rs:52:1 | -58 | pub mod pub_module_no_dox {} +52 | pub mod pub_module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:62:1 + --> $DIR/missing-doc.rs:56:1 | -62 | pub fn foo2() {} +56 | pub fn foo2() {} | ^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:63:1 + --> $DIR/missing-doc.rs:57:1 | -63 | fn foo3() {} +57 | fn foo3() {} | ^^^^^^^^^^^^ error: missing documentation for a trait - --> $DIR/missing-doc.rs:80:1 + --> $DIR/missing-doc.rs:75:1 | -80 | / pub trait C { -81 | | fn foo(&self); -82 | | fn foo_with_impl(&self) {} -83 | | } +75 | / pub trait C { +76 | | fn foo(&self); +77 | | fn foo_with_impl(&self) {} +78 | | } | |_^ error: missing documentation for a trait method - --> $DIR/missing-doc.rs:81:5 + --> $DIR/missing-doc.rs:76:5 | -81 | fn foo(&self); +76 | fn foo(&self); | ^^^^^^^^^^^^^^ error: missing documentation for a trait method - --> $DIR/missing-doc.rs:82:5 + --> $DIR/missing-doc.rs:77:5 | -82 | fn foo_with_impl(&self) {} +77 | fn foo_with_impl(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type - --> $DIR/missing-doc.rs:92:5 + --> $DIR/missing-doc.rs:87:5 | -92 | type AssociatedType; +87 | type AssociatedType; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type - --> $DIR/missing-doc.rs:93:5 + --> $DIR/missing-doc.rs:88:5 | -93 | type AssociatedTypeDef = Self; +88 | type AssociatedTypeDef = Self; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: missing documentation for a method + --> $DIR/missing-doc.rs:99:5 + | +99 | pub fn foo() {} + | ^^^^^^^^^^^^^^^ + +error: missing documentation for a method + --> $DIR/missing-doc.rs:100:5 + | +100 | fn bar() {} + | ^^^^^^^^^^^ + error: missing documentation for a method --> $DIR/missing-doc.rs:104:5 | @@ -118,150 +130,128 @@ error: missing documentation for a method | ^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:105:5 + --> $DIR/missing-doc.rs:107:5 | -105 | fn bar() {} - | ^^^^^^^^^^^ - -error: missing documentation for a method - --> $DIR/missing-doc.rs:109:5 - | -109 | pub fn foo() {} - | ^^^^^^^^^^^^^^^ - -error: missing documentation for a method - --> $DIR/missing-doc.rs:112:5 - | -112 | fn foo2() {} +107 | fn foo2() {} | ^^^^^^^^^^^^ error: missing documentation for an enum - --> $DIR/missing-doc.rs:138:1 + --> $DIR/missing-doc.rs:134:1 | -138 | / enum Baz { -139 | | BazA { -140 | | a: isize, -141 | | b: isize -142 | | }, -143 | | BarB -144 | | } +134 | / enum Baz { +135 | | BazA { a: isize, b: isize }, +136 | | BarB, +137 | | } | |_^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:139:5 + --> $DIR/missing-doc.rs:135:5 | -139 | / BazA { -140 | | a: isize, -141 | | b: isize -142 | | }, - | |_____^ +135 | BazA { a: isize, b: isize }, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:140:9 + --> $DIR/missing-doc.rs:135:12 | -140 | a: isize, - | ^^^^^^^^ +135 | BazA { a: isize, b: isize }, + | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:141:9 + --> $DIR/missing-doc.rs:135:22 | -141 | b: isize - | ^^^^^^^^ +135 | BazA { a: isize, b: isize }, + | ^^^^^^^^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:143:5 + --> $DIR/missing-doc.rs:136:5 | -143 | BarB +136 | BarB, | ^^^^ error: missing documentation for an enum - --> $DIR/missing-doc.rs:146:1 + --> $DIR/missing-doc.rs:139:1 | -146 | / pub enum PubBaz { -147 | | PubBazA { -148 | | a: isize, -149 | | }, -150 | | } +139 | / pub enum PubBaz { +140 | | PubBazA { a: isize }, +141 | | } | |_^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:147:5 + --> $DIR/missing-doc.rs:140:5 | -147 | / PubBazA { -148 | | a: isize, -149 | | }, - | |_____^ +140 | PubBazA { a: isize }, + | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:148:9 + --> $DIR/missing-doc.rs:140:15 | -148 | a: isize, - | ^^^^^^^^ +140 | PubBazA { a: isize }, + | ^^^^^^^^ error: missing documentation for a constant - --> $DIR/missing-doc.rs:172:1 + --> $DIR/missing-doc.rs:160:1 | -172 | const FOO: u32 = 0; +160 | const FOO: u32 = 0; | ^^^^^^^^^^^^^^^^^^^ error: missing documentation for a constant - --> $DIR/missing-doc.rs:179:1 + --> $DIR/missing-doc.rs:167:1 | -179 | pub const FOO4: u32 = 0; +167 | pub const FOO4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing-doc.rs:182:1 + --> $DIR/missing-doc.rs:169:1 | -182 | static BAR: u32 = 0; +169 | static BAR: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing-doc.rs:189:1 + --> $DIR/missing-doc.rs:176:1 | -189 | pub static BAR4: u32 = 0; +176 | pub static BAR4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:192:1 + --> $DIR/missing-doc.rs:178:1 | -192 | / mod internal_impl { -193 | | /// dox -194 | | pub fn documented() {} -195 | | pub fn undocumented1() {} +178 | / mod internal_impl { +179 | | /// dox +180 | | pub fn documented() {} +181 | | pub fn undocumented1() {} ... | -204 | | } -205 | | } +190 | | } +191 | | } | |_^ error: missing documentation for a function - --> $DIR/missing-doc.rs:195:5 + --> $DIR/missing-doc.rs:181:5 | -195 | pub fn undocumented1() {} +181 | pub fn undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:196:5 + --> $DIR/missing-doc.rs:182:5 | -196 | pub fn undocumented2() {} +182 | pub fn undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:197:5 + --> $DIR/missing-doc.rs:183:5 | -197 | fn undocumented3() {} +183 | fn undocumented3() {} | ^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:202:9 + --> $DIR/missing-doc.rs:188:9 | -202 | pub fn also_undocumented1() {} +188 | pub fn also_undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:203:9 + --> $DIR/missing-doc.rs:189:9 | -203 | fn also_undocumented2() {} +189 | fn also_undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 39 previous errors diff --git a/tests/ui/missing_inline.stderr b/tests/ui/missing_inline.stderr index fc617ef54c9..132285a1eaa 100644 --- a/tests/ui/missing_inline.stderr +++ b/tests/ui/missing_inline.stderr @@ -1,39 +1,39 @@ error: missing `#[inline]` for a function - --> $DIR/missing_inline.rs:43:1 + --> $DIR/missing_inline.rs:40:1 | -43 | pub fn pub_foo() {} // missing #[inline] +40 | pub fn pub_foo() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-inline-in-public-items` implied by `-D warnings` error: missing `#[inline]` for a default trait method - --> $DIR/missing_inline.rs:58:5 + --> $DIR/missing_inline.rs:56:5 | -58 | fn PubBar_b() {} // missing #[inline] +56 | fn PubBar_b() {} // missing #[inline] + | ^^^^^^^^^^^^^^^^ + +error: missing `#[inline]` for a method + --> $DIR/missing_inline.rs:70:5 + | +70 | fn PubBar_a() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method --> $DIR/missing_inline.rs:71:5 | -71 | fn PubBar_a() {} // missing #[inline] +71 | fn PubBar_b() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method --> $DIR/missing_inline.rs:72:5 | -72 | fn PubBar_b() {} // missing #[inline] +72 | fn PubBar_c() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:73:5 + --> $DIR/missing_inline.rs:82:5 | -73 | fn PubBar_c() {} // missing #[inline] - | ^^^^^^^^^^^^^^^^ - -error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:83:5 - | -83 | pub fn PubFooImpl() {} // missing #[inline] +82 | pub fn PubFooImpl() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/module_inception.stderr b/tests/ui/module_inception.stderr index c1e6d0a6e62..bf891aa4578 100644 --- a/tests/ui/module_inception.stderr +++ b/tests/ui/module_inception.stderr @@ -1,19 +1,19 @@ error: module has the same name as its containing module - --> $DIR/module_inception.rs:17:9 + --> $DIR/module_inception.rs:14:9 | -17 | / mod bar { -18 | | mod foo {} -19 | | } +14 | / mod bar { +15 | | mod foo {} +16 | | } | |_________^ | = note: `-D clippy::module-inception` implied by `-D warnings` error: module has the same name as its containing module - --> $DIR/module_inception.rs:22:5 + --> $DIR/module_inception.rs:19:5 | -22 | / mod foo { -23 | | mod bar {} -24 | | } +19 | / mod foo { +20 | | mod bar {} +21 | | } | |_____^ error: aborting due to 2 previous errors diff --git a/tests/ui/modulo_one.stderr b/tests/ui/modulo_one.stderr index 57e2c59ee14..e4d20c5c63c 100644 --- a/tests/ui/modulo_one.stderr +++ b/tests/ui/modulo_one.stderr @@ -1,7 +1,7 @@ error: any number modulo 1 will be 0 - --> $DIR/modulo_one.rs:17:5 + --> $DIR/modulo_one.rs:14:5 | -17 | 10 % 1; +14 | 10 % 1; | ^^^^^^ | = note: `-D clippy::modulo-one` implied by `-D warnings` diff --git a/tests/ui/mut_from_ref.stderr b/tests/ui/mut_from_ref.stderr index 48b5abf5a6e..db0f05a7fa7 100644 --- a/tests/ui/mut_from_ref.stderr +++ b/tests/ui/mut_from_ref.stderr @@ -1,62 +1,62 @@ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:19:39 + --> $DIR/mut_from_ref.rs:16:39 | -19 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { +16 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^^^^ | = note: `-D clippy::mut-from-ref` implied by `-D warnings` note: immutable borrow here - --> $DIR/mut_from_ref.rs:19:29 + --> $DIR/mut_from_ref.rs:16:29 | -19 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { +16 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:25:25 + --> $DIR/mut_from_ref.rs:22:25 | -25 | fn ouch(x: &Foo) -> &mut Foo; +22 | fn ouch(x: &Foo) -> &mut Foo; | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:25:16 + --> $DIR/mut_from_ref.rs:22:16 | -25 | fn ouch(x: &Foo) -> &mut Foo; +22 | fn ouch(x: &Foo) -> &mut Foo; | ^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:34:21 + --> $DIR/mut_from_ref.rs:31:21 | -34 | fn fail(x: &u32) -> &mut u16 { +31 | fn fail(x: &u32) -> &mut u16 { | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:34:12 + --> $DIR/mut_from_ref.rs:31:12 | -34 | fn fail(x: &u32) -> &mut u16 { +31 | fn fail(x: &u32) -> &mut u16 { | ^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:38:50 + --> $DIR/mut_from_ref.rs:35:50 | -38 | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { +35 | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:38:25 + --> $DIR/mut_from_ref.rs:35:25 | -38 | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { +35 | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:42:67 + --> $DIR/mut_from_ref.rs:39:67 | -42 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { +39 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:42:27 + --> $DIR/mut_from_ref.rs:39:27 | -42 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { +39 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^ ^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/mut_mut.stderr b/tests/ui/mut_mut.stderr index c05c0215795..626a309a6a9 100644 --- a/tests/ui/mut_mut.stderr +++ b/tests/ui/mut_mut.stderr @@ -1,61 +1,61 @@ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:20:12 + --> $DIR/mut_mut.rs:13:11 | -20 | fn fun(x : &mut &mut u32) -> bool { - | ^^^^^^^^^^^^^ +13 | fn fun(x: &mut &mut u32) -> bool { + | ^^^^^^^^^^^^^ | = note: `-D clippy::mut-mut` implied by `-D warnings` error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:34:17 + --> $DIR/mut_mut.rs:29:17 | -34 | let mut x = &mut &mut 1u32; +29 | let mut x = &mut &mut 1u32; | ^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:29:20 + --> $DIR/mut_mut.rs:23:9 | -29 | ($p:expr) => { &mut $p } - | ^^^^^^^ +23 | &mut $p + | ^^^^^^^ ... -49 | let mut z = mut_ptr!(&mut 3u32); +44 | let mut z = mut_ptr!(&mut 3u32); | ------------------- in this macro invocation error: this expression mutably borrows a mutable reference. Consider reborrowing - --> $DIR/mut_mut.rs:36:21 + --> $DIR/mut_mut.rs:31:21 | -36 | let mut y = &mut x; +31 | let mut y = &mut x; | ^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:40:33 + --> $DIR/mut_mut.rs:35:32 | -40 | let y : &mut &mut u32 = &mut &mut 2; - | ^^^^^^^^^^^ +35 | let y: &mut &mut u32 = &mut &mut 2; + | ^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:40:17 + --> $DIR/mut_mut.rs:35:16 | -40 | let y : &mut &mut u32 = &mut &mut 2; - | ^^^^^^^^^^^^^ +35 | let y: &mut &mut u32 = &mut &mut 2; + | ^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:45:38 + --> $DIR/mut_mut.rs:40:37 | -45 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; - | ^^^^^^^^^^^^^^^^ +40 | let y: &mut &mut &mut u32 = &mut &mut &mut 2; + | ^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:45:17 + --> $DIR/mut_mut.rs:40:16 | -45 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; - | ^^^^^^^^^^^^^^^^^^ +40 | let y: &mut &mut &mut u32 = &mut &mut &mut 2; + | ^^^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:45:22 + --> $DIR/mut_mut.rs:40:21 | -45 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; - | ^^^^^^^^^^^^^ +40 | let y: &mut &mut &mut u32 = &mut &mut &mut 2; + | ^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/mut_range_bound.stderr b/tests/ui/mut_range_bound.stderr index a476ad5d14e..87537d77f44 100644 --- a/tests/ui/mut_range_bound.stderr +++ b/tests/ui/mut_range_bound.stderr @@ -1,33 +1,33 @@ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:28:21 + --> $DIR/mut_range_bound.rs:25:9 | -28 | for i in 0..m { m = 5; } // warning - | ^^^^^ +25 | m = 5; + | ^^^^^ | = note: `-D clippy::mut-range-bound` implied by `-D warnings` error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:33:22 + --> $DIR/mut_range_bound.rs:32:9 | -33 | for i in m..10 { m *= 2; } // warning - | ^^^^^^ +32 | m *= 2; + | ^^^^^^ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:39:21 + --> $DIR/mut_range_bound.rs:40:9 | -39 | for i in m..n { m = 5; n = 7; } // warning (1 for each mutated bound) - | ^^^^^ +40 | m = 5; + | ^^^^^ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:39:28 + --> $DIR/mut_range_bound.rs:41:9 | -39 | for i in m..n { m = 5; n = 7; } // warning (1 for each mutated bound) - | ^^^^^ +41 | n = 7; + | ^^^^^ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:50:22 + --> $DIR/mut_range_bound.rs:55:22 | -50 | let n = &mut m; // warning +55 | let n = &mut m; // warning | ^ error: aborting due to 5 previous errors diff --git a/tests/ui/mut_reference.stderr b/tests/ui/mut_reference.stderr index 07b07580d4b..1664c1dffed 100644 --- a/tests/ui/mut_reference.stderr +++ b/tests/ui/mut_reference.stderr @@ -1,21 +1,21 @@ error: The function/method `takes_an_immutable_reference` doesn't need a mutable reference - --> $DIR/mut_reference.rs:32:34 + --> $DIR/mut_reference.rs:26:34 | -32 | takes_an_immutable_reference(&mut 42); +26 | takes_an_immutable_reference(&mut 42); | ^^^^^^^ | = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings` error: The function/method `as_ptr` doesn't need a mutable reference - --> $DIR/mut_reference.rs:34:12 + --> $DIR/mut_reference.rs:28:12 | -34 | as_ptr(&mut 42); +28 | as_ptr(&mut 42); | ^^^^^^^ error: The function/method `takes_an_immutable_reference` doesn't need a mutable reference - --> $DIR/mut_reference.rs:38:44 + --> $DIR/mut_reference.rs:32:44 | -38 | my_struct.takes_an_immutable_reference(&mut 42); +32 | my_struct.takes_an_immutable_reference(&mut 42); | ^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index a317e8a6c94..d6f4f03c323 100644 --- a/tests/ui/mutex_atomic.stderr +++ b/tests/ui/mutex_atomic.stderr @@ -1,47 +1,47 @@ error: Consider using an AtomicBool instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:19:5 + --> $DIR/mutex_atomic.rs:15:5 | -19 | Mutex::new(true); +15 | Mutex::new(true); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::mutex-atomic` implied by `-D warnings` error: Consider using an AtomicUsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:20:5 + --> $DIR/mutex_atomic.rs:16:5 | -20 | Mutex::new(5usize); +16 | Mutex::new(5usize); | ^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicIsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:21:5 + --> $DIR/mutex_atomic.rs:17:5 | -21 | Mutex::new(9isize); +17 | Mutex::new(9isize); | ^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicPtr instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:23:5 + --> $DIR/mutex_atomic.rs:19:5 | -23 | Mutex::new(&x as *const u32); +19 | Mutex::new(&x as *const u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicPtr instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:24:5 + --> $DIR/mutex_atomic.rs:20:5 | -24 | Mutex::new(&mut x as *mut u32); +20 | Mutex::new(&mut x as *mut u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicUsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:25:5 + --> $DIR/mutex_atomic.rs:21:5 | -25 | Mutex::new(0u32); +21 | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::mutex-integer` implied by `-D warnings` error: Consider using an AtomicIsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:26:5 + --> $DIR/mutex_atomic.rs:22:5 | -26 | Mutex::new(0i32); +22 | Mutex::new(0i32); | ^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/needless_bool.stderr b/tests/ui/needless_bool.stderr index 638a3f56f0f..df2f80ffd11 100644 --- a/tests/ui/needless_bool.stderr +++ b/tests/ui/needless_bool.stderr @@ -1,95 +1,139 @@ error: this if-then-else expression will always return true - --> $DIR/needless_bool.rs:41:5 + --> $DIR/needless_bool.rs:40:5 | -41 | if x { true } else { true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +40 | / if x { +41 | | true +42 | | } else { +43 | | true +44 | | }; + | |_____^ | = note: `-D clippy::needless-bool` implied by `-D warnings` error: this if-then-else expression will always return false - --> $DIR/needless_bool.rs:42:5 - | -42 | if x { false } else { false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:43:5 - | -43 | if x { true } else { false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `x` - -error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:44:5 - | -44 | if x { false } else { true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `!x` - -error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:45:5 | -45 | if x && y { false } else { true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `!(x && y)` +45 | / if x { +46 | | false +47 | | } else { +48 | | false +49 | | }; + | |_____^ -error: this if-then-else expression will always return true +error: this if-then-else expression returns a bool literal + --> $DIR/needless_bool.rs:50:5 + | +50 | / if x { +51 | | true +52 | | } else { +53 | | false +54 | | }; + | |_____^ help: you can reduce it to: `x` + +error: this if-then-else expression returns a bool literal + --> $DIR/needless_bool.rs:55:5 + | +55 | / if x { +56 | | false +57 | | } else { +58 | | true +59 | | }; + | |_____^ help: you can reduce it to: `!x` + +error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:60:5 | -60 | if x { return true } else { return true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +60 | / if x && y { +61 | | false +62 | | } else { +63 | | true +64 | | }; + | |_____^ help: you can reduce it to: `!(x && y)` + +error: this if-then-else expression will always return true + --> $DIR/needless_bool.rs:83:5 + | +83 | / if x { +84 | | return true; +85 | | } else { +86 | | return true; +87 | | }; + | |_____^ error: this if-then-else expression will always return false - --> $DIR/needless_bool.rs:65:5 + --> $DIR/needless_bool.rs:92:5 | -65 | if x { return false } else { return false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +92 | / if x { +93 | | return false; +94 | | } else { +95 | | return false; +96 | | }; + | |_____^ error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:70:5 - | -70 | if x { return true } else { return false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `return x` + --> $DIR/needless_bool.rs:101:5 + | +101 | / if x { +102 | | return true; +103 | | } else { +104 | | return false; +105 | | }; + | |_____^ help: you can reduce it to: `return x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:75:5 - | -75 | if x && y { return true } else { return false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `return x && y` + --> $DIR/needless_bool.rs:110:5 + | +110 | / if x && y { +111 | | return true; +112 | | } else { +113 | | return false; +114 | | }; + | |_____^ help: you can reduce it to: `return x && y` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:80:5 - | -80 | if x { return false } else { return true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `return !x` + --> $DIR/needless_bool.rs:119:5 + | +119 | / if x { +120 | | return false; +121 | | } else { +122 | | return true; +123 | | }; + | |_____^ help: you can reduce it to: `return !x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:85:5 - | -85 | if x && y { return false } else { return true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `return !(x && y)` + --> $DIR/needless_bool.rs:128:5 + | +128 | / if x && y { +129 | | return false; +130 | | } else { +131 | | return true; +132 | | }; + | |_____^ help: you can reduce it to: `return !(x && y)` error: equality checks against true are unnecessary - --> $DIR/needless_bool.rs:89:7 - | -89 | if x == true { }; - | ^^^^^^^^^^ help: try simplifying it as shown: `x` - | - = note: `-D clippy::bool-comparison` implied by `-D warnings` + --> $DIR/needless_bool.rs:136:8 + | +136 | if x == true {}; + | ^^^^^^^^^ help: try simplifying it as shown: `x` + | + = note: `-D clippy::bool-comparison` implied by `-D warnings` error: equality checks against false can be replaced by a negation - --> $DIR/needless_bool.rs:93:7 - | -93 | if x == false { }; - | ^^^^^^^^^^^ help: try simplifying it as shown: `!x` + --> $DIR/needless_bool.rs:140:8 + | +140 | if x == false {}; + | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/needless_bool.rs:104:8 + --> $DIR/needless_bool.rs:150:8 | -104 | if x == true { }; +150 | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/needless_bool.rs:105:8 + --> $DIR/needless_bool.rs:151:8 | -105 | if x == false { }; +151 | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: aborting due to 15 previous errors diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index 93ba61784d3..42deedfa869 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -1,41 +1,41 @@ error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:25:15 + --> $DIR/needless_borrow.rs:22:15 | -25 | let c = x(&&a); +22 | let c = x(&&a); | ^^^ help: change this to: `&a` | = note: `-D clippy::needless-borrow` implied by `-D warnings` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow.rs:32:17 + --> $DIR/needless_borrow.rs:29:17 | -32 | if let Some(ref cake) = Some(&5) {} +29 | if let Some(ref cake) = Some(&5) {} | ^^^^^^^^ help: change this to: `cake` error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:39:15 + --> $DIR/needless_borrow.rs:36:15 | -39 | 46 => &&a, +36 | 46 => &&a, | ^^^ help: change this to: `&a` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrow.rs:61:34 + --> $DIR/needless_borrow.rs:58:34 | -61 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); +58 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` | = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrow.rs:62:30 + --> $DIR/needless_borrow.rs:59:30 | -62 | let _ = v.iter().filter(|&ref a| a.is_empty()); +59 | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow.rs:62:31 + --> $DIR/needless_borrow.rs:59:31 | -62 | let _ = v.iter().filter(|&ref a| a.is_empty()); +59 | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^ help: change this to: `a` error: aborting due to 6 previous errors diff --git a/tests/ui/needless_borrowed_ref.stderr b/tests/ui/needless_borrowed_ref.stderr index ef80473a9dc..5ec7b9e4f3e 100644 --- a/tests/ui/needless_borrowed_ref.stderr +++ b/tests/ui/needless_borrowed_ref.stderr @@ -1,27 +1,27 @@ error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:18:34 + --> $DIR/needless_borrowed_ref.rs:14:34 | -18 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); +14 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` | = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:23:17 + --> $DIR/needless_borrowed_ref.rs:19:17 | -23 | if let Some(&ref v) = thingy { +19 | if let Some(&ref v) = thingy { | ^^^^^^ help: try removing the `&ref` part and just keep: `v` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:52:27 + --> $DIR/needless_borrowed_ref.rs:48:27 | -52 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' +48 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' | ^^^^^^ help: try removing the `&ref` part and just keep: `k` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:52:38 + --> $DIR/needless_borrowed_ref.rs:48:38 | -52 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' +48 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' | ^^^^^^ help: try removing the `&ref` part and just keep: `k` error: aborting due to 4 previous errors diff --git a/tests/ui/needless_collect.stderr b/tests/ui/needless_collect.stderr index ee41a9d8dea..39b3aa5470b 100644 --- a/tests/ui/needless_collect.stderr +++ b/tests/ui/needless_collect.stderr @@ -1,27 +1,27 @@ error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:19:28 + --> $DIR/needless_collect.rs:16:28 | -19 | let len = sample.iter().collect::>().len(); +16 | let len = sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.count()` | = note: `-D clippy::needless-collect` implied by `-D warnings` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:20:21 + --> $DIR/needless_collect.rs:17:21 | -20 | if sample.iter().collect::>().is_empty() { +17 | if sample.iter().collect::>().is_empty() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:23:27 + --> $DIR/needless_collect.rs:20:27 | -23 | sample.iter().cloned().collect::>().contains(&1); +20 | sample.iter().cloned().collect::>().contains(&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.any(|&x| x == 1)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:24:34 + --> $DIR/needless_collect.rs:21:34 | -24 | sample.iter().map(|x| (x, x)).collect::>().len(); +21 | sample.iter().map(|x| (x, x)).collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.count()` error: aborting due to 4 previous errors diff --git a/tests/ui/needless_continue.stderr b/tests/ui/needless_continue.stderr index 10e7062f2a6..06f63ee496e 100644 --- a/tests/ui/needless_continue.stderr +++ b/tests/ui/needless_continue.stderr @@ -12,9 +12,9 @@ error: This else block is redundant. = help: Consider dropping the else clause and merging the code that follows (in the loop) with the if block, like so: if i % 2 == 0 && i % 3 == 0 { println!("{}", i); - println!("{}", i+1); + println!("{}", i + 1); if i % 5 == 0 { - println!("{}", i+2); + println!("{}", i + 2); } let i = 0; println!("bar {} ", i); diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index 3685f0e9614..e11aa73db2a 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -1,128 +1,128 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:21:23 + --> $DIR/needless_pass_by_value.rs:24:23 | -21 | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { +24 | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { | ^^^^^^ help: consider changing the type to: `&[T]` | = note: `-D clippy::needless-pass-by-value` implied by `-D warnings` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:35:11 + --> $DIR/needless_pass_by_value.rs:38:11 | -35 | fn bar(x: String, y: Wrapper) { +38 | fn bar(x: String, y: Wrapper) { | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:35:22 + --> $DIR/needless_pass_by_value.rs:38:22 | -35 | fn bar(x: String, y: Wrapper) { +38 | fn bar(x: String, y: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:41:71 + --> $DIR/needless_pass_by_value.rs:44:71 | -41 | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { +44 | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { | ^ help: consider taking a reference instead: `&V` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:53:18 + --> $DIR/needless_pass_by_value.rs:56:18 | -53 | fn test_match(x: Option>, y: Option>) { +56 | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead | -53 | fn test_match(x: &Option>, y: Option>) { -54 | match *x { +56 | fn test_match(x: &Option>, y: Option>) { +57 | match *x { | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:66:24 + --> $DIR/needless_pass_by_value.rs:69:24 | -66 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +69 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:66:36 + --> $DIR/needless_pass_by_value.rs:69:36 | -66 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +69 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead | -66 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { -67 | let Wrapper(s) = z; // moved -68 | let Wrapper(ref t) = *y; // not moved -69 | let Wrapper(_) = *y; // still not moved +69 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { +70 | let Wrapper(s) = z; // moved +71 | let Wrapper(ref t) = *y; // not moved +72 | let Wrapper(_) = *y; // still not moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:82:49 + --> $DIR/needless_pass_by_value.rs:85:49 | -82 | fn test_blanket_ref(_foo: T, _serializable: S) {} +85 | fn test_blanket_ref(_foo: T, _serializable: S) {} | ^ help: consider taking a reference instead: `&T` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:84:18 + --> $DIR/needless_pass_by_value.rs:87:18 | -84 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +87 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:84:29 + --> $DIR/needless_pass_by_value.rs:87:29 | -84 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +87 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider changing the type to | -84 | fn issue_2114(s: String, t: &str, u: Vec, v: Vec) { +87 | fn issue_2114(s: String, t: &str, u: Vec, v: Vec) { | ^^^^ help: change `t.clone()` to | -86 | let _ = t.to_string(); +89 | let _ = t.to_string(); | ^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:84:40 + --> $DIR/needless_pass_by_value.rs:87:40 | -84 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +87 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider taking a reference instead: `&Vec` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:84:53 + --> $DIR/needless_pass_by_value.rs:87:53 | -84 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +87 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider changing the type to | -84 | fn issue_2114(s: String, t: String, u: Vec, v: &[i32]) { +87 | fn issue_2114(s: String, t: String, u: Vec, v: &[i32]) { | ^^^^^^ help: change `v.clone()` to | -88 | let _ = v.to_owned(); +91 | let _ = v.to_owned(); | ^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:96:12 - | -96 | s: String, - | ^^^^^^ help: consider changing the type to: `&str` - -error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:97:12 - | -97 | t: String, - | ^^^^^^ help: consider taking a reference instead: `&String` - -error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:109:13 + --> $DIR/needless_pass_by_value.rs:100:12 | -109 | _u: U, - | ^ help: consider taking a reference instead: `&U` +100 | s: String, + | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:110:13 + --> $DIR/needless_pass_by_value.rs:101:12 | -110 | _s: Self, - | ^^^^ help: consider taking a reference instead: `&Self` +101 | t: String, + | ^^^^^^ help: consider taking a reference instead: `&String` + +error: this argument is passed by value, but not consumed in the function body + --> $DIR/needless_pass_by_value.rs:110:23 + | +110 | fn baz(&self, _u: U, _s: Self) {} + | ^ help: consider taking a reference instead: `&U` + +error: this argument is passed by value, but not consumed in the function body + --> $DIR/needless_pass_by_value.rs:110:30 + | +110 | fn baz(&self, _u: U, _s: Self) {} + | ^^^^ help: consider taking a reference instead: `&Self` error: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:132:24 diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index 688e9fc3a2c..03a469dfa72 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -1,83 +1,83 @@ error: the loop variable `i` is only used to index `ns`. - --> $DIR/needless_range_loop.rs:18:14 + --> $DIR/needless_range_loop.rs:17:14 | -18 | for i in 3..10 { +17 | for i in 3..10 { | ^^^^^ | = note: `-D clippy::needless-range-loop` implied by `-D warnings` help: consider using an iterator | -18 | for in ns.iter().take(10).skip(3) { +17 | for in ns.iter().take(10).skip(3) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `ms`. - --> $DIR/needless_range_loop.rs:39:14 + --> $DIR/needless_range_loop.rs:38:14 | -39 | for i in 0..ms.len() { +38 | for i in 0..ms.len() { | ^^^^^^^^^^^ help: consider using an iterator | -39 | for in &mut ms { +38 | for in &mut ms { | ^^^^^^ ^^^^^^^ error: the loop variable `i` is only used to index `ms`. - --> $DIR/needless_range_loop.rs:45:14 + --> $DIR/needless_range_loop.rs:44:14 | -45 | for i in 0..ms.len() { +44 | for i in 0..ms.len() { | ^^^^^^^^^^^ help: consider using an iterator | -45 | for in &mut ms { +44 | for in &mut ms { | ^^^^^^ ^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/needless_range_loop.rs:69:14 + --> $DIR/needless_range_loop.rs:68:14 | -69 | for i in x..x + 4 { +68 | for i in x..x + 4 { | ^^^^^^^^ help: consider using an iterator | -69 | for in vec.iter_mut().skip(x).take(4) { +68 | for in vec.iter_mut().skip(x).take(4) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/needless_range_loop.rs:76:14 + --> $DIR/needless_range_loop.rs:75:14 | -76 | for i in x..=x + 4 { +75 | for i in x..=x + 4 { | ^^^^^^^^^ help: consider using an iterator | -76 | for in vec.iter_mut().skip(x).take(4 + 1) { +75 | for in vec.iter_mut().skip(x).take(4 + 1) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `arr`. - --> $DIR/needless_range_loop.rs:82:14 + --> $DIR/needless_range_loop.rs:81:14 | -82 | for i in 0..3 { +81 | for i in 0..3 { | ^^^^ help: consider using an iterator | -82 | for in &arr { +81 | for in &arr { | ^^^^^^ ^^^^ error: the loop variable `i` is only used to index `arr`. - --> $DIR/needless_range_loop.rs:86:14 + --> $DIR/needless_range_loop.rs:85:14 | -86 | for i in 0..2 { +85 | for i in 0..2 { | ^^^^ help: consider using an iterator | -86 | for in arr.iter().take(2) { +85 | for in arr.iter().take(2) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `arr`. - --> $DIR/needless_range_loop.rs:90:14 + --> $DIR/needless_range_loop.rs:89:14 | -90 | for i in 1..3 { +89 | for i in 1..3 { | ^^^^ help: consider using an iterator | -90 | for in arr.iter().skip(1) { +89 | for in arr.iter().skip(1) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 742ef8d379e..07d29c19be3 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -1,51 +1,51 @@ error: unneeded return statement - --> $DIR/needless_return.rs:21:5 + --> $DIR/needless_return.rs:17:5 | -21 | return true; +17 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` | = note: `-D clippy::needless-return` implied by `-D warnings` error: unneeded return statement - --> $DIR/needless_return.rs:25:5 + --> $DIR/needless_return.rs:21:5 | -25 | return true - | ^^^^^^^^^^^ help: remove `return` as shown: `true` +21 | return true; + | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:30:9 + --> $DIR/needless_return.rs:26:9 | -30 | return true; +26 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:32:9 + --> $DIR/needless_return.rs:28:9 | -32 | return false; +28 | return false; | ^^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement - --> $DIR/needless_return.rs:38:17 + --> $DIR/needless_return.rs:34:17 | -38 | true => return false, +34 | true => return false, | ^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement - --> $DIR/needless_return.rs:40:13 + --> $DIR/needless_return.rs:36:13 | -40 | return true; +36 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:47:9 + --> $DIR/needless_return.rs:43:9 | -47 | return true; +43 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:49:16 + --> $DIR/needless_return.rs:45:16 | -49 | let _ = || return true; +45 | let _ = || return true; | ^^^^^^^^^^^ help: remove `return` as shown: `true` error: aborting due to 8 previous errors diff --git a/tests/ui/needless_update.stderr b/tests/ui/needless_update.stderr index 512cec84770..d5cd0e7889a 100644 --- a/tests/ui/needless_update.stderr +++ b/tests/ui/needless_update.stderr @@ -1,7 +1,7 @@ error: struct update has no effect, all the fields in the struct have already been specified - --> $DIR/needless_update.rs:26:23 + --> $DIR/needless_update.rs:22:23 | -26 | S { a: 1, b: 1, ..base }; +22 | S { a: 1, b: 1, ..base }; | ^^^^ | = note: `-D clippy::needless-update` implied by `-D warnings` diff --git a/tests/ui/neg_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index 1bd292818b3..ee0f9af6f95 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -1,27 +1,27 @@ error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:29:21 + --> $DIR/neg_cmp_op_on_partial_ord.rs:24:21 | -29 | let _not_less = !(a_value < another_value); +24 | let _not_less = !(a_value < another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::neg-cmp-op-on-partial-ord` implied by `-D warnings` error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:32:30 + --> $DIR/neg_cmp_op_on_partial_ord.rs:27:30 | -32 | let _not_less_or_equal = !(a_value <= another_value); +27 | let _not_less_or_equal = !(a_value <= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:35:24 + --> $DIR/neg_cmp_op_on_partial_ord.rs:30:24 | -35 | let _not_greater = !(a_value > another_value); +30 | let _not_greater = !(a_value > another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:38:33 + --> $DIR/neg_cmp_op_on_partial_ord.rs:33:33 | -38 | let _not_greater_or_equal = !(a_value >= another_value); +33 | let _not_greater_or_equal = !(a_value >= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/neg_multiply.stderr b/tests/ui/neg_multiply.stderr index ed96dd519ff..5e5d1afaafe 100644 --- a/tests/ui/neg_multiply.stderr +++ b/tests/ui/neg_multiply.stderr @@ -1,15 +1,15 @@ error: Negation by multiplying with -1 - --> $DIR/neg_multiply.rs:40:5 + --> $DIR/neg_multiply.rs:36:5 | -40 | x * -1; +36 | x * -1; | ^^^^^^ | = note: `-D clippy::neg-multiply` implied by `-D warnings` error: Negation by multiplying with -1 - --> $DIR/neg_multiply.rs:42:5 + --> $DIR/neg_multiply.rs:38:5 | -42 | -1 * x; +38 | -1 * x; | ^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index e4daa6e4350..6ef26234d9d 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -1,93 +1,99 @@ error: this loop never actually loops - --> $DIR/never_loop.rs:17:5 + --> $DIR/never_loop.rs:19:5 | -17 | / loop { // clippy::never_loop -18 | | x += 1; -19 | | if x == 1 { -20 | | return -21 | | } -22 | | break; -23 | | } +19 | / loop { +20 | | // clippy::never_loop +21 | | x += 1; +22 | | if x == 1 { +... | +25 | | break; +26 | | } | |_____^ | = note: #[deny(clippy::never_loop)] on by default error: this loop never actually loops - --> $DIR/never_loop.rs:38:5 + --> $DIR/never_loop.rs:41:5 | -38 | / loop { // never loops -39 | | x += 1; -40 | | break -41 | | } +41 | / loop { +42 | | // never loops +43 | | x += 1; +44 | | break; +45 | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:57:2 + --> $DIR/never_loop.rs:61:5 | -57 | loop { // never loops - | _____^ -58 | | while i == 0 { // never loops -59 | | break -60 | | } -61 | | return -62 | | } +61 | / loop { +62 | | // never loops +63 | | while i == 0 { +64 | | // never loops +... | +67 | | return; +68 | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:58:9 + --> $DIR/never_loop.rs:63:9 | -58 | / while i == 0 { // never loops -59 | | break -60 | | } +63 | / while i == 0 { +64 | | // never loops +65 | | break; +66 | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:69:3 + --> $DIR/never_loop.rs:75:9 | -69 | loop { // never loops - | _________^ -70 | | if x == 5 { break } -71 | | continue 'outer -72 | | } +75 | / loop { +76 | | // never loops +77 | | if x == 5 { +78 | | break; +79 | | } +80 | | continue 'outer; +81 | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:102:5 + --> $DIR/never_loop.rs:111:5 | -102 | / while let Some(y) = x { // never loops -103 | | return -104 | | } +111 | / while let Some(y) = x { +112 | | // never loops +113 | | return; +114 | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:108:5 + --> $DIR/never_loop.rs:118:5 | -108 | / for x in 0..10 { // never loops -109 | | match x { -110 | | 1 => break, -111 | | _ => return, -112 | | } -113 | | } +118 | / for x in 0..10 { +119 | | // never loops +120 | | match x { +121 | | 1 => break, +122 | | _ => return, +123 | | } +124 | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:154:5 + --> $DIR/never_loop.rs:166:5 | -154 | / 'outer: while a { // never loops -155 | | while a { -156 | | if a { -157 | | a = false; +166 | / 'outer: while a { +167 | | // never loops +168 | | while a { +169 | | if a { ... | -161 | | break 'outer; -162 | | } +174 | | break 'outer; +175 | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:168:9 + --> $DIR/never_loop.rs:181:9 | -168 | / while false { -169 | | break 'label; -170 | | } +181 | / while false { +182 | | break 'label; +183 | | } | |_________^ error: aborting due to 9 previous errors diff --git a/tests/ui/new_ret_no_self.stderr b/tests/ui/new_ret_no_self.stderr index bab9627ca22..e5911b3d72e 100644 --- a/tests/ui/new_ret_no_self.stderr +++ b/tests/ui/new_ret_no_self.stderr @@ -25,22 +25,28 @@ error: methods called `new` usually return `Self` | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:120:5 + --> $DIR/new_ret_no_self.rs:126:5 | -120 | pub fn new() -> (u32, u32) { unimplemented!(); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +126 | / pub fn new() -> (u32, u32) { +127 | | unimplemented!(); +128 | | } + | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:141:5 + --> $DIR/new_ret_no_self.rs:153:5 | -141 | pub fn new() -> *mut V { unimplemented!(); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +153 | / pub fn new() -> *mut V { +154 | | unimplemented!(); +155 | | } + | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:155:5 + --> $DIR/new_ret_no_self.rs:171:5 | -155 | pub fn new() -> Option { unimplemented!(); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +171 | / pub fn new() -> Option { +172 | | unimplemented!(); +173 | | } + | |_____^ error: aborting due to 6 previous errors diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index 5343428636c..b37c1e14424 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -1,39 +1,45 @@ error: you should consider deriving a `Default` implementation for `Foo` - --> $DIR/new_without_default.rs:22:5 + --> $DIR/new_without_default.rs:17:5 | -22 | pub fn new() -> Foo { Foo } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +17 | / pub fn new() -> Foo { +18 | | Foo +19 | | } + | |_____^ | = note: `-D clippy::new-without-default-derive` implied by `-D warnings` help: try this | -19 | #[derive(Default)] +14 | #[derive(Default)] | error: you should consider deriving a `Default` implementation for `Bar` - --> $DIR/new_without_default.rs:28:5 + --> $DIR/new_without_default.rs:25:5 | -28 | pub fn new() -> Self { Bar } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +25 | / pub fn new() -> Self { +26 | | Bar +27 | | } + | |_____^ help: try this | -25 | #[derive(Default)] +22 | #[derive(Default)] | error: you should consider adding a `Default` implementation for `LtKo<'c>` - --> $DIR/new_without_default.rs:76:5 + --> $DIR/new_without_default.rs:89:5 | -76 | pub fn new() -> LtKo<'c> { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +89 | / pub fn new() -> LtKo<'c> { +90 | | unimplemented!() +91 | | } + | |_____^ | = note: `-D clippy::new-without-default` implied by `-D warnings` help: try this | -75 | impl Default for LtKo<'c> { -76 | fn default() -> Self { -77 | Self::new() -78 | } -79 | } +88 | impl Default for LtKo<'c> { +89 | fn default() -> Self { +90 | Self::new() +91 | } +92 | } | error: aborting due to 3 previous errors diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index 7f012aa2ed4..e8a88307c97 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -1,154 +1,154 @@ error: statement with no effect - --> $DIR/no_effect.rs:71:5 + --> $DIR/no_effect.rs:74:5 | -71 | 0; +74 | 0; | ^^ | = note: `-D clippy::no-effect` implied by `-D warnings` -error: statement with no effect - --> $DIR/no_effect.rs:72:5 - | -72 | s2; - | ^^^ - -error: statement with no effect - --> $DIR/no_effect.rs:73:5 - | -73 | Unit; - | ^^^^^ - -error: statement with no effect - --> $DIR/no_effect.rs:74:5 - | -74 | Tuple(0); - | ^^^^^^^^^ - error: statement with no effect --> $DIR/no_effect.rs:75:5 | -75 | Struct { field: 0 }; - | ^^^^^^^^^^^^^^^^^^^^ +75 | s2; + | ^^^ error: statement with no effect --> $DIR/no_effect.rs:76:5 | -76 | Struct { ..s }; - | ^^^^^^^^^^^^^^^ +76 | Unit; + | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:77:5 | -77 | Union { a: 0 }; - | ^^^^^^^^^^^^^^^ +77 | Tuple(0); + | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:78:5 | -78 | Enum::Tuple(0); - | ^^^^^^^^^^^^^^^ +78 | Struct { field: 0 }; + | ^^^^^^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:79:5 | -79 | Enum::Struct { field: 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +79 | Struct { ..s }; + | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:80:5 | -80 | 5 + 6; - | ^^^^^^ +80 | Union { a: 0 }; + | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:81:5 | -81 | *&42; - | ^^^^^ +81 | Enum::Tuple(0); + | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:82:5 | -82 | &6; - | ^^^ +82 | Enum::Struct { field: 0 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:83:5 | -83 | (5, 6, 7); - | ^^^^^^^^^^ +83 | 5 + 6; + | ^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:84:5 | -84 | box 42; - | ^^^^^^^ +84 | *&42; + | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:85:5 | -85 | ..; +85 | &6; | ^^^ error: statement with no effect --> $DIR/no_effect.rs:86:5 | -86 | 5..; - | ^^^^ +86 | (5, 6, 7); + | ^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:87:5 | -87 | ..5; - | ^^^^ +87 | box 42; + | ^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:88:5 | -88 | 5..6; - | ^^^^^ +88 | ..; + | ^^^ + +error: statement with no effect + --> $DIR/no_effect.rs:89:5 + | +89 | 5..; + | ^^^^ error: statement with no effect --> $DIR/no_effect.rs:90:5 | -90 | [42, 55]; - | ^^^^^^^^^ +90 | ..5; + | ^^^^ error: statement with no effect --> $DIR/no_effect.rs:91:5 | -91 | [42, 55][1]; - | ^^^^^^^^^^^^ - -error: statement with no effect - --> $DIR/no_effect.rs:92:5 - | -92 | (42, 55).1; - | ^^^^^^^^^^^ +91 | 5..6; + | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:93:5 | -93 | [42; 55]; +93 | [42, 55]; | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:94:5 | -94 | [42; 55][13]; - | ^^^^^^^^^^^^^ +94 | [42, 55][1]; + | ^^^^^^^^^^^^ + +error: statement with no effect + --> $DIR/no_effect.rs:95:5 + | +95 | (42, 55).1; + | ^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:96:5 | -96 | || x += 5; +96 | [42; 55]; + | ^^^^^^^^^ + +error: statement with no effect + --> $DIR/no_effect.rs:97:5 + | +97 | [42; 55][13]; + | ^^^^^^^^^^^^^ + +error: statement with no effect + --> $DIR/no_effect.rs:99:5 + | +99 | || x += 5; | ^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:98:5 - | -98 | FooString { s: s }; - | ^^^^^^^^^^^^^^^^^^^ + --> $DIR/no_effect.rs:101:5 + | +101 | FooString { s: s }; + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 25 previous errors diff --git a/tests/ui/non_copy_const.stderr b/tests/ui/non_copy_const.stderr index 744b5474844..6d65f4dca50 100644 --- a/tests/ui/non_copy_const.stderr +++ b/tests/ui/non_copy_const.stderr @@ -1,7 +1,7 @@ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:22:1 + --> $DIR/non_copy_const.rs:19:1 | -22 | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable +19 | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` @@ -9,264 +9,264 @@ error: a const item should never be interior mutable = note: #[deny(clippy::declare_interior_mutable_const)] on by default error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:23:1 + --> $DIR/non_copy_const.rs:20:1 | -23 | const CELL: Cell = Cell::new(6); //~ ERROR interior mutable +20 | const CELL: Cell = Cell::new(6); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:24:1 + --> $DIR/non_copy_const.rs:21:1 | -24 | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); +21 | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:28:42 + --> $DIR/non_copy_const.rs:26:9 | -28 | ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; }; - | ^^^^^^^^^^^^^^^^^^^^^^ -29 | } -30 | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable +26 | const $name: $ty = $e; + | ^^^^^^^^^^^^^^^^^^^^^^ +... +29 | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable | ------------------------------------------ in this macro invocation error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:51:5 + --> $DIR/non_copy_const.rs:50:5 | -51 | const ATOMIC: AtomicUsize; //~ ERROR interior mutable +50 | const ATOMIC: AtomicUsize; //~ ERROR interior mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:55:5 + --> $DIR/non_copy_const.rs:54:5 | -55 | const INPUT: T; +54 | const INPUT: T; | ^^^^^^^^^^^^^^^ | help: consider requiring `T` to be `Copy` - --> $DIR/non_copy_const.rs:55:18 + --> $DIR/non_copy_const.rs:54:18 | -55 | const INPUT: T; +54 | const INPUT: T; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:58:5 + --> $DIR/non_copy_const.rs:57:5 | -58 | const ASSOC: Self::NonCopyType; +57 | const ASSOC: Self::NonCopyType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `>::NonCopyType` to be `Copy` - --> $DIR/non_copy_const.rs:58:18 + --> $DIR/non_copy_const.rs:57:18 | -58 | const ASSOC: Self::NonCopyType; +57 | const ASSOC: Self::NonCopyType; | ^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:62:5 + --> $DIR/non_copy_const.rs:61:5 | -62 | const AN_INPUT: T = Self::INPUT; +61 | const AN_INPUT: T = Self::INPUT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `T` to be `Copy` - --> $DIR/non_copy_const.rs:62:21 + --> $DIR/non_copy_const.rs:61:21 | -62 | const AN_INPUT: T = Self::INPUT; +61 | const AN_INPUT: T = Self::INPUT; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:28:42 + --> $DIR/non_copy_const.rs:26:9 | -28 | ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; }; - | ^^^^^^^^^^^^^^^^^^^^^^ +26 | const $name: $ty = $e; + | ^^^^^^^^^^^^^^^^^^^^^^ ... -65 | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable +64 | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable | ----------------------------------------------- in this macro invocation error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:71:5 + --> $DIR/non_copy_const.rs:70:5 | -71 | const SELF_2: Self; +70 | const SELF_2: Self; | ^^^^^^^^^^^^^^^^^^^ | help: consider requiring `Self` to be `Copy` - --> $DIR/non_copy_const.rs:71:19 + --> $DIR/non_copy_const.rs:70:19 | -71 | const SELF_2: Self; +70 | const SELF_2: Self; | ^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:92:5 + --> $DIR/non_copy_const.rs:91:5 | -92 | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable +91 | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:95:5 + --> $DIR/non_copy_const.rs:94:5 | -95 | const U_SELF: U = U::SELF_2; +94 | const U_SELF: U = U::SELF_2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `U` to be `Copy` - --> $DIR/non_copy_const.rs:95:19 + --> $DIR/non_copy_const.rs:94:19 | -95 | const U_SELF: U = U::SELF_2; +94 | const U_SELF: U = U::SELF_2; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:98:5 + --> $DIR/non_copy_const.rs:97:5 | -98 | const T_ASSOC: T::NonCopyType = T::ASSOC; +97 | const T_ASSOC: T::NonCopyType = T::ASSOC; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `>::NonCopyType` to be `Copy` - --> $DIR/non_copy_const.rs:98:20 + --> $DIR/non_copy_const.rs:97:20 | -98 | const T_ASSOC: T::NonCopyType = T::ASSOC; +97 | const T_ASSOC: T::NonCopyType = T::ASSOC; | ^^^^^^^^^^^^^^ error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:105:5 + --> $DIR/non_copy_const.rs:104:5 | -105 | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability +104 | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^ | = note: #[deny(clippy::borrow_interior_mutable_const)] on by default = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:106:16 + --> $DIR/non_copy_const.rs:105:16 | -106 | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability +105 | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability | ^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:108:5 + --> $DIR/non_copy_const.rs:107:5 | -108 | ATOMIC_USIZE_INIT.store(2, Ordering::SeqCst); //~ ERROR interior mutability +107 | ATOMIC_USIZE_INIT.store(2, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:109:16 + --> $DIR/non_copy_const.rs:108:16 | -109 | assert_eq!(ATOMIC_USIZE_INIT.load(Ordering::SeqCst), 0); //~ ERROR interior mutability +108 | assert_eq!(ATOMIC_USIZE_INIT.load(Ordering::SeqCst), 0); //~ ERROR interior mutability | ^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:112:22 + --> $DIR/non_copy_const.rs:111:22 | -112 | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability +111 | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:113:25 + --> $DIR/non_copy_const.rs:112:25 | -113 | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability +112 | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:114:27 + --> $DIR/non_copy_const.rs:113:27 | -114 | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability +113 | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:115:26 + --> $DIR/non_copy_const.rs:114:26 | -115 | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability +114 | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here +error: a const item with interior mutability should not be borrowed + --> $DIR/non_copy_const.rs:125:14 + | +125 | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability + | ^^^^^^^^^^^^ + | + = help: assign this const to a local or static variable, and use the variable here + error: a const item with interior mutability should not be borrowed --> $DIR/non_copy_const.rs:126:14 | -126 | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability +126 | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:127:14 + --> $DIR/non_copy_const.rs:127:19 | -127 | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability - | ^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here - -error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:128:19 - | -128 | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability +127 | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:129:14 + --> $DIR/non_copy_const.rs:128:14 | -129 | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability +128 | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:130:13 + --> $DIR/non_copy_const.rs:129:13 | -130 | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability +129 | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:136:13 + --> $DIR/non_copy_const.rs:135:13 | -136 | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability +135 | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:141:5 + --> $DIR/non_copy_const.rs:140:5 | -141 | CELL.set(2); //~ ERROR interior mutability +140 | CELL.set(2); //~ ERROR interior mutability | ^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:142:16 + --> $DIR/non_copy_const.rs:141:16 | -142 | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability +141 | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability | ^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:155:5 + --> $DIR/non_copy_const.rs:154:5 | -155 | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability +154 | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:156:16 + --> $DIR/non_copy_const.rs:155:16 | -156 | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability +155 | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability | ^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index 1369cd8a4ad..568ae721588 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,170 +1,170 @@ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:28:9 + --> $DIR/non_expressive_names.rs:24:9 | -28 | let bpple: i32; +24 | let bpple: i32; | ^^^^^ | = note: `-D clippy::similar-names` implied by `-D warnings` note: existing binding defined here - --> $DIR/non_expressive_names.rs:26:9 + --> $DIR/non_expressive_names.rs:22:9 | -26 | let apple: i32; +22 | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `b_pple` - --> $DIR/non_expressive_names.rs:28:9 + --> $DIR/non_expressive_names.rs:24:9 | -28 | let bpple: i32; +24 | let bpple: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:30:9 - | -30 | let cpple: i32; - | ^^^^^ - | -note: existing binding defined here --> $DIR/non_expressive_names.rs:26:9 | -26 | let apple: i32; +26 | let cpple: i32; + | ^^^^^ + | +note: existing binding defined here + --> $DIR/non_expressive_names.rs:22:9 + | +22 | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `c_pple` - --> $DIR/non_expressive_names.rs:30:9 + --> $DIR/non_expressive_names.rs:26:9 | -30 | let cpple: i32; +26 | let cpple: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:55:9 + --> $DIR/non_expressive_names.rs:50:9 | -55 | let bluby: i32; +50 | let bluby: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:54:9 + --> $DIR/non_expressive_names.rs:49:9 | -54 | let blubx: i32; +49 | let blubx: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `blub_y` - --> $DIR/non_expressive_names.rs:55:9 + --> $DIR/non_expressive_names.rs:50:9 | -55 | let bluby: i32; +50 | let bluby: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:60:9 + --> $DIR/non_expressive_names.rs:54:9 | -60 | let coke: i32; +54 | let coke: i32; | ^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:58:9 + --> $DIR/non_expressive_names.rs:52:9 | -58 | let cake: i32; +52 | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:78:9 + --> $DIR/non_expressive_names.rs:72:9 | -78 | let xyzeabc: i32; +72 | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here + --> $DIR/non_expressive_names.rs:70:9 + | +70 | let xyz1abc: i32; + | ^^^^^^^ + +error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:76:9 | -76 | let xyz1abc: i32; - | ^^^^^^^ - -error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:82:9 - | -82 | let parsee: i32; +76 | let parsee: i32; | ^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:80:9 + --> $DIR/non_expressive_names.rs:74:9 | -80 | let parser: i32; +74 | let parser: i32; | ^^^^^^ help: separate the discriminating character by an underscore like: `parse_e` - --> $DIR/non_expressive_names.rs:82:9 + --> $DIR/non_expressive_names.rs:76:9 | -82 | let parsee: i32; +76 | let parsee: i32; | ^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:96:16 + --> $DIR/non_expressive_names.rs:90:16 | -96 | bpple: sprang } = unimplemented!(); +90 | bpple: sprang, | ^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:95:22 + --> $DIR/non_expressive_names.rs:89:16 | -95 | let Foo { apple: spring, - | ^^^^^^ +89 | apple: spring, + | ^^^^^^ error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:130:17 + --> $DIR/non_expressive_names.rs:125:17 | -130 | let e: i32; +125 | let e: i32; | ^ | = note: `-D clippy::many-single-char-names` implied by `-D warnings` error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:133:17 + --> $DIR/non_expressive_names.rs:128:17 | -133 | let e: i32; +128 | let e: i32; | ^ error: 6th binding whose name is just one char - --> $DIR/non_expressive_names.rs:134:17 + --> $DIR/non_expressive_names.rs:129:17 | -134 | let f: i32; +129 | let f: i32; | ^ error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:139:13 + --> $DIR/non_expressive_names.rs:133:13 | -139 | e => panic!(), +133 | e => panic!(), | ^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:149:9 + --> $DIR/non_expressive_names.rs:143:9 | -149 | let _1 = 1; //~ERROR Consider a more descriptive name +143 | let _1 = 1; //~ERROR Consider a more descriptive name | ^^ | = note: `-D clippy::just-underscores-and-digits` implied by `-D warnings` error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:150:9 + --> $DIR/non_expressive_names.rs:144:9 | -150 | let ____1 = 1; //~ERROR Consider a more descriptive name +144 | let ____1 = 1; //~ERROR Consider a more descriptive name | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:151:9 + --> $DIR/non_expressive_names.rs:145:9 | -151 | let __1___2 = 12; //~ERROR Consider a more descriptive name +145 | let __1___2 = 12; //~ERROR Consider a more descriptive name | ^^^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:171:13 + --> $DIR/non_expressive_names.rs:165:13 | -171 | let _1 = 1; +165 | let _1 = 1; | ^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:172:13 + --> $DIR/non_expressive_names.rs:166:13 | -172 | let ____1 = 1; +166 | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:173:13 + --> $DIR/non_expressive_names.rs:167:13 | -173 | let __1___2 = 12; +167 | let __1___2 = 12; | ^^^^^^^ error: aborting due to 17 previous errors diff --git a/tests/ui/ok_expect.stderr b/tests/ui/ok_expect.stderr index f4c8440a774..be013cba459 100644 --- a/tests/ui/ok_expect.stderr +++ b/tests/ui/ok_expect.stderr @@ -1,33 +1,33 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:24:5 + --> $DIR/ok_expect.rs:23:5 | -24 | res.ok().expect("disaster!"); +23 | res.ok().expect("disaster!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::ok-expect` implied by `-D warnings` error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:30:5 + --> $DIR/ok_expect.rs:29:5 | -30 | res3.ok().expect("whoof"); +29 | res3.ok().expect("whoof"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:32:5 + --> $DIR/ok_expect.rs:31:5 | -32 | res4.ok().expect("argh"); +31 | res4.ok().expect("argh"); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:34:5 + --> $DIR/ok_expect.rs:33:5 | -34 | res5.ok().expect("oops"); +33 | res5.ok().expect("oops"); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:36:5 + --> $DIR/ok_expect.rs:35:5 | -36 | res6.ok().expect("meh"); +35 | res6.ok().expect("meh"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/ok_if_let.stderr b/tests/ui/ok_if_let.stderr index 27b3ef28ff3..5dd8ea37f6f 100644 --- a/tests/ui/ok_if_let.stderr +++ b/tests/ui/ok_if_let.stderr @@ -1,11 +1,11 @@ error: Matching on `Some` with `ok()` is redundant - --> $DIR/ok_if_let.rs:17:5 + --> $DIR/ok_if_let.rs:13:5 | -17 | / if let Some(y) = x.parse().ok() { -18 | | y -19 | | } else { -20 | | 0 -21 | | } +13 | / if let Some(y) = x.parse().ok() { +14 | | y +15 | | } else { +16 | | 0 +17 | | } | |_____^ | = note: `-D clippy::if-let-some-result` implied by `-D warnings` diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index e2b7b7820f3..abe7348622f 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -1,19 +1,19 @@ error: needlessly taken reference of both operands - --> $DIR/op_ref.rs:23:15 + --> $DIR/op_ref.rs:19:15 | -23 | let foo = &5 - &6; +19 | let foo = &5 - &6; | ^^^^^^^ | = note: `-D clippy::op-ref` implied by `-D warnings` help: use the values directly | -23 | let foo = 5 - 6; +19 | let foo = 5 - 6; | ^ ^ error: taken reference of right operand - --> $DIR/op_ref.rs:31:8 + --> $DIR/op_ref.rs:27:8 | -31 | if b < &a { +27 | if b < &a { | ^^^^-- | | | help: use the right value directly: `a` diff --git a/tests/ui/open_options.stderr b/tests/ui/open_options.stderr index 2835eebfbb3..10691d65a29 100644 --- a/tests/ui/open_options.stderr +++ b/tests/ui/open_options.stderr @@ -1,45 +1,45 @@ error: file opened with "truncate" and "read" - --> $DIR/open_options.rs:18:5 + --> $DIR/open_options.rs:15:5 | -18 | OpenOptions::new().read(true).truncate(true).open("foo.txt"); +15 | OpenOptions::new().read(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::nonsensical-open-options` implied by `-D warnings` error: file opened with "append" and "truncate" - --> $DIR/open_options.rs:19:5 + --> $DIR/open_options.rs:16:5 | -19 | OpenOptions::new().append(true).truncate(true).open("foo.txt"); +16 | OpenOptions::new().append(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "read" is called more than once - --> $DIR/open_options.rs:21:5 + --> $DIR/open_options.rs:18:5 | -21 | OpenOptions::new().read(true).read(false).open("foo.txt"); +18 | OpenOptions::new().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "create" is called more than once - --> $DIR/open_options.rs:22:5 + --> $DIR/open_options.rs:19:5 | -22 | OpenOptions::new().create(true).create(false).open("foo.txt"); +19 | OpenOptions::new().create(true).create(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "write" is called more than once - --> $DIR/open_options.rs:23:5 + --> $DIR/open_options.rs:20:5 | -23 | OpenOptions::new().write(true).write(false).open("foo.txt"); +20 | OpenOptions::new().write(true).write(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "append" is called more than once - --> $DIR/open_options.rs:24:5 + --> $DIR/open_options.rs:21:5 | -24 | OpenOptions::new().append(true).append(false).open("foo.txt"); +21 | OpenOptions::new().append(true).append(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "truncate" is called more than once - --> $DIR/open_options.rs:25:5 + --> $DIR/open_options.rs:22:5 | -25 | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); +22 | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/option_map_unit_fn.stderr b/tests/ui/option_map_unit_fn.stderr index 7a2dfd338a3..86fb9e75d8f 100644 --- a/tests/ui/option_map_unit_fn.stderr +++ b/tests/ui/option_map_unit_fn.stderr @@ -1,7 +1,7 @@ error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:44:5 + --> $DIR/option_map_unit_fn.rs:41:5 | -44 | x.field.map(do_nothing); +41 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` @@ -9,36 +9,41 @@ error: called `map(f)` on an Option value where `f` is a unit function = note: `-D clippy::option-map-unit-fn` implied by `-D warnings` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:46:5 + --> $DIR/option_map_unit_fn.rs:43:5 | -46 | x.field.map(do_nothing); +43 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:48:5 + --> $DIR/option_map_unit_fn.rs:45:5 | -48 | x.field.map(diverge); +45 | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:54:5 + --> $DIR/option_map_unit_fn.rs:53:5 | -54 | x.field.map(|value| x.do_option_nothing(value + captured)); +53 | x.field.map(|value| x.do_option_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:56:5 + --> $DIR/option_map_unit_fn.rs:55:5 | -56 | x.field.map(|value| { x.do_option_plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` +55 | x.field.map(|value| { + | _____^ + | |_____| + | || +56 | || x.do_option_plus_one(value + captured); +57 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:59:5 @@ -51,157 +56,212 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:61:5 | -61 | x.field.map(|value| { do_nothing(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +61 | x.field.map(|value| do_nothing(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:63:5 | -63 | x.field.map(|value| { do_nothing(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` +63 | x.field.map(|value| { + | _____^ + | |_____| + | || +64 | || do_nothing(value + captured); +65 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:65:5 + --> $DIR/option_map_unit_fn.rs:67:5 | -65 | x.field.map(|value| { { do_nothing(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` +67 | x.field.map(|value| { + | _____^ + | |_____| + | || +68 | || do_nothing(value + captured); +69 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:68:5 + --> $DIR/option_map_unit_fn.rs:71:5 | -68 | x.field.map(|value| diverge(value + captured)); +71 | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:70:5 + --> $DIR/option_map_unit_fn.rs:73:5 | -70 | x.field.map(|value| { diverge(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +73 | x.field.map(|value| diverge(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:72:5 + --> $DIR/option_map_unit_fn.rs:75:5 | -72 | x.field.map(|value| { diverge(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` - -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:74:5 - | -74 | x.field.map(|value| { { diverge(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` - -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:79:5 - | -79 | x.field.map(|value| { let y = plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }` - -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:81:5 - | -81 | x.field.map(|value| { plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` - -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:83:5 - | -83 | x.field.map(|value| { { plus_one(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` - -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:86:5 - | -86 | x.field.map(|ref value| { do_nothing(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }` - -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:89:5 - | -89 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { ... }` - -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:91:5 - | -91 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { ... }` - -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:95:5 - | -95 | x.field.map(|value| { +75 | x.field.map(|value| { | _____^ | |_____| | || -96 | || do_nothing(value); -97 | || do_nothing(value) -98 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { ... }` +76 | || diverge(value + captured); +77 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { diverge(value + captured); }` | |_______| | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:99:5 + --> $DIR/option_map_unit_fn.rs:79:5 | -99 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +79 | x.field.map(|value| { + | _____^ + | |_____| + | || +80 | || diverge(value + captured); +81 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { diverge(value + captured); }` + | |_______| + | + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/option_map_unit_fn.rs:85:5 + | +85 | x.field.map(|value| { + | _____^ + | |_____| + | || +86 | || let y = plus_one(value + captured); +87 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }` + | |_______| + | + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/option_map_unit_fn.rs:89:5 + | +89 | x.field.map(|value| { + | _____^ + | |_____| + | || +90 | || plus_one(value + captured); +91 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` + | |_______| + | + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/option_map_unit_fn.rs:93:5 + | +93 | x.field.map(|value| { + | _____^ + | |_____| + | || +94 | || plus_one(value + captured); +95 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` + | |_______| + | + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/option_map_unit_fn.rs:97:5 + | +97 | x.field.map(|ref value| do_nothing(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | - | help: try this: `if let Some(value) = x.field { ... }` + | help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }` + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/option_map_unit_fn.rs:99:5 + | +99 | x.field.map(|value| { + | _____^ + | |_____| + | || +100 | || do_nothing(value); +101 | || do_nothing(value) +102 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { ... }` + | |_______| + | + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/option_map_unit_fn.rs:104:5 + | +104 | x.field.map(|value| { + | _____^ + | |_____| + | || +105 | || if value > 0 { +106 | || do_nothing(value); +107 | || do_nothing(value) +108 | || } +109 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { ... }` + | |_______| + | + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/option_map_unit_fn.rs:113:5 + | +113 | x.field.map(|value| { + | _____^ + | |_____| + | || +114 | || do_nothing(value); +115 | || do_nothing(value) +116 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { ... }` + | |_______| + | + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/option_map_unit_fn.rs:117:5 + | +117 | x.field.map(|value| { + | _____^ + | |_____| + | || +118 | || do_nothing(value); +119 | || do_nothing(value); +120 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { ... }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:102:5 + --> $DIR/option_map_unit_fn.rs:124:5 | -102 | Some(42).map(diverge); +124 | Some(42).map(diverge); | ^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = Some(42) { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:103:5 + --> $DIR/option_map_unit_fn.rs:125:5 | -103 | "12".parse::().ok().map(diverge); +125 | "12".parse::().ok().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = "12".parse::().ok() { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:104:5 + --> $DIR/option_map_unit_fn.rs:126:5 | -104 | Some(plus_one(1)).map(do_nothing); +126 | Some(plus_one(1)).map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = Some(plus_one(1)) { do_nothing(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:108:5 + --> $DIR/option_map_unit_fn.rs:130:5 | -108 | y.map(do_nothing); +130 | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_y) = y { do_nothing(...) }` diff --git a/tests/ui/option_option.stderr b/tests/ui/option_option.stderr index 8a867fd4fe2..0689a10231b 100644 --- a/tests/ui/option_option.stderr +++ b/tests/ui/option_option.stderr @@ -1,58 +1,58 @@ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:11:13 + --> $DIR/option_option.rs:10:13 | -11 | fn input(_: Option>) { +10 | fn input(_: Option>) {} | ^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::option-option` implied by `-D warnings` error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:14:16 + --> $DIR/option_option.rs:12:16 | -14 | fn output() -> Option> { +12 | fn output() -> Option> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:18:27 + --> $DIR/option_option.rs:16:27 | -18 | fn output_nested() -> Vec>> { +16 | fn output_nested() -> Vec>> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:23:30 + --> $DIR/option_option.rs:21:30 | -23 | fn output_nested_nested() -> Option>> { +21 | fn output_nested_nested() -> Option>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:28:8 + --> $DIR/option_option.rs:26:8 | -28 | x: Option>, +26 | x: Option>, | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:32:23 + --> $DIR/option_option.rs:30:23 | -32 | fn struct_fn() -> Option> { +30 | fn struct_fn() -> Option> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:38:22 + --> $DIR/option_option.rs:36:22 | -38 | fn trait_fn() -> Option>; +36 | fn trait_fn() -> Option>; | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:42:11 + --> $DIR/option_option.rs:40:11 | -42 | Tuple(Option>), +40 | Tuple(Option>), | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:43:15 + --> $DIR/option_option.rs:41:17 | -43 | Struct{x: Option>}, - | ^^^^^^^^^^^^^^^^^^ +41 | Struct { x: Option> }, + | ^^^^^^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index 0bd20210f01..1c15eeaf67b 100644 --- a/tests/ui/overflow_check_conditional.stderr +++ b/tests/ui/overflow_check_conditional.stderr @@ -1,51 +1,51 @@ error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:21:5 + --> $DIR/overflow_check_conditional.rs:17:8 | -21 | if a + b < a { +17 | if a + b < a {} | ^^^^^^^^^ | = note: `-D clippy::overflow-check-conditional` implied by `-D warnings` error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:24:5 + --> $DIR/overflow_check_conditional.rs:18:8 | -24 | if a > a + b { +18 | if a > a + b {} | ^^^^^^^^^ error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:27:5 + --> $DIR/overflow_check_conditional.rs:19:8 | -27 | if a + b < b { +19 | if a + b < b {} | ^^^^^^^^^ error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:30:5 + --> $DIR/overflow_check_conditional.rs:20:8 | -30 | if b > a + b { +20 | if b > a + b {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:33:5 + --> $DIR/overflow_check_conditional.rs:21:8 | -33 | if a - b > b { +21 | if a - b > b {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:36:5 + --> $DIR/overflow_check_conditional.rs:22:8 | -36 | if b < a - b { +22 | if b < a - b {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:39:5 + --> $DIR/overflow_check_conditional.rs:23:8 | -39 | if a - b > a { +23 | if a - b > a {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:42:5 + --> $DIR/overflow_check_conditional.rs:24:8 | -42 | if a < a - b { +24 | if a < a - b {} | ^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/panic_unimplemented.stderr b/tests/ui/panic_unimplemented.stderr index 75032c1170e..e357050b739 100644 --- a/tests/ui/panic_unimplemented.stderr +++ b/tests/ui/panic_unimplemented.stderr @@ -1,33 +1,33 @@ error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:18:16 + --> $DIR/panic_unimplemented.rs:14:16 | -18 | panic!("{}"); +14 | panic!("{}"); | ^^^^ | = note: `-D clippy::panic-params` implied by `-D warnings` error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:20:16 + --> $DIR/panic_unimplemented.rs:16:16 | -20 | panic!("{:?}"); +16 | panic!("{:?}"); | ^^^^^^ error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:22:23 + --> $DIR/panic_unimplemented.rs:18:23 | -22 | assert!(true, "here be missing values: {}"); +18 | assert!(true, "here be missing values: {}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:25:12 + --> $DIR/panic_unimplemented.rs:21:12 | -25 | panic!("{{{this}}}"); +21 | panic!("{{{this}}}"); | ^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panic_unimplemented.rs:68:5 + --> $DIR/panic_unimplemented.rs:64:5 | -68 | unimplemented!(); +64 | unimplemented!(); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unimplemented` implied by `-D warnings` diff --git a/tests/ui/partialeq_ne_impl.stderr b/tests/ui/partialeq_ne_impl.stderr index 0ed2d0789cb..d429fba5db0 100644 --- a/tests/ui/partialeq_ne_impl.stderr +++ b/tests/ui/partialeq_ne_impl.stderr @@ -1,8 +1,10 @@ error: re-implementing `PartialEq::ne` is unnecessary - --> $DIR/partialeq_ne_impl.rs:20:5 + --> $DIR/partialeq_ne_impl.rs:18:5 | -20 | fn ne(&self, _: &Foo) -> bool { false } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +18 | / fn ne(&self, _: &Foo) -> bool { +19 | | false +20 | | } + | |_____^ | = note: `-D clippy::partialeq-ne-impl` implied by `-D warnings` diff --git a/tests/ui/patterns.stderr b/tests/ui/patterns.stderr index d236da24022..b97709d2ae9 100644 --- a/tests/ui/patterns.stderr +++ b/tests/ui/patterns.stderr @@ -1,7 +1,7 @@ error: the `y @ _` pattern can be written as just `y` - --> $DIR/patterns.rs:20:9 + --> $DIR/patterns.rs:17:9 | -20 | y @ _ => (), +17 | y @ _ => (), | ^^^^^ | = note: `-D clippy::redundant-pattern` implied by `-D warnings` diff --git a/tests/ui/precedence.stderr b/tests/ui/precedence.stderr index 3d5553ed0c3..8601f828ef3 100644 --- a/tests/ui/precedence.stderr +++ b/tests/ui/precedence.stderr @@ -1,57 +1,57 @@ error: operator precedence can trip the unwary - --> $DIR/precedence.rs:28:5 + --> $DIR/precedence.rs:24:5 | -28 | 1 << 2 + 3; +24 | 1 << 2 + 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` | = note: `-D clippy::precedence` implied by `-D warnings` +error: operator precedence can trip the unwary + --> $DIR/precedence.rs:25:5 + | +25 | 1 + 2 << 3; + | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3` + +error: operator precedence can trip the unwary + --> $DIR/precedence.rs:26:5 + | +26 | 4 >> 1 + 1; + | ^^^^^^^^^^ help: consider parenthesizing your expression: `4 >> (1 + 1)` + +error: operator precedence can trip the unwary + --> $DIR/precedence.rs:27:5 + | +27 | 1 + 3 >> 2; + | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 3) >> 2` + +error: operator precedence can trip the unwary + --> $DIR/precedence.rs:28:5 + | +28 | 1 ^ 1 - 1; + | ^^^^^^^^^ help: consider parenthesizing your expression: `1 ^ (1 - 1)` + error: operator precedence can trip the unwary --> $DIR/precedence.rs:29:5 | -29 | 1 + 2 << 3; - | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3` +29 | 3 | 2 - 1; + | ^^^^^^^^^ help: consider parenthesizing your expression: `3 | (2 - 1)` error: operator precedence can trip the unwary --> $DIR/precedence.rs:30:5 | -30 | 4 >> 1 + 1; - | ^^^^^^^^^^ help: consider parenthesizing your expression: `4 >> (1 + 1)` - -error: operator precedence can trip the unwary - --> $DIR/precedence.rs:31:5 - | -31 | 1 + 3 >> 2; - | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 3) >> 2` - -error: operator precedence can trip the unwary - --> $DIR/precedence.rs:32:5 - | -32 | 1 ^ 1 - 1; - | ^^^^^^^^^ help: consider parenthesizing your expression: `1 ^ (1 - 1)` - -error: operator precedence can trip the unwary - --> $DIR/precedence.rs:33:5 - | -33 | 3 | 2 - 1; - | ^^^^^^^^^ help: consider parenthesizing your expression: `3 | (2 - 1)` - -error: operator precedence can trip the unwary - --> $DIR/precedence.rs:34:5 - | -34 | 3 & 5 - 2; +30 | 3 & 5 - 2; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 & (5 - 2)` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:35:5 + --> $DIR/precedence.rs:31:5 | -35 | -1i32.abs(); +31 | -1i32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1i32.abs())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:36:5 + --> $DIR/precedence.rs:32:5 | -36 | -1f32.abs(); +32 | -1f32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1f32.abs())` error: aborting due to 9 previous errors diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index 605e527c208..199f76568f0 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -1,59 +1,59 @@ error: use of `Debug`-based formatting - --> $DIR/print.rs:23:19 + --> $DIR/print.rs:20:19 | -23 | write!(f, "{:?}", 43.1415) +20 | write!(f, "{:?}", 43.1415) | ^^^^^^ | = note: `-D clippy::use-debug` implied by `-D warnings` error: use of `Debug`-based formatting - --> $DIR/print.rs:30:19 + --> $DIR/print.rs:27:19 | -30 | write!(f, "{:?}", 42.718) +27 | write!(f, "{:?}", 42.718) | ^^^^^^ error: use of `println!` - --> $DIR/print.rs:35:5 + --> $DIR/print.rs:32:5 | -35 | println!("Hello"); +32 | println!("Hello"); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::print-stdout` implied by `-D warnings` error: use of `print!` - --> $DIR/print.rs:36:5 + --> $DIR/print.rs:33:5 | -36 | print!("Hello"); +33 | print!("Hello"); | ^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:38:5 + --> $DIR/print.rs:35:5 | -38 | print!("Hello {}", "World"); +35 | print!("Hello {}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:40:5 + --> $DIR/print.rs:37:5 | -40 | print!("Hello {:?}", "World"); +37 | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:40:12 + --> $DIR/print.rs:37:12 | -40 | print!("Hello {:?}", "World"); +37 | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:42:5 + --> $DIR/print.rs:39:5 | -42 | print!("Hello {:#?}", "#orld"); +39 | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:42:12 + --> $DIR/print.rs:39:12 | -42 | print!("Hello {:#?}", "#orld"); +39 | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index 9fe7fe34e6e..cba5cc19eac 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -1,88 +1,88 @@ error: literal with an empty format string - --> $DIR/print_literal.rs:34:71 + --> $DIR/print_literal.rs:31:71 | -34 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); +31 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ | = note: `-D clippy::print-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/print_literal.rs:35:24 + --> $DIR/print_literal.rs:32:24 | -35 | print!("Hello {}", "world"); +32 | print!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:36:36 + --> $DIR/print_literal.rs:33:36 | -36 | println!("Hello {} {}", world, "world"); +33 | println!("Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:37:26 + --> $DIR/print_literal.rs:34:26 | -37 | println!("Hello {}", "world"); +34 | println!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:38:30 + --> $DIR/print_literal.rs:35:30 | -38 | println!("10 / 4 is {}", 2.5); +35 | println!("10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:39:28 + --> $DIR/print_literal.rs:36:28 | -39 | println!("2 + 1 = {}", 3); +36 | println!("2 + 1 = {}", 3); | ^ error: literal with an empty format string - --> $DIR/print_literal.rs:44:25 + --> $DIR/print_literal.rs:41:25 | -44 | println!("{0} {1}", "hello", "world"); +41 | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:44:34 + --> $DIR/print_literal.rs:41:34 | -44 | println!("{0} {1}", "hello", "world"); +41 | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:45:25 + --> $DIR/print_literal.rs:42:25 | -45 | println!("{1} {0}", "hello", "world"); +42 | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:45:34 + --> $DIR/print_literal.rs:42:34 | -45 | println!("{1} {0}", "hello", "world"); +42 | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:48:33 + --> $DIR/print_literal.rs:45:35 | -48 | println!("{foo} {bar}", foo="hello", bar="world"); - | ^^^^^^^ +45 | println!("{foo} {bar}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:48:46 + --> $DIR/print_literal.rs:45:50 | -48 | println!("{foo} {bar}", foo="hello", bar="world"); - | ^^^^^^^ +45 | println!("{foo} {bar}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:49:33 + --> $DIR/print_literal.rs:46:35 | -49 | println!("{bar} {foo}", foo="hello", bar="world"); - | ^^^^^^^ +46 | println!("{bar} {foo}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:49:46 + --> $DIR/print_literal.rs:46:50 | -49 | println!("{bar} {foo}", foo="hello", bar="world"); - | ^^^^^^^ +46 | println!("{bar} {foo}", foo = "hello", bar = "world"); + | ^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index 4cd7a6685d4..639a4271110 100644 --- a/tests/ui/print_with_newline.stderr +++ b/tests/ui/print_with_newline.stderr @@ -1,27 +1,27 @@ error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:17:5 + --> $DIR/print_with_newline.rs:14:5 | -17 | print!("Hello/n"); +14 | print!("Hello/n"); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::print-with-newline` implied by `-D warnings` error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:18:5 + --> $DIR/print_with_newline.rs:15:5 | -18 | print!("Hello {}/n", "world"); +15 | print!("Hello {}/n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:19:5 + --> $DIR/print_with_newline.rs:16:5 | -19 | print!("Hello {} {}/n", "world", "#2"); +16 | print!("Hello {} {}/n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:20:5 + --> $DIR/print_with_newline.rs:17:5 | -20 | print!("{}/n", 1265); +17 | print!("{}/n", 1265); | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/println_empty_string.stderr b/tests/ui/println_empty_string.stderr index e06b403cfec..9a08150d627 100644 --- a/tests/ui/println_empty_string.stderr +++ b/tests/ui/println_empty_string.stderr @@ -1,15 +1,15 @@ error: using `println!("")` - --> $DIR/println_empty_string.rs:13:5 + --> $DIR/println_empty_string.rs:12:5 | -13 | println!(""); +12 | println!(""); | ^^^^^^^^^^^^ help: replace it with: `println!()` | = note: `-D clippy::println-empty-string` implied by `-D warnings` error: using `println!("")` - --> $DIR/println_empty_string.rs:16:14 + --> $DIR/println_empty_string.rs:15:14 | -16 | _ => println!(""), +15 | _ => println!(""), | ^^^^^^^^^^^^ help: replace it with: `println!()` error: aborting due to 2 previous errors diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index e7aecf7c20b..c9e8292795f 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -1,85 +1,85 @@ error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:18:14 + --> $DIR/ptr_arg.rs:15:14 | -18 | fn do_vec(x: &Vec) { +15 | fn do_vec(x: &Vec) { | ^^^^^^^^^ help: change this to: `&[i64]` | = note: `-D clippy::ptr-arg` implied by `-D warnings` error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:26:14 + --> $DIR/ptr_arg.rs:24:14 | -26 | fn do_str(x: &String) { +24 | fn do_str(x: &String) { | ^^^^^^^ help: change this to: `&str` error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:39:18 + --> $DIR/ptr_arg.rs:37:18 | -39 | fn do_vec(x: &Vec); +37 | fn do_vec(x: &Vec); | ^^^^^^^^^ help: change this to: `&[i64]` error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:52:14 + --> $DIR/ptr_arg.rs:50:14 | -52 | fn cloned(x: &Vec) -> Vec { +50 | fn cloned(x: &Vec) -> Vec { | ^^^^^^^^ help: change this to | -52 | fn cloned(x: &[u8]) -> Vec { +50 | fn cloned(x: &[u8]) -> Vec { | ^^^^^ help: change `x.clone()` to | -53 | let e = x.to_owned(); +51 | let e = x.to_owned(); | ^^^^^^^^^^^^ help: change `x.clone()` to | -58 | x.to_owned() +56 | x.to_owned() | error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:61:18 + --> $DIR/ptr_arg.rs:59:18 | -61 | fn str_cloned(x: &String) -> String { +59 | fn str_cloned(x: &String) -> String { | ^^^^^^^ help: change this to | -61 | fn str_cloned(x: &str) -> String { +59 | fn str_cloned(x: &str) -> String { | ^^^^ help: change `x.clone()` to | -62 | let a = x.to_string(); +60 | let a = x.to_string(); | ^^^^^^^^^^^^^ help: change `x.clone()` to | -63 | let b = x.to_string(); +61 | let b = x.to_string(); | ^^^^^^^^^^^^^ help: change `x.clone()` to | -68 | x.to_string() +64 | x.to_string() | error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:71:44 + --> $DIR/ptr_arg.rs:67:44 | -71 | fn false_positive_capacity(x: &Vec, y: &String) { +67 | fn false_positive_capacity(x: &Vec, y: &String) { | ^^^^^^^ help: change this to | -71 | fn false_positive_capacity(x: &Vec, y: &str) { +67 | fn false_positive_capacity(x: &Vec, y: &str) { | ^^^^ help: change `y.clone()` to | -73 | let b = y.to_string(); +69 | let b = y.to_string(); | ^^^^^^^^^^^^^ help: change `y.as_str()` to | -74 | let c = y; +70 | let c = y; | ^ error: using a reference to `Cow` is not recommended. - --> $DIR/ptr_arg.rs:83:25 + --> $DIR/ptr_arg.rs:81:25 | -83 | fn test_cow_with_ref(c: &Cow<[i32]>) { +81 | fn test_cow_with_ref(c: &Cow<[i32]>) {} | ^^^^^^^^^^^ help: change this to: `&[i32]` error: aborting due to 7 previous errors diff --git a/tests/ui/ptr_offset_with_cast.stderr b/tests/ui/ptr_offset_with_cast.stderr index b3df0abbaa8..c9bd4d79460 100644 --- a/tests/ui/ptr_offset_with_cast.stderr +++ b/tests/ui/ptr_offset_with_cast.stderr @@ -1,15 +1,15 @@ error: use of `offset` with a `usize` casted to an `isize` - --> $DIR/ptr_offset_with_cast.rs:20:9 + --> $DIR/ptr_offset_with_cast.rs:19:9 | -20 | ptr.offset(offset_usize as isize); +19 | ptr.offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)` | = note: `-D clippy::ptr-offset-with-cast` implied by `-D warnings` error: use of `wrapping_offset` with a `usize` casted to an `isize` - --> $DIR/ptr_offset_with_cast.rs:24:9 + --> $DIR/ptr_offset_with_cast.rs:23:9 | -24 | ptr.wrapping_offset(offset_usize as isize); +23 | ptr.wrapping_offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)` error: aborting due to 2 previous errors diff --git a/tests/ui/question_mark.stderr b/tests/ui/question_mark.stderr index 7ca76e38192..d3daaaa9270 100644 --- a/tests/ui/question_mark.stderr +++ b/tests/ui/question_mark.stderr @@ -1,21 +1,19 @@ error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:12:2 + --> $DIR/question_mark.rs:11:5 | -12 | if a.is_none() { - | _____^ -13 | | return None -14 | | } +11 | / if a.is_none() { +12 | | return None; +13 | | } | |_____^ help: replace_it_with: `a?;` | = note: `-D clippy::question-mark` implied by `-D warnings` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:47:3 + --> $DIR/question_mark.rs:46:9 | -47 | if (self.opt).is_none() { - | _________^ -48 | | return None; -49 | | } +46 | / if (self.opt).is_none() { +47 | | return None; +48 | | } | |_________^ help: replace_it_with: `(self.opt)?;` error: aborting due to 2 previous errors diff --git a/tests/ui/range.stderr b/tests/ui/range.stderr index 2dc81b4f042..7b3c5ebc3e1 100644 --- a/tests/ui/range.stderr +++ b/tests/ui/range.stderr @@ -1,42 +1,42 @@ error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:20:13 + --> $DIR/range.rs:17:13 | -20 | let _ = (0..1).step_by(0); +17 | let _ = (0..1).step_by(0); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::iterator-step-by-zero` implied by `-D warnings` error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:24:13 + --> $DIR/range.rs:21:13 | -24 | let _ = (1..).step_by(0); +21 | let _ = (1..).step_by(0); | ^^^^^^^^^^^^^^^^ +error: Iterator::step_by(0) will panic at runtime + --> $DIR/range.rs:22:13 + | +22 | let _ = (1..=2).step_by(0); + | ^^^^^^^^^^^^^^^^^^ + error: Iterator::step_by(0) will panic at runtime --> $DIR/range.rs:25:13 | -25 | let _ = (1..=2).step_by(0); - | ^^^^^^^^^^^^^^^^^^ - -error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:28:13 - | -28 | let _ = x.step_by(0); +25 | let _ = x.step_by(0); | ^^^^^^^^^^^^ error: It is more idiomatic to use v1.iter().enumerate() - --> $DIR/range.rs:36:14 + --> $DIR/range.rs:33:14 | -36 | let _x = v1.iter().zip(0..v1.len()); +33 | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::range-zip-with-len` implied by `-D warnings` error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:40:13 + --> $DIR/range.rs:37:13 | -40 | let _ = v1.iter().step_by(2/3); - | ^^^^^^^^^^^^^^^^^^^^^^ +37 | let _ = v1.iter().step_by(2 / 3); + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/range_plus_minus_one.stderr b/tests/ui/range_plus_minus_one.stderr index 0cac21734dc..dc49420ecb9 100644 --- a/tests/ui/range_plus_minus_one.stderr +++ b/tests/ui/range_plus_minus_one.stderr @@ -1,54 +1,54 @@ error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:22:14 + --> $DIR/range_plus_minus_one.rs:19:14 | -22 | for _ in 0..3+1 { } - | ^^^^^^ help: use: `0..=3` +19 | for _ in 0..3 + 1 {} + | ^^^^^^^^ help: use: `0..=3` | = note: `-D clippy::range-plus-one` implied by `-D warnings` +error: an inclusive range would be more readable + --> $DIR/range_plus_minus_one.rs:22:14 + | +22 | for _ in 0..1 + 5 {} + | ^^^^^^^^ help: use: `0..=5` + error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:25:14 | -25 | for _ in 0..1+5 { } - | ^^^^^^ help: use: `0..=5` +25 | for _ in 1..1 + 1 {} + | ^^^^^^^^ help: use: `1..=1` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:28:14 + --> $DIR/range_plus_minus_one.rs:31:14 | -28 | for _ in 1..1+1 { } - | ^^^^^^ help: use: `1..=1` - -error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:34:14 - | -34 | for _ in 0..(1+f()) { } - | ^^^^^^^^^^ help: use: `0..=f()` +31 | for _ in 0..(1 + f()) {} + | ^^^^^^^^^^^^ help: use: `0..=f()` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:38:13 + --> $DIR/range_plus_minus_one.rs:35:13 | -38 | let _ = ..=11-1; - | ^^^^^^^ help: use: `..11` +35 | let _ = ..=11 - 1; + | ^^^^^^^^^ help: use: `..11` | = note: `-D clippy::range-minus-one` implied by `-D warnings` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:39:13 + --> $DIR/range_plus_minus_one.rs:36:13 | -39 | let _ = ..=(11-1); - | ^^^^^^^^^ help: use: `..11` +36 | let _ = ..=(11 - 1); + | ^^^^^^^^^^^ help: use: `..11` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:40:13 + --> $DIR/range_plus_minus_one.rs:37:13 | -40 | let _ = (1..11+1); - | ^^^^^^^^^ help: use: `(1..=11)` +37 | let _ = (1..11 + 1); + | ^^^^^^^^^^^ help: use: `(1..=11)` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:41:13 + --> $DIR/range_plus_minus_one.rs:38:13 | -41 | let _ = (f()+1)..(f()+1); - | ^^^^^^^^^^^^^^^^ help: use: `((f()+1)..=f())` +38 | let _ = (f() + 1)..(f() + 1); + | ^^^^^^^^^^^^^^^^^^^^ help: use: `((f() + 1)..=f())` error: aborting due to 8 previous errors diff --git a/tests/ui/redundant_clone.stderr b/tests/ui/redundant_clone.stderr index db452822f89..2130d2a6fe1 100644 --- a/tests/ui/redundant_clone.stderr +++ b/tests/ui/redundant_clone.stderr @@ -96,15 +96,15 @@ note: this value is dropped without further use | ^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:43:22 + --> $DIR/redundant_clone.rs:44:22 | -43 | (a.clone(), a.clone()) +44 | (a.clone(), a.clone()) | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:43:21 + --> $DIR/redundant_clone.rs:44:21 | -43 | (a.clone(), a.clone()) +44 | (a.clone(), a.clone()) | ^ error: aborting due to 9 previous errors diff --git a/tests/ui/redundant_closure_call.stderr b/tests/ui/redundant_closure_call.stderr index 1563de3d74f..0d49f1a4066 100644 --- a/tests/ui/redundant_closure_call.stderr +++ b/tests/ui/redundant_closure_call.stderr @@ -1,34 +1,34 @@ error: Closure called just once immediately after it was declared - --> $DIR/redundant_closure_call.rs:25:2 + --> $DIR/redundant_closure_call.rs:21:5 | -25 | i = closure(); +21 | i = closure(); | ^^^^^^^^^^^^^ | = note: `-D clippy::redundant-closure-call` implied by `-D warnings` error: Closure called just once immediately after it was declared - --> $DIR/redundant_closure_call.rs:28:2 + --> $DIR/redundant_closure_call.rs:24:5 | -28 | i = closure(3); +24 | i = closure(3); | ^^^^^^^^^^^^^^ error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:17:10 + --> $DIR/redundant_closure_call.rs:13:13 | -17 | let a = (|| 42)(); +13 | let a = (|| 42)(); | ^^^^^^^^^ help: Try doing something like: : `42` error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:20:14 + --> $DIR/redundant_closure_call.rs:16:17 | -20 | let mut k = (|m| m+1)(i); - | ^^^^^^^^^^^^ +16 | let mut k = (|m| m + 1)(i); + | ^^^^^^^^^^^^^^ error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:22:6 + --> $DIR/redundant_closure_call.rs:18:9 | -22 | k = (|a,b| a*b)(1,5); - | ^^^^^^^^^^^^^^^^ +18 | k = (|a, b| a * b)(1, 5); + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/redundant_field_names.stderr b/tests/ui/redundant_field_names.stderr index d81ddf343f1..7febaa61b71 100644 --- a/tests/ui/redundant_field_names.stderr +++ b/tests/ui/redundant_field_names.stderr @@ -1,45 +1,45 @@ error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:46:9 + --> $DIR/redundant_field_names.rs:43:9 | -46 | gender: gender, +43 | gender: gender, | ^^^^^^^^^^^^^^ help: replace it with: `gender` | = note: `-D clippy::redundant-field-names` implied by `-D warnings` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:47:9 + --> $DIR/redundant_field_names.rs:44:9 | -47 | age: age, +44 | age: age, | ^^^^^^^^ help: replace it with: `age` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:68:25 + --> $DIR/redundant_field_names.rs:65:25 | -68 | let _ = RangeFrom { start: start }; +65 | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:69:23 + --> $DIR/redundant_field_names.rs:66:23 | -69 | let _ = RangeTo { end: end }; +66 | let _ = RangeTo { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:70:21 + --> $DIR/redundant_field_names.rs:67:21 | -70 | let _ = Range { start: start, end: end }; +67 | let _ = Range { start: start, end: end }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:70:35 + --> $DIR/redundant_field_names.rs:67:35 | -70 | let _ = Range { start: start, end: end }; +67 | let _ = Range { start: start, end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:72:32 + --> $DIR/redundant_field_names.rs:69:32 | -72 | let _ = RangeToInclusive { end: end }; +69 | let _ = RangeToInclusive { end: end }; | ^^^^^^^^ help: replace it with: `end` error: aborting due to 7 previous errors diff --git a/tests/ui/redundant_pattern_matching.stderr b/tests/ui/redundant_pattern_matching.stderr index a42ac7ba04d..2d2aa88d76d 100644 --- a/tests/ui/redundant_pattern_matching.stderr +++ b/tests/ui/redundant_pattern_matching.stderr @@ -1,87 +1,81 @@ error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching.rs:19:12 + --> $DIR/redundant_pattern_matching.rs:14:12 | -19 | if let Ok(_) = Ok::(42) {} +14 | if let Ok(_) = Ok::(42) {} | -------^^^^^------------------------ help: try this: `if Ok::(42).is_ok()` | = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching.rs:21:12 + --> $DIR/redundant_pattern_matching.rs:16:12 | -21 | if let Err(_) = Err::(42) { - | _____- ^^^^^^ -22 | | } - | |_____- help: try this: `if Err::(42).is_err()` +16 | if let Err(_) = Err::(42) {} + | -------^^^^^^------------------------- help: try this: `if Err::(42).is_err()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching.rs:24:12 + --> $DIR/redundant_pattern_matching.rs:18:12 | -24 | if let None = None::<()> { - | _____- ^^^^ -25 | | } - | |_____- help: try this: `if None::<()>.is_none()` +18 | if let None = None::<()> {} + | -------^^^^---------------- help: try this: `if None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching.rs:27:12 + --> $DIR/redundant_pattern_matching.rs:20:12 | -27 | if let Some(_) = Some(42) { - | _____- ^^^^^^^ -28 | | } - | |_____- help: try this: `if Some(42).is_some()` +20 | if let Some(_) = Some(42) {} + | -------^^^^^^^-------------- help: try this: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching.rs:46:5 + --> $DIR/redundant_pattern_matching.rs:34:5 | -46 | / match Ok::(42) { -47 | | Ok(_) => true, -48 | | Err(_) => false, -49 | | }; +34 | / match Ok::(42) { +35 | | Ok(_) => true, +36 | | Err(_) => false, +37 | | }; | |_____^ help: try this: `Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching.rs:51:5 + --> $DIR/redundant_pattern_matching.rs:39:5 | -51 | / match Ok::(42) { -52 | | Ok(_) => false, -53 | | Err(_) => true, -54 | | }; +39 | / match Ok::(42) { +40 | | Ok(_) => false, +41 | | Err(_) => true, +42 | | }; | |_____^ help: try this: `Ok::(42).is_err()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching.rs:56:5 + --> $DIR/redundant_pattern_matching.rs:44:5 | -56 | / match Err::(42) { -57 | | Ok(_) => false, -58 | | Err(_) => true, -59 | | }; +44 | / match Err::(42) { +45 | | Ok(_) => false, +46 | | Err(_) => true, +47 | | }; | |_____^ help: try this: `Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching.rs:61:5 + --> $DIR/redundant_pattern_matching.rs:49:5 | -61 | / match Err::(42) { -62 | | Ok(_) => true, -63 | | Err(_) => false, -64 | | }; +49 | / match Err::(42) { +50 | | Ok(_) => true, +51 | | Err(_) => false, +52 | | }; | |_____^ help: try this: `Err::(42).is_ok()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching.rs:66:5 + --> $DIR/redundant_pattern_matching.rs:54:5 | -66 | / match Some(42) { -67 | | Some(_) => true, -68 | | None => false, -69 | | }; +54 | / match Some(42) { +55 | | Some(_) => true, +56 | | None => false, +57 | | }; | |_____^ help: try this: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching.rs:71:5 + --> $DIR/redundant_pattern_matching.rs:59:5 | -71 | / match None::<()> { -72 | | Some(_) => false, -73 | | None => true, -74 | | }; +59 | / match None::<()> { +60 | | Some(_) => false, +61 | | None => true, +62 | | }; | |_____^ help: try this: `None::<()>.is_none()` error: aborting due to 10 previous errors diff --git a/tests/ui/reference.stderr b/tests/ui/reference.stderr index 4187d55cb47..c09a31e2d8a 100644 --- a/tests/ui/reference.stderr +++ b/tests/ui/reference.stderr @@ -1,69 +1,69 @@ error: immediately dereferencing a reference - --> $DIR/reference.rs:29:13 + --> $DIR/reference.rs:25:13 | -29 | let b = *&a; +25 | let b = *&a; | ^^^ help: try this: `a` | = note: `-D clippy::deref-addrof` implied by `-D warnings` error: immediately dereferencing a reference - --> $DIR/reference.rs:31:13 + --> $DIR/reference.rs:27:13 | -31 | let b = *&get_number(); +27 | let b = *&get_number(); | ^^^^^^^^^^^^^^ help: try this: `get_number()` +error: immediately dereferencing a reference + --> $DIR/reference.rs:32:13 + | +32 | let b = *&bytes[1..2][0]; + | ^^^^^^^^^^^^^^^^ help: try this: `bytes[1..2][0]` + error: immediately dereferencing a reference --> $DIR/reference.rs:36:13 | -36 | let b = *&bytes[1..2][0]; - | ^^^^^^^^^^^^^^^^ help: try this: `bytes[1..2][0]` +36 | let b = *&(a); + | ^^^^^ help: try this: `(a)` + +error: immediately dereferencing a reference + --> $DIR/reference.rs:38:13 + | +38 | let b = *(&a); + | ^^^^^ help: try this: `a` error: immediately dereferencing a reference --> $DIR/reference.rs:40:13 | -40 | let b = *&(a); - | ^^^^^ help: try this: `(a)` +40 | let b = *(&a); + | ^^^^^ help: try this: `a` error: immediately dereferencing a reference --> $DIR/reference.rs:42:13 | -42 | let b = *(&a); - | ^^^^^ help: try this: `a` - -error: immediately dereferencing a reference - --> $DIR/reference.rs:44:13 - | -44 | let b = *((&a)); - | ^^^^^^^ help: try this: `a` - -error: immediately dereferencing a reference - --> $DIR/reference.rs:46:13 - | -46 | let b = *&&a; +42 | let b = *&&a; | ^^^^ help: try this: `&a` +error: immediately dereferencing a reference + --> $DIR/reference.rs:44:14 + | +44 | let b = **&aref; + | ^^^^^^ help: try this: `aref` + error: immediately dereferencing a reference --> $DIR/reference.rs:48:14 | -48 | let b = **&aref; - | ^^^^^^ help: try this: `aref` - -error: immediately dereferencing a reference - --> $DIR/reference.rs:52:14 - | -52 | let b = **&&a; +48 | let b = **&&a; | ^^^^ help: try this: `&a` error: immediately dereferencing a reference - --> $DIR/reference.rs:56:17 + --> $DIR/reference.rs:52:17 | -56 | let y = *&mut x; +52 | let y = *&mut x; | ^^^^^^^ help: try this: `x` error: immediately dereferencing a reference - --> $DIR/reference.rs:63:18 + --> $DIR/reference.rs:59:18 | -63 | let y = **&mut &mut x; +59 | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try this: `&mut x` error: aborting due to 11 previous errors diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index 1da859dea5c..680cc5146e5 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -1,168 +1,168 @@ error: trivial regex - --> $DIR/regex.rs:26:45 + --> $DIR/regex.rs:22:45 | -26 | let pipe_in_wrong_position = Regex::new("|"); +22 | let pipe_in_wrong_position = Regex::new("|"); | ^^^ | = note: `-D clippy::trivial-regex` implied by `-D warnings` = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:27:60 + --> $DIR/regex.rs:23:60 | -27 | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); +23 | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); | ^^^ | = help: the regex is unlikely to be useful as it is error: regex syntax error: invalid character class range, the start must be <= the end - --> $DIR/regex.rs:28:42 + --> $DIR/regex.rs:24:42 | -28 | let wrong_char_ranice = Regex::new("[z-a]"); +24 | let wrong_char_ranice = Regex::new("[z-a]"); | ^^^ | = note: `-D clippy::invalid-regex` implied by `-D warnings` error: regex syntax error: invalid character class range, the start must be <= the end - --> $DIR/regex.rs:29:37 + --> $DIR/regex.rs:25:37 | -29 | let some_unicode = Regex::new("[é-è]"); +25 | let some_unicode = Regex::new("[é-è]"); | ^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:31:33 + --> $DIR/regex.rs:27:33 | -31 | let some_regex = Regex::new(OPENING_PAREN); +27 | let some_regex = Regex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: trivial regex - --> $DIR/regex.rs:33:53 + --> $DIR/regex.rs:29:53 | -33 | let binary_pipe_in_wrong_position = BRegex::new("|"); +29 | let binary_pipe_in_wrong_position = BRegex::new("|"); | ^^^ | = help: the regex is unlikely to be useful as it is error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:34:41 + --> $DIR/regex.rs:30:41 | -34 | let some_binary_regex = BRegex::new(OPENING_PAREN); +30 | let some_binary_regex = BRegex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:35:56 + --> $DIR/regex.rs:31:56 | -35 | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); +31 | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:51:9 + --> $DIR/regex.rs:43:37 | -51 | OPENING_PAREN, - | ^^^^^^^^^^^^^ +43 | let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); + | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:55:9 + --> $DIR/regex.rs:44:39 | -55 | OPENING_PAREN, - | ^^^^^^^^^^^^^ +44 | let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); + | ^^^^^^^^^^^^^ error: regex syntax error: unrecognized escape sequence - --> $DIR/regex.rs:59:45 + --> $DIR/regex.rs:46:45 | -59 | let raw_string_error = Regex::new(r"[...//...]"); +46 | let raw_string_error = Regex::new(r"[...//...]"); | ^^ error: regex syntax error: unrecognized escape sequence - --> $DIR/regex.rs:60:46 + --> $DIR/regex.rs:47:46 | -60 | let raw_string_error = Regex::new(r#"[...//...]"#); +47 | let raw_string_error = Regex::new(r#"[...//...]"#); | ^^ error: trivial regex - --> $DIR/regex.rs:64:33 + --> $DIR/regex.rs:51:33 | -64 | let trivial_eq = Regex::new("^foobar$"); +51 | let trivial_eq = Regex::new("^foobar$"); | ^^^^^^^^^^ | = help: consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:66:48 + --> $DIR/regex.rs:53:48 | -66 | let trivial_eq_builder = RegexBuilder::new("^foobar$"); +53 | let trivial_eq_builder = RegexBuilder::new("^foobar$"); | ^^^^^^^^^^ | = help: consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:68:42 + --> $DIR/regex.rs:55:42 | -68 | let trivial_starts_with = Regex::new("^foobar"); +55 | let trivial_starts_with = Regex::new("^foobar"); | ^^^^^^^^^ | = help: consider using `str::starts_with` error: trivial regex - --> $DIR/regex.rs:70:40 + --> $DIR/regex.rs:57:40 | -70 | let trivial_ends_with = Regex::new("foobar$"); +57 | let trivial_ends_with = Regex::new("foobar$"); | ^^^^^^^^^ | = help: consider using `str::ends_with` error: trivial regex - --> $DIR/regex.rs:72:39 + --> $DIR/regex.rs:59:39 | -72 | let trivial_contains = Regex::new("foobar"); +59 | let trivial_contains = Regex::new("foobar"); | ^^^^^^^^ | = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:74:39 + --> $DIR/regex.rs:61:39 | -74 | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); +61 | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); | ^^^^^^^^^^^^^^^^ | = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:76:40 + --> $DIR/regex.rs:63:40 | -76 | let trivial_backslash = Regex::new("a/.b"); +63 | let trivial_backslash = Regex::new("a/.b"); | ^^^^^^^ | = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:79:36 + --> $DIR/regex.rs:66:36 | -79 | let trivial_empty = Regex::new(""); +66 | let trivial_empty = Regex::new(""); | ^^ | = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:81:36 + --> $DIR/regex.rs:68:36 | -81 | let trivial_empty = Regex::new("^"); +68 | let trivial_empty = Regex::new("^"); | ^^^ | = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:83:36 + --> $DIR/regex.rs:70:36 | -83 | let trivial_empty = Regex::new("^$"); +70 | let trivial_empty = Regex::new("^$"); | ^^^^ | = help: consider using `str::is_empty` error: trivial regex - --> $DIR/regex.rs:85:44 + --> $DIR/regex.rs:72:44 | -85 | let binary_trivial_empty = BRegex::new("^$"); +72 | let binary_trivial_empty = BRegex::new("^$"); | ^^^^ | = help: consider using `str::is_empty` diff --git a/tests/ui/replace_consts.stderr b/tests/ui/replace_consts.stderr index 5b8451e046c..401e3a527a6 100644 --- a/tests/ui/replace_consts.stderr +++ b/tests/ui/replace_consts.stderr @@ -1,217 +1,217 @@ error: using `ATOMIC_BOOL_INIT` - --> $DIR/replace_consts.rs:23:17 + --> $DIR/replace_consts.rs:22:17 | -23 | { let foo = ATOMIC_BOOL_INIT; }; +22 | { let foo = ATOMIC_BOOL_INIT; }; | ^^^^^^^^^^^^^^^^ help: try this: `AtomicBool::new(false)` | note: lint level defined here - --> $DIR/replace_consts.rs:13:9 + --> $DIR/replace_consts.rs:12:9 | -13 | #![deny(clippy::replace_consts)] +12 | #![deny(clippy::replace_consts)] | ^^^^^^^^^^^^^^^^^^^^^^ error: using `ATOMIC_ISIZE_INIT` - --> $DIR/replace_consts.rs:24:17 + --> $DIR/replace_consts.rs:23:17 | -24 | { let foo = ATOMIC_ISIZE_INIT; }; +23 | { let foo = ATOMIC_ISIZE_INIT; }; | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicIsize::new(0)` error: using `ATOMIC_I8_INIT` - --> $DIR/replace_consts.rs:25:17 + --> $DIR/replace_consts.rs:24:17 | -25 | { let foo = ATOMIC_I8_INIT; }; +24 | { let foo = ATOMIC_I8_INIT; }; | ^^^^^^^^^^^^^^ help: try this: `AtomicI8::new(0)` error: using `ATOMIC_I16_INIT` - --> $DIR/replace_consts.rs:26:17 + --> $DIR/replace_consts.rs:25:17 | -26 | { let foo = ATOMIC_I16_INIT; }; +25 | { let foo = ATOMIC_I16_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI16::new(0)` error: using `ATOMIC_I32_INIT` - --> $DIR/replace_consts.rs:27:17 + --> $DIR/replace_consts.rs:26:17 | -27 | { let foo = ATOMIC_I32_INIT; }; +26 | { let foo = ATOMIC_I32_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI32::new(0)` error: using `ATOMIC_I64_INIT` - --> $DIR/replace_consts.rs:28:17 + --> $DIR/replace_consts.rs:27:17 | -28 | { let foo = ATOMIC_I64_INIT; }; +27 | { let foo = ATOMIC_I64_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI64::new(0)` error: using `ATOMIC_USIZE_INIT` - --> $DIR/replace_consts.rs:29:17 + --> $DIR/replace_consts.rs:28:17 | -29 | { let foo = ATOMIC_USIZE_INIT; }; +28 | { let foo = ATOMIC_USIZE_INIT; }; | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicUsize::new(0)` error: using `ATOMIC_U8_INIT` - --> $DIR/replace_consts.rs:30:17 + --> $DIR/replace_consts.rs:29:17 | -30 | { let foo = ATOMIC_U8_INIT; }; +29 | { let foo = ATOMIC_U8_INIT; }; | ^^^^^^^^^^^^^^ help: try this: `AtomicU8::new(0)` error: using `ATOMIC_U16_INIT` - --> $DIR/replace_consts.rs:31:17 + --> $DIR/replace_consts.rs:30:17 | -31 | { let foo = ATOMIC_U16_INIT; }; +30 | { let foo = ATOMIC_U16_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU16::new(0)` error: using `ATOMIC_U32_INIT` - --> $DIR/replace_consts.rs:32:17 + --> $DIR/replace_consts.rs:31:17 | -32 | { let foo = ATOMIC_U32_INIT; }; +31 | { let foo = ATOMIC_U32_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU32::new(0)` error: using `ATOMIC_U64_INIT` - --> $DIR/replace_consts.rs:33:17 + --> $DIR/replace_consts.rs:32:17 | -33 | { let foo = ATOMIC_U64_INIT; }; +32 | { let foo = ATOMIC_U64_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU64::new(0)` +error: using `MIN` + --> $DIR/replace_consts.rs:34:17 + | +34 | { let foo = std::isize::MIN; }; + | ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()` + error: using `MIN` --> $DIR/replace_consts.rs:35:17 | -35 | { let foo = std::isize::MIN; }; - | ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()` +35 | { let foo = std::i8::MIN; }; + | ^^^^^^^^^^^^ help: try this: `i8::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:36:17 | -36 | { let foo = std::i8::MIN; }; - | ^^^^^^^^^^^^ help: try this: `i8::min_value()` +36 | { let foo = std::i16::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `i16::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:37:17 | -37 | { let foo = std::i16::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `i16::min_value()` +37 | { let foo = std::i32::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `i32::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:38:17 | -38 | { let foo = std::i32::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `i32::min_value()` +38 | { let foo = std::i64::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `i64::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:39:17 | -39 | { let foo = std::i64::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `i64::min_value()` +39 | { let foo = std::i128::MIN; }; + | ^^^^^^^^^^^^^^ help: try this: `i128::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:40:17 | -40 | { let foo = std::i128::MIN; }; - | ^^^^^^^^^^^^^^ help: try this: `i128::min_value()` +40 | { let foo = std::usize::MIN; }; + | ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:41:17 | -41 | { let foo = std::usize::MIN; }; - | ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()` +41 | { let foo = std::u8::MIN; }; + | ^^^^^^^^^^^^ help: try this: `u8::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:42:17 | -42 | { let foo = std::u8::MIN; }; - | ^^^^^^^^^^^^ help: try this: `u8::min_value()` +42 | { let foo = std::u16::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `u16::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:43:17 | -43 | { let foo = std::u16::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `u16::min_value()` +43 | { let foo = std::u32::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `u32::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:44:17 | -44 | { let foo = std::u32::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `u32::min_value()` +44 | { let foo = std::u64::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `u64::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:45:17 | -45 | { let foo = std::u64::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `u64::min_value()` - -error: using `MIN` - --> $DIR/replace_consts.rs:46:17 - | -46 | { let foo = std::u128::MIN; }; +45 | { let foo = std::u128::MIN; }; | ^^^^^^^^^^^^^^ help: try this: `u128::min_value()` +error: using `MAX` + --> $DIR/replace_consts.rs:47:17 + | +47 | { let foo = std::isize::MAX; }; + | ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()` + error: using `MAX` --> $DIR/replace_consts.rs:48:17 | -48 | { let foo = std::isize::MAX; }; - | ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()` +48 | { let foo = std::i8::MAX; }; + | ^^^^^^^^^^^^ help: try this: `i8::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:49:17 | -49 | { let foo = std::i8::MAX; }; - | ^^^^^^^^^^^^ help: try this: `i8::max_value()` +49 | { let foo = std::i16::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `i16::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:50:17 | -50 | { let foo = std::i16::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `i16::max_value()` +50 | { let foo = std::i32::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `i32::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:51:17 | -51 | { let foo = std::i32::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `i32::max_value()` +51 | { let foo = std::i64::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `i64::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:52:17 | -52 | { let foo = std::i64::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `i64::max_value()` +52 | { let foo = std::i128::MAX; }; + | ^^^^^^^^^^^^^^ help: try this: `i128::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:53:17 | -53 | { let foo = std::i128::MAX; }; - | ^^^^^^^^^^^^^^ help: try this: `i128::max_value()` +53 | { let foo = std::usize::MAX; }; + | ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:54:17 | -54 | { let foo = std::usize::MAX; }; - | ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()` +54 | { let foo = std::u8::MAX; }; + | ^^^^^^^^^^^^ help: try this: `u8::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:55:17 | -55 | { let foo = std::u8::MAX; }; - | ^^^^^^^^^^^^ help: try this: `u8::max_value()` +55 | { let foo = std::u16::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `u16::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:56:17 | -56 | { let foo = std::u16::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `u16::max_value()` +56 | { let foo = std::u32::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `u32::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:57:17 | -57 | { let foo = std::u32::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `u32::max_value()` +57 | { let foo = std::u64::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `u64::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:58:17 | -58 | { let foo = std::u64::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `u64::max_value()` - -error: using `MAX` - --> $DIR/replace_consts.rs:59:17 - | -59 | { let foo = std::u128::MAX; }; +58 | { let foo = std::u128::MAX; }; | ^^^^^^^^^^^^^^ help: try this: `u128::max_value()` error: aborting due to 35 previous errors diff --git a/tests/ui/result_map_unit_fn.stderr b/tests/ui/result_map_unit_fn.stderr index 04f105c78e2..1ef107a5000 100644 --- a/tests/ui/result_map_unit_fn.stderr +++ b/tests/ui/result_map_unit_fn.stderr @@ -1,7 +1,7 @@ error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:45:5 + --> $DIR/result_map_unit_fn.rs:42:5 | -45 | x.field.map(do_nothing); +42 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` @@ -9,36 +9,41 @@ error: called `map(f)` on an Result value where `f` is a unit function = note: `-D clippy::result-map-unit-fn` implied by `-D warnings` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:47:5 + --> $DIR/result_map_unit_fn.rs:44:5 | -47 | x.field.map(do_nothing); +44 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:49:5 + --> $DIR/result_map_unit_fn.rs:46:5 | -49 | x.field.map(diverge); +46 | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:55:5 + --> $DIR/result_map_unit_fn.rs:54:5 | -55 | x.field.map(|value| x.do_result_nothing(value + captured)); +54 | x.field.map(|value| x.do_result_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:57:5 + --> $DIR/result_map_unit_fn.rs:56:5 | -57 | x.field.map(|value| { x.do_result_plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` +56 | x.field.map(|value| { + | _____^ + | |_____| + | || +57 | || x.do_result_plus_one(value + captured); +58 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:60:5 @@ -51,141 +56,196 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:62:5 | -62 | x.field.map(|value| { do_nothing(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +62 | x.field.map(|value| do_nothing(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:64:5 | -64 | x.field.map(|value| { do_nothing(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` +64 | x.field.map(|value| { + | _____^ + | |_____| + | || +65 | || do_nothing(value + captured); +66 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:66:5 + --> $DIR/result_map_unit_fn.rs:68:5 | -66 | x.field.map(|value| { { do_nothing(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` +68 | x.field.map(|value| { + | _____^ + | |_____| + | || +69 | || do_nothing(value + captured); +70 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:69:5 + --> $DIR/result_map_unit_fn.rs:72:5 | -69 | x.field.map(|value| diverge(value + captured)); +72 | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:71:5 + --> $DIR/result_map_unit_fn.rs:74:5 | -71 | x.field.map(|value| { diverge(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +74 | x.field.map(|value| diverge(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:73:5 + --> $DIR/result_map_unit_fn.rs:76:5 | -73 | x.field.map(|value| { diverge(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:75:5 - | -75 | x.field.map(|value| { { diverge(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:80:5 - | -80 | x.field.map(|value| { let y = plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:82:5 - | -82 | x.field.map(|value| { plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:84:5 - | -84 | x.field.map(|value| { { plus_one(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:87:5 - | -87 | x.field.map(|ref value| { do_nothing(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:90:5 - | -90 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { ... }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:92:5 - | -92 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { ... }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:96:5 - | -96 | x.field.map(|value| { +76 | x.field.map(|value| { | _____^ | |_____| | || -97 | || do_nothing(value); -98 | || do_nothing(value) -99 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { ... }` +77 | || diverge(value + captured); +78 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` | |_______| | +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:80:5 + | +80 | x.field.map(|value| { + | _____^ + | |_____| + | || +81 | || diverge(value + captured); +82 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` + | |_______| + | + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:86:5 + | +86 | x.field.map(|value| { + | _____^ + | |_____| + | || +87 | || let y = plus_one(value + captured); +88 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` + | |_______| + | + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:90:5 + | +90 | x.field.map(|value| { + | _____^ + | |_____| + | || +91 | || plus_one(value + captured); +92 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` + | |_______| + | + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:94:5 + | +94 | x.field.map(|value| { + | _____^ + | |_____| + | || +95 | || plus_one(value + captured); +96 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` + | |_______| + | + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:98:5 + | +98 | x.field.map(|ref value| do_nothing(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` + error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:100:5 | -100 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { ... }` +100 | x.field.map(|value| { + | _____^ + | |_____| + | || +101 | || do_nothing(value); +102 | || do_nothing(value) +103 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { ... }` + | |_______| + | + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:105:5 + | +105 | x.field.map(|value| { + | _____^ + | |_____| + | || +106 | || if value > 0 { +107 | || do_nothing(value); +108 | || do_nothing(value) +109 | || } +110 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { ... }` + | |_______| + | + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:114:5 + | +114 | x.field.map(|value| { + | _____^ + | |_____| + | || +115 | || do_nothing(value); +116 | || do_nothing(value) +117 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { ... }` + | |_______| + | + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:118:5 + | +118 | x.field.map(|value| { + | _____^ + | |_____| + | || +119 | || do_nothing(value); +120 | || do_nothing(value); +121 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { ... }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:104:5 + --> $DIR/result_map_unit_fn.rs:126:5 | -104 | "12".parse::().map(diverge); +126 | "12".parse::().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(_) = "12".parse::() { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:110:5 + --> $DIR/result_map_unit_fn.rs:132:5 | -110 | y.map(do_nothing); +132 | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(_y) = y { do_nothing(...) }` diff --git a/tests/ui/serde.stderr b/tests/ui/serde.stderr index e223430e680..23f10f69435 100644 --- a/tests/ui/serde.stderr +++ b/tests/ui/serde.stderr @@ -1,8 +1,9 @@ error: you should not implement `visit_string` without also implementing `visit_str` - --> $DIR/serde.rs:49:5 + --> $DIR/serde.rs:48:5 | -49 | / fn visit_string(self, _v: String) -> Result -50 | | where E: serde::de::Error, +48 | / fn visit_string(self, _v: String) -> Result +49 | | where +50 | | E: serde::de::Error, 51 | | { 52 | | unimplemented!() 53 | | } diff --git a/tests/ui/shadow.stderr b/tests/ui/shadow.stderr index adca299d382..196f17ac653 100644 --- a/tests/ui/shadow.stderr +++ b/tests/ui/shadow.stderr @@ -1,137 +1,137 @@ error: `x` is shadowed by itself in `&mut x` - --> $DIR/shadow.rs:23:5 + --> $DIR/shadow.rs:29:5 | -23 | let x = &mut x; +29 | let x = &mut x; | ^^^^^^^^^^^^^^^ | = note: `-D clippy::shadow-same` implied by `-D warnings` note: previous binding is here - --> $DIR/shadow.rs:22:13 + --> $DIR/shadow.rs:28:13 | -22 | let mut x = 1; +28 | let mut x = 1; | ^ error: `x` is shadowed by itself in `{ x }` - --> $DIR/shadow.rs:24:5 + --> $DIR/shadow.rs:30:5 | -24 | let x = { x }; +30 | let x = { x }; | ^^^^^^^^^^^^^^ | note: previous binding is here - --> $DIR/shadow.rs:23:9 + --> $DIR/shadow.rs:29:9 | -23 | let x = &mut x; +29 | let x = &mut x; | ^ error: `x` is shadowed by itself in `(&*x)` - --> $DIR/shadow.rs:25:5 + --> $DIR/shadow.rs:31:5 | -25 | let x = (&*x); +31 | let x = (&*x); | ^^^^^^^^^^^^^^ | note: previous binding is here - --> $DIR/shadow.rs:24:9 + --> $DIR/shadow.rs:30:9 | -24 | let x = { x }; +30 | let x = { x }; | ^ error: `x` is shadowed by `{ *x + 1 }` which reuses the original value - --> $DIR/shadow.rs:26:9 + --> $DIR/shadow.rs:32:9 | -26 | let x = { *x + 1 }; +32 | let x = { *x + 1 }; | ^ | = note: `-D clippy::shadow-reuse` implied by `-D warnings` note: initialization happens here - --> $DIR/shadow.rs:26:13 + --> $DIR/shadow.rs:32:13 | -26 | let x = { *x + 1 }; +32 | let x = { *x + 1 }; | ^^^^^^^^^^ note: previous binding is here - --> $DIR/shadow.rs:25:9 + --> $DIR/shadow.rs:31:9 | -25 | let x = (&*x); +31 | let x = (&*x); | ^ error: `x` is shadowed by `id(x)` which reuses the original value - --> $DIR/shadow.rs:27:9 + --> $DIR/shadow.rs:33:9 | -27 | let x = id(x); +33 | let x = id(x); | ^ | note: initialization happens here - --> $DIR/shadow.rs:27:13 + --> $DIR/shadow.rs:33:13 | -27 | let x = id(x); +33 | let x = id(x); | ^^^^^ note: previous binding is here - --> $DIR/shadow.rs:26:9 + --> $DIR/shadow.rs:32:9 | -26 | let x = { *x + 1 }; +32 | let x = { *x + 1 }; | ^ error: `x` is shadowed by `(1, x)` which reuses the original value - --> $DIR/shadow.rs:28:9 + --> $DIR/shadow.rs:34:9 | -28 | let x = (1, x); +34 | let x = (1, x); | ^ | note: initialization happens here - --> $DIR/shadow.rs:28:13 + --> $DIR/shadow.rs:34:13 | -28 | let x = (1, x); +34 | let x = (1, x); | ^^^^^^ note: previous binding is here - --> $DIR/shadow.rs:27:9 + --> $DIR/shadow.rs:33:9 | -27 | let x = id(x); +33 | let x = id(x); | ^ error: `x` is shadowed by `first(x)` which reuses the original value - --> $DIR/shadow.rs:29:9 + --> $DIR/shadow.rs:35:9 | -29 | let x = first(x); +35 | let x = first(x); | ^ | note: initialization happens here - --> $DIR/shadow.rs:29:13 + --> $DIR/shadow.rs:35:13 | -29 | let x = first(x); +35 | let x = first(x); | ^^^^^^^^ note: previous binding is here - --> $DIR/shadow.rs:28:9 + --> $DIR/shadow.rs:34:9 | -28 | let x = (1, x); +34 | let x = (1, x); | ^ error: `x` is shadowed by `y` - --> $DIR/shadow.rs:31:9 + --> $DIR/shadow.rs:37:9 | -31 | let x = y; +37 | let x = y; | ^ | = note: `-D clippy::shadow-unrelated` implied by `-D warnings` note: initialization happens here - --> $DIR/shadow.rs:31:13 + --> $DIR/shadow.rs:37:13 | -31 | let x = y; +37 | let x = y; | ^ note: previous binding is here - --> $DIR/shadow.rs:29:9 + --> $DIR/shadow.rs:35:9 | -29 | let x = first(x); +35 | let x = first(x); | ^ error: `x` shadows a previous declaration - --> $DIR/shadow.rs:33:5 + --> $DIR/shadow.rs:39:5 | -33 | let x; +39 | let x; | ^^^^^^ | note: previous binding is here - --> $DIR/shadow.rs:31:9 + --> $DIR/shadow.rs:37:9 | -31 | let x = y; +37 | let x = y; | ^ error: aborting due to 9 previous errors diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index 331bdac3128..7b5c843d072 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -1,21 +1,21 @@ error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:17:5 + --> $DIR/short_circuit_statement.rs:13:5 | -17 | f() && g(); +13 | f() && g(); | ^^^^^^^^^^^ help: replace it with: `if f() { g(); }` | = note: `-D clippy::short-circuit-statement` implied by `-D warnings` error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:18:5 + --> $DIR/short_circuit_statement.rs:14:5 | -18 | f() || g(); +14 | f() || g(); | ^^^^^^^^^^^ help: replace it with: `if !f() { g(); }` error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:19:5 + --> $DIR/short_circuit_statement.rs:15:5 | -19 | 1 == 2 || g(); +15 | 1 == 2 || g(); | ^^^^^^^^^^^^^^ help: replace it with: `if !(1 == 2) { g(); }` error: aborting due to 3 previous errors diff --git a/tests/ui/single_char_pattern.stderr b/tests/ui/single_char_pattern.stderr index ff657df1bf8..273bf779640 100644 --- a/tests/ui/single_char_pattern.stderr +++ b/tests/ui/single_char_pattern.stderr @@ -1,123 +1,123 @@ error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:17:13 + --> $DIR/single_char_pattern.rs:14:13 | -17 | x.split("x"); +14 | x.split("x"); | ^^^ help: try using a char instead: `'x'` | = note: `-D clippy::single-char-pattern` implied by `-D warnings` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:34:16 + --> $DIR/single_char_pattern.rs:31:16 | -34 | x.contains("x"); +31 | x.contains("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:35:19 + --> $DIR/single_char_pattern.rs:32:19 | -35 | x.starts_with("x"); +32 | x.starts_with("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:36:17 + --> $DIR/single_char_pattern.rs:33:17 | -36 | x.ends_with("x"); +33 | x.ends_with("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:37:12 + --> $DIR/single_char_pattern.rs:34:12 | -37 | x.find("x"); +34 | x.find("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:38:13 + --> $DIR/single_char_pattern.rs:35:13 | -38 | x.rfind("x"); +35 | x.rfind("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:39:14 + --> $DIR/single_char_pattern.rs:36:14 | -39 | x.rsplit("x"); +36 | x.rsplit("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:40:24 + --> $DIR/single_char_pattern.rs:37:24 | -40 | x.split_terminator("x"); +37 | x.split_terminator("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:41:25 + --> $DIR/single_char_pattern.rs:38:25 | -41 | x.rsplit_terminator("x"); +38 | x.rsplit_terminator("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:42:17 + --> $DIR/single_char_pattern.rs:39:17 | -42 | x.splitn(0, "x"); +39 | x.splitn(0, "x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:43:18 + --> $DIR/single_char_pattern.rs:40:18 | -43 | x.rsplitn(0, "x"); +40 | x.rsplitn(0, "x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:44:15 + --> $DIR/single_char_pattern.rs:41:15 | -44 | x.matches("x"); +41 | x.matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:45:16 + --> $DIR/single_char_pattern.rs:42:16 | -45 | x.rmatches("x"); +42 | x.rmatches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:46:21 + --> $DIR/single_char_pattern.rs:43:21 | -46 | x.match_indices("x"); +43 | x.match_indices("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:47:22 + --> $DIR/single_char_pattern.rs:44:22 | -47 | x.rmatch_indices("x"); +44 | x.rmatch_indices("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:48:25 + --> $DIR/single_char_pattern.rs:45:25 | -48 | x.trim_left_matches("x"); +45 | x.trim_left_matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:49:26 + --> $DIR/single_char_pattern.rs:46:26 | -49 | x.trim_right_matches("x"); +46 | x.trim_right_matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:51:13 + --> $DIR/single_char_pattern.rs:48:13 | -51 | x.split("/n"); +48 | x.split("/n"); | ^^^^ help: try using a char instead: `'/n'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:56:31 + --> $DIR/single_char_pattern.rs:53:31 | -56 | x.replace(";", ",").split(","); // issue #2978 +53 | x.replace(";", ",").split(","); // issue #2978 | ^^^ help: try using a char instead: `','` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:57:19 + --> $DIR/single_char_pattern.rs:54:19 | -57 | x.starts_with("/x03"); // issue #2996 +54 | x.starts_with("/x03"); // issue #2996 | ^^^^^^ help: try using a char instead: `'/x03'` error: aborting due to 20 previous errors diff --git a/tests/ui/single_match.stderr b/tests/ui/single_match.stderr index df614ad201d..45fcbce0047 100644 --- a/tests/ui/single_match.stderr +++ b/tests/ui/single_match.stderr @@ -1,60 +1,68 @@ error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:21:5 + --> $DIR/single_match.rs:17:5 | -21 | / match x { -22 | | Some(y) => { println!("{:?}", y); } -23 | | _ => () -24 | | }; - | |_____^ help: try this: `if let Some(y) = x { println!("{:?}", y); }` +17 | / match x { +18 | | Some(y) => { +19 | | println!("{:?}", y); +20 | | }, +21 | | _ => (), +22 | | }; + | |_____^ | = note: `-D clippy::single-match` implied by `-D warnings` +help: try this + | +17 | if let Some(y) = x { +18 | println!("{:?}", y); +19 | }; + | error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:27:5 + --> $DIR/single_match.rs:25:5 | -27 | / match x { -28 | | // Note the missing block braces. -29 | | // We suggest `if let Some(y) = x { .. }` because the macro -30 | | // is expanded before we can do anything. -31 | | Some(y) => println!("{:?}", y), -32 | | _ => () -33 | | } +25 | / match x { +26 | | // Note the missing block braces. +27 | | // We suggest `if let Some(y) = x { .. }` because the macro +28 | | // is expanded before we can do anything. +29 | | Some(y) => println!("{:?}", y), +30 | | _ => (), +31 | | } | |_____^ help: try this: `if let Some(y) = x { println!("{:?}", y) }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:36:5 + --> $DIR/single_match.rs:34:5 | -36 | / match z { -37 | | (2...3, 7...9) => dummy(), -38 | | _ => {} -39 | | }; +34 | / match z { +35 | | (2...3, 7...9) => dummy(), +36 | | _ => {}, +37 | | }; | |_____^ help: try this: `if let (2...3, 7...9) = z { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:62:5 + --> $DIR/single_match.rs:63:5 | -62 | / match x { -63 | | Some(y) => dummy(), -64 | | None => () -65 | | }; +63 | / match x { +64 | | Some(y) => dummy(), +65 | | None => (), +66 | | }; | |_____^ help: try this: `if let Some(y) = x { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:67:5 + --> $DIR/single_match.rs:68:5 | -67 | / match y { -68 | | Ok(y) => dummy(), -69 | | Err(..) => () -70 | | }; +68 | / match y { +69 | | Ok(y) => dummy(), +70 | | Err(..) => (), +71 | | }; | |_____^ help: try this: `if let Ok(y) = y { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:74:5 + --> $DIR/single_match.rs:75:5 | -74 | / match c { -75 | | Cow::Borrowed(..) => dummy(), -76 | | Cow::Owned(..) => (), -77 | | }; +75 | / match c { +76 | | Cow::Borrowed(..) => dummy(), +77 | | Cow::Owned(..) => (), +78 | | }; | |_____^ help: try this: `if let Cow::Borrowed(..) = c { dummy() }` error: aborting due to 6 previous errors diff --git a/tests/ui/single_match_else.stderr b/tests/ui/single_match_else.stderr index 0b488b2fcf4..6ae9dd1a818 100644 --- a/tests/ui/single_match_else.stderr +++ b/tests/ui/single_match_else.stderr @@ -3,11 +3,21 @@ error: you seem to be trying to use match for destructuring a single pattern. Co | 21 | / match ExprNode::Butterflies { 22 | | ExprNode::ExprAddrOf => Some(&NODE), -23 | | _ => { let x = 5; None }, -24 | | } - | |_____^ help: try this: `if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None }` +23 | | _ => { +24 | | let x = 5; +25 | | None +26 | | }, +27 | | } + | |_____^ | = note: `-D clippy::single-match-else` implied by `-D warnings` +help: try this + | +21 | if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { +22 | let x = 5; +23 | None +24 | } + | error: aborting due to previous error diff --git a/tests/ui/starts_ends_with.stderr b/tests/ui/starts_ends_with.stderr index 9921819e093..0b1b7c020d9 100644 --- a/tests/ui/starts_ends_with.stderr +++ b/tests/ui/starts_ends_with.stderr @@ -1,77 +1,77 @@ error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:19:5 + --> $DIR/starts_ends_with.rs:16:5 | -19 | "".chars().next() == Some(' '); +16 | "".chars().next() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with(' ')` | = note: `-D clippy::chars-next-cmp` implied by `-D warnings` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:20:5 + --> $DIR/starts_ends_with.rs:17:5 | -20 | Some(' ') != "".chars().next(); +17 | Some(' ') != "".chars().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with(' ')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:25:8 + --> $DIR/starts_ends_with.rs:22:8 | -25 | if s.chars().next().unwrap() == 'f' { // s.starts_with('f') +22 | if s.chars().next().unwrap() == 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:28:8 + --> $DIR/starts_ends_with.rs:26:8 | -28 | if s.chars().next_back().unwrap() == 'o' { // s.ends_with('o') +26 | if s.chars().next_back().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` | = note: `-D clippy::chars-last-cmp` implied by `-D warnings` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:31:8 + --> $DIR/starts_ends_with.rs:30:8 | -31 | if s.chars().last().unwrap() == 'o' { // s.ends_with('o') +30 | if s.chars().last().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` error: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:34:8 | -34 | if s.chars().next().unwrap() != 'f' { // !s.starts_with('f') +34 | if s.chars().next().unwrap() != 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:37:8 + --> $DIR/starts_ends_with.rs:38:8 | -37 | if s.chars().next_back().unwrap() != 'o' { // !s.ends_with('o') +38 | if s.chars().next_back().unwrap() != 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:40:8 + --> $DIR/starts_ends_with.rs:42:8 | -40 | if s.chars().last().unwrap() != 'o' { // !s.ends_with('o') +42 | if s.chars().last().unwrap() != 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` -error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:47:5 - | -47 | "".chars().last() == Some(' '); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` - -error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:48:5 - | -48 | Some(' ') != "".chars().last(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` - -error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:49:5 - | -49 | "".chars().next_back() == Some(' '); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` - error: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:50:5 | -50 | Some(' ') != "".chars().next_back(); +50 | "".chars().last() == Some(' '); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` + +error: you should use the `ends_with` method + --> $DIR/starts_ends_with.rs:51:5 + | +51 | Some(' ') != "".chars().last(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` + +error: you should use the `ends_with` method + --> $DIR/starts_ends_with.rs:52:5 + | +52 | "".chars().next_back() == Some(' '); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` + +error: you should use the `ends_with` method + --> $DIR/starts_ends_with.rs:53:5 + | +53 | Some(' ') != "".chars().next_back(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: aborting due to 12 previous errors diff --git a/tests/ui/string_extend.stderr b/tests/ui/string_extend.stderr index 2a82972a3cd..36af80b8665 100644 --- a/tests/ui/string_extend.stderr +++ b/tests/ui/string_extend.stderr @@ -1,21 +1,21 @@ error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:26:5 + --> $DIR/string_extend.rs:25:5 | -26 | s.extend(abc.chars()); +25 | s.extend(abc.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(abc)` | = note: `-D clippy::string-extend-chars` implied by `-D warnings` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:29:5 + --> $DIR/string_extend.rs:28:5 | -29 | s.extend("abc".chars()); +28 | s.extend("abc".chars()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str("abc")` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:32:5 + --> $DIR/string_extend.rs:31:5 | -32 | s.extend(def.chars()); +31 | s.extend(def.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(&def)` error: aborting due to 3 previous errors diff --git a/tests/ui/strings.stderr b/tests/ui/strings.stderr index 21115d8e97e..fe491d29b78 100644 --- a/tests/ui/strings.stderr +++ b/tests/ui/strings.stderr @@ -1,75 +1,75 @@ error: manual implementation of an assign operation - --> $DIR/strings.rs:20:9 + --> $DIR/strings.rs:17:9 | -20 | x = x + "."; +17 | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:20:13 + --> $DIR/strings.rs:17:13 | -20 | x = x + "."; +17 | x = x + "."; | ^^^^^^^ | = note: `-D clippy::string-add` implied by `-D warnings` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:24:13 + --> $DIR/strings.rs:21:13 | -24 | let z = y + "..."; +21 | let z = y + "..."; | ^^^^^^^^^ error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:34:9 + --> $DIR/strings.rs:31:9 | -34 | x = x + "."; +31 | x = x + "."; | ^^^^^^^^^^^ | = note: `-D clippy::string-add-assign` implied by `-D warnings` error: manual implementation of an assign operation - --> $DIR/strings.rs:34:9 + --> $DIR/strings.rs:31:9 | -34 | x = x + "."; +31 | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:48:9 + --> $DIR/strings.rs:45:9 | -48 | x = x + "."; +45 | x = x + "."; | ^^^^^^^^^^^ error: manual implementation of an assign operation - --> $DIR/strings.rs:48:9 + --> $DIR/strings.rs:45:9 | -48 | x = x + "."; +45 | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:52:13 + --> $DIR/strings.rs:49:13 | -52 | let z = y + "..."; +49 | let z = y + "..."; | ^^^^^^^^^ error: calling `as_bytes()` on a string literal - --> $DIR/strings.rs:60:14 + --> $DIR/strings.rs:57:14 | -60 | let bs = "hello there".as_bytes(); +57 | let bs = "hello there".as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"hello there"` | = note: `-D clippy::string-lit-as-bytes` implied by `-D warnings` error: calling `as_bytes()` on a string literal - --> $DIR/strings.rs:62:14 + --> $DIR/strings.rs:59:14 | -62 | let bs = r###"raw string with three ### in it and some " ""###.as_bytes(); +59 | let bs = r###"raw string with three ### in it and some " ""###.as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `br###"raw string with three ### in it and some " ""###` error: calling `as_bytes()` on `include_str!(..)` - --> $DIR/strings.rs:69:22 + --> $DIR/strings.rs:66:22 | -69 | let includestr = include_str!("entry.rs").as_bytes(); +66 | let includestr = include_str!("entry.rs").as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `include_bytes!(..)` instead: `include_bytes!("entry.rs")` error: aborting due to 11 previous errors diff --git a/tests/ui/stutter.stderr b/tests/ui/stutter.stderr index 2ff992fccf6..8c2d1d43281 100644 --- a/tests/ui/stutter.stderr +++ b/tests/ui/stutter.stderr @@ -1,33 +1,33 @@ error: item name starts with its containing module's name - --> $DIR/stutter.rs:18:5 + --> $DIR/stutter.rs:15:5 | -18 | pub fn foo_bar() {} +15 | pub fn foo_bar() {} | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::stutter` implied by `-D warnings` error: item name ends with its containing module's name - --> $DIR/stutter.rs:19:5 + --> $DIR/stutter.rs:16:5 | -19 | pub fn bar_foo() {} +16 | pub fn bar_foo() {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/stutter.rs:20:5 + --> $DIR/stutter.rs:17:5 | -20 | pub struct FooCake {} +17 | pub struct FooCake {} | ^^^^^^^^^^^^^^^^^^^^^ error: item name ends with its containing module's name - --> $DIR/stutter.rs:21:5 + --> $DIR/stutter.rs:18:5 | -21 | pub enum CakeFoo {} +18 | pub enum CakeFoo {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/stutter.rs:22:5 + --> $DIR/stutter.rs:19:5 | -22 | pub struct Foo7Bar; +19 | pub struct Foo7Bar; | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/suspicious_arithmetic_impl.stderr b/tests/ui/suspicious_arithmetic_impl.stderr index 64070cce3a8..5e27dd1d44f 100644 --- a/tests/ui/suspicious_arithmetic_impl.stderr +++ b/tests/ui/suspicious_arithmetic_impl.stderr @@ -1,15 +1,15 @@ error: Suspicious use of binary operator in `Add` impl - --> $DIR/suspicious_arithmetic_impl.rs:24:20 + --> $DIR/suspicious_arithmetic_impl.rs:20:20 | -24 | Foo(self.0 - other.0) +20 | Foo(self.0 - other.0) | ^ | = note: `-D clippy::suspicious-arithmetic-impl` implied by `-D warnings` error: Suspicious use of binary operator in `AddAssign` impl - --> $DIR/suspicious_arithmetic_impl.rs:30:23 + --> $DIR/suspicious_arithmetic_impl.rs:26:23 | -30 | *self = *self - other; +26 | *self = *self - other; | ^ | = note: #[deny(clippy::suspicious_op_assign_impl)] on by default diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index 7a4fbdad791..12d012442ad 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -1,66 +1,66 @@ error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:21:5 + --> $DIR/swap.rs:17:5 | -21 | / let temp = foo[0]; -22 | | foo[0] = foo[1]; -23 | | foo[1] = temp; +17 | / let temp = foo[0]; +18 | | foo[0] = foo[1]; +19 | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` | = note: `-D clippy::manual-swap` implied by `-D warnings` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:30:5 + --> $DIR/swap.rs:26:5 | -30 | / let temp = foo[0]; -31 | | foo[0] = foo[1]; -32 | | foo[1] = temp; +26 | / let temp = foo[0]; +27 | | foo[0] = foo[1]; +28 | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:39:5 + --> $DIR/swap.rs:35:5 | -39 | / let temp = foo[0]; -40 | | foo[0] = foo[1]; -41 | | foo[1] = temp; +35 | / let temp = foo[0]; +36 | | foo[0] = foo[1]; +37 | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:57:7 + --> $DIR/swap.rs:53:6 | -57 | ; let t = a; - | _______^ -58 | | a = b; -59 | | b = t; +53 | ; let t = a; + | ______^ +54 | | a = b; +55 | | b = t; | |_________^ help: try: `std::mem::swap(&mut a, &mut b)` | = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `c.0` and `a` manually - --> $DIR/swap.rs:66:7 + --> $DIR/swap.rs:62:6 | -66 | ; let t = c.0; - | _______^ -67 | | c.0 = a; -68 | | a = t; +62 | ; let t = c.0; + | ______^ +63 | | c.0 = a; +64 | | a = t; | |_________^ help: try: `std::mem::swap(&mut c.0, &mut a)` | = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:54:5 + --> $DIR/swap.rs:50:5 | -54 | / a = b; -55 | | b = a; +50 | / a = b; +51 | | b = a; | |_________^ help: try: `std::mem::swap(&mut a, &mut b)` | = note: `-D clippy::almost-swapped` implied by `-D warnings` = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `c.0` and `a` - --> $DIR/swap.rs:63:5 + --> $DIR/swap.rs:59:5 | -63 | / c.0 = a; -64 | | a = c.0; +59 | / c.0 = a; +60 | | a = c.0; | |___________^ help: try: `std::mem::swap(&mut c.0, &mut a)` | = note: or maybe you should use `std::mem::replace`? diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index edde5510e2a..2807539604d 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -1,34 +1,34 @@ error: `ref` directly on a function argument is ignored. Consider using a reference type instead. - --> $DIR/toplevel_ref_arg.rs:17:15 + --> $DIR/toplevel_ref_arg.rs:13:15 | -17 | fn the_answer(ref mut x: u8) { +13 | fn the_answer(ref mut x: u8) { | ^^^^^^^^^ | = note: `-D clippy::toplevel-ref-arg` implied by `-D warnings` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:28:7 + --> $DIR/toplevel_ref_arg.rs:24:9 | -28 | let ref x = 1; - | ----^^^^^----- help: try: `let x = &1;` +24 | let ref x = 1; + | ----^^^^^----- help: try: `let x = &1;` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:30:7 + --> $DIR/toplevel_ref_arg.rs:26:9 | -30 | let ref y: (&_, u8) = (&1, 2); - | ----^^^^^--------------------- help: try: `let y: &(&_, u8) = &(&1, 2);` +26 | let ref y: (&_, u8) = (&1, 2); + | ----^^^^^--------------------- help: try: `let y: &(&_, u8) = &(&1, 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:32:7 + --> $DIR/toplevel_ref_arg.rs:28:9 | -32 | let ref z = 1 + 2; - | ----^^^^^--------- help: try: `let z = &(1 + 2);` +28 | let ref z = 1 + 2; + | ----^^^^^--------- help: try: `let z = &(1 + 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:34:7 + --> $DIR/toplevel_ref_arg.rs:30:9 | -34 | let ref mut z = 1 + 2; - | ----^^^^^^^^^--------- help: try: `let z = &mut (1 + 2);` +30 | let ref mut z = 1 + 2; + | ----^^^^^^^^^--------- help: try: `let z = &mut (1 + 2);` error: aborting due to 5 previous errors diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr index 4dbb82b3460..0bd3580a7dd 100644 --- a/tests/ui/trailing_zeros.stderr +++ b/tests/ui/trailing_zeros.stderr @@ -1,15 +1,15 @@ error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:17:31 + --> $DIR/trailing_zeros.rs:16:5 | -17 | let _ = #[clippy::author] (x & 0b1111 == 0); // suggest trailing_zeros - | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` +16 | (x & 0b1111 == 0); // suggest trailing_zeros + | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` | = note: `-D clippy::verbose-bit-mask` implied by `-D warnings` error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:18:13 + --> $DIR/trailing_zeros.rs:17:13 | -18 | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros +17 | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5` error: aborting due to 2 previous errors diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index bde43da499f..6e4fe32a4a6 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -1,245 +1,245 @@ error: transmute from a type (`&'a T`) to itself - --> $DIR/transmute.rs:32:20 + --> $DIR/transmute.rs:28:20 | -32 | let _: &'a T = core::intrinsics::transmute(t); +28 | let _: &'a T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::useless-transmute` implied by `-D warnings` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:36:23 + --> $DIR/transmute.rs:32:23 | -36 | let _: *const T = core::intrinsics::transmute(t); +32 | let _: *const T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:38:21 + --> $DIR/transmute.rs:34:21 | -38 | let _: *mut T = core::intrinsics::transmute(t); +34 | let _: *mut T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:40:23 + --> $DIR/transmute.rs:36:23 | -40 | let _: *const U = core::intrinsics::transmute(t); +36 | let _: *const U = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U` error: transmute from a pointer type (`*const T`) to a reference type (`&T`) - --> $DIR/transmute.rs:45:17 + --> $DIR/transmute.rs:41:17 | -45 | let _: &T = std::mem::transmute(p); +41 | let _: &T = std::mem::transmute(p); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p` | = note: `-D clippy::transmute-ptr-to-ref` implied by `-D warnings` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:48:21 + --> $DIR/transmute.rs:44:21 | -48 | let _: &mut T = std::mem::transmute(m); +44 | let _: &mut T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *m` error: transmute from a pointer type (`*mut T`) to a reference type (`&T`) - --> $DIR/transmute.rs:51:17 + --> $DIR/transmute.rs:47:17 | -51 | let _: &T = std::mem::transmute(m); +47 | let _: &T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*m` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:54:21 + --> $DIR/transmute.rs:50:21 | -54 | let _: &mut T = std::mem::transmute(p as *mut T); +50 | let _: &mut T = std::mem::transmute(p as *mut T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(p as *mut T)` error: transmute from a pointer type (`*const U`) to a reference type (`&T`) - --> $DIR/transmute.rs:57:17 + --> $DIR/transmute.rs:53:17 | -57 | let _: &T = std::mem::transmute(o); +53 | let _: &T = std::mem::transmute(o); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(o as *const T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:60:21 + --> $DIR/transmute.rs:56:21 | -60 | let _: &mut T = std::mem::transmute(om); +56 | let _: &mut T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(om as *mut T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&T`) - --> $DIR/transmute.rs:63:17 + --> $DIR/transmute.rs:59:17 | -63 | let _: &T = std::mem::transmute(om); +59 | let _: &T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(om as *const T)` error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, u8>`) - --> $DIR/transmute.rs:74:32 + --> $DIR/transmute.rs:70:32 | -74 | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; +70 | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<_>)` error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, &u8>`) - --> $DIR/transmute.rs:76:33 + --> $DIR/transmute.rs:72:33 | -76 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; +72 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<&_>)` error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) - --> $DIR/transmute.rs:80:14 + --> $DIR/transmute.rs:76:14 | -80 | unsafe { std::mem::transmute::<_, Bar>(raw) }; +76 | unsafe { std::mem::transmute::<_, Bar>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)` +error: transmute from a type (`std::vec::Vec`) to itself + --> $DIR/transmute.rs:82:27 + | +82 | let _: Vec = core::intrinsics::transmute(my_vec()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: transmute from a type (`std::vec::Vec`) to itself + --> $DIR/transmute.rs:84:27 + | +84 | let _: Vec = core::mem::transmute(my_vec()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: transmute from a type (`std::vec::Vec`) to itself --> $DIR/transmute.rs:86:27 | -86 | let _: Vec = core::intrinsics::transmute(my_vec()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +86 | let _: Vec = std::intrinsics::transmute(my_vec()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself --> $DIR/transmute.rs:88:27 | -88 | let _: Vec = core::mem::transmute(my_vec()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +88 | let _: Vec = std::mem::transmute(my_vec()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself --> $DIR/transmute.rs:90:27 | -90 | let _: Vec = std::intrinsics::transmute(my_vec()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:92:27 - | -92 | let _: Vec = std::mem::transmute(my_vec()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:94:27 - | -94 | let _: Vec = my_transmute(my_vec()); +90 | let _: Vec = my_transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^ +error: transmute from an integer to a pointer + --> $DIR/transmute.rs:98:31 + | +98 | let _: *const usize = std::mem::transmute(5_isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize` + error: transmute from an integer to a pointer --> $DIR/transmute.rs:102:31 | -102 | let _: *const usize = std::mem::transmute(5_isize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize` - -error: transmute from an integer to a pointer - --> $DIR/transmute.rs:106:31 - | -106 | let _: *const usize = std::mem::transmute(1+1usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1+1usize) as *const usize` +102 | let _: *const usize = std::mem::transmute(1 + 1usize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1 + 1usize) as *const usize` error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`) - --> $DIR/transmute.rs:121:24 + --> $DIR/transmute.rs:117:24 | -121 | let _: Usize = core::intrinsics::transmute(int_const_ptr); +117 | let _: Usize = core::intrinsics::transmute(int_const_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::crosspointer-transmute` implied by `-D warnings` error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) - --> $DIR/transmute.rs:123:24 + --> $DIR/transmute.rs:119:24 | -123 | let _: Usize = core::intrinsics::transmute(int_mut_ptr); +119 | let _: Usize = core::intrinsics::transmute(int_mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`) - --> $DIR/transmute.rs:125:31 + --> $DIR/transmute.rs:121:31 | -125 | let _: *const Usize = core::intrinsics::transmute(my_int()); +121 | let _: *const Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`) - --> $DIR/transmute.rs:127:29 + --> $DIR/transmute.rs:123:29 | -127 | let _: *mut Usize = core::intrinsics::transmute(my_int()); +123 | let _: *mut Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `u32` to a `char` - --> $DIR/transmute.rs:133:28 + --> $DIR/transmute.rs:129:28 | -133 | let _: char = unsafe { std::mem::transmute(0_u32) }; +129 | let _: char = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_u32).unwrap()` | = note: `-D clippy::transmute-int-to-char` implied by `-D warnings` error: transmute from a `i32` to a `char` - --> $DIR/transmute.rs:134:28 + --> $DIR/transmute.rs:130:28 | -134 | let _: char = unsafe { std::mem::transmute(0_i32) }; +130 | let _: char = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_i32 as u32).unwrap()` error: transmute from a `u8` to a `bool` - --> $DIR/transmute.rs:139:28 + --> $DIR/transmute.rs:135:28 | -139 | let _: bool = unsafe { std::mem::transmute(0_u8) }; +135 | let _: bool = unsafe { std::mem::transmute(0_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0` | = note: `-D clippy::transmute-int-to-bool` implied by `-D warnings` error: transmute from a `u32` to a `f32` - --> $DIR/transmute.rs:144:27 + --> $DIR/transmute.rs:140:27 | -144 | let _: f32 = unsafe { std::mem::transmute(0_u32) }; +140 | let _: f32 = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)` | = note: `-D clippy::transmute-int-to-float` implied by `-D warnings` error: transmute from a `i32` to a `f32` - --> $DIR/transmute.rs:145:27 + --> $DIR/transmute.rs:141:27 | -145 | let _: f32 = unsafe { std::mem::transmute(0_i32) }; +141 | let _: f32 = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)` error: transmute from a `&[u8]` to a `&str` - --> $DIR/transmute.rs:149:28 + --> $DIR/transmute.rs:145:28 | -149 | let _: &str = unsafe { std::mem::transmute(b) }; +145 | let _: &str = unsafe { std::mem::transmute(b) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(b).unwrap()` | = note: `-D clippy::transmute-bytes-to-str` implied by `-D warnings` error: transmute from a `&mut [u8]` to a `&mut str` - --> $DIR/transmute.rs:150:32 + --> $DIR/transmute.rs:146:32 | -150 | let _: &mut str = unsafe { std::mem::transmute(mb) }; +146 | let _: &mut str = unsafe { std::mem::transmute(mb) }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()` error: transmute from a pointer to a pointer - --> $DIR/transmute.rs:182:29 + --> $DIR/transmute.rs:178:29 | -182 | let _: *const f32 = std::mem::transmute(ptr); +178 | let _: *const f32 = std::mem::transmute(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr as *const f32` | = note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings` error: transmute from a pointer to a pointer - --> $DIR/transmute.rs:183:27 + --> $DIR/transmute.rs:179:27 | -183 | let _: *mut f32 = std::mem::transmute(mut_ptr); +179 | let _: *mut f32 = std::mem::transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `mut_ptr as *mut f32` error: transmute from a reference to a reference - --> $DIR/transmute.rs:185:23 + --> $DIR/transmute.rs:181:23 | -185 | let _: &f32 = std::mem::transmute(&1u32); +181 | let _: &f32 = std::mem::transmute(&1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1u32 as *const u32 as *const f32)` error: transmute from a reference to a reference - --> $DIR/transmute.rs:186:23 + --> $DIR/transmute.rs:182:23 | -186 | let _: &f64 = std::mem::transmute(&1f32); +182 | let _: &f64 = std::mem::transmute(&1f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f32 as *const f32 as *const f64)` error: transmute from a reference to a reference - --> $DIR/transmute.rs:189:27 + --> $DIR/transmute.rs:185:27 | -189 | let _: &mut f32 = std::mem::transmute(&mut 1u32); +185 | let _: &mut f32 = std::mem::transmute(&mut 1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(&mut 1u32 as *mut u32 as *mut f32)` error: transmute from a reference to a reference - --> $DIR/transmute.rs:190:37 + --> $DIR/transmute.rs:186:37 | -190 | let _: &GenericParam = std::mem::transmute(&GenericParam { t: 1u32 }); +186 | let _: &GenericParam = std::mem::transmute(&GenericParam { t: 1u32 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam as *const GenericParam)` error: aborting due to 38 previous errors diff --git a/tests/ui/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index dcc6d264caf..320bbeb7d29 100644 --- a/tests/ui/transmute_64bit.stderr +++ b/tests/ui/transmute_64bit.stderr @@ -1,15 +1,15 @@ error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:21:31 + --> $DIR/transmute_64bit.rs:16:31 | -21 | let _: *const usize = std::mem::transmute(6.0f64); +16 | let _: *const usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::wrong-transmute` implied by `-D warnings` error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:23:29 + --> $DIR/transmute_64bit.rs:18:29 | -23 | let _: *mut usize = std::mem::transmute(6.0f64); +18 | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/trivially_copy_pass_by_ref.stderr b/tests/ui/trivially_copy_pass_by_ref.stderr index 3fb577d3edb..41aa52ecd14 100644 --- a/tests/ui/trivially_copy_pass_by_ref.stderr +++ b/tests/ui/trivially_copy_pass_by_ref.stderr @@ -1,93 +1,93 @@ error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:57:11 + --> $DIR/trivially_copy_pass_by_ref.rs:56:11 | -57 | fn bad(x: &u32, y: &Foo, z: &Baz) { +56 | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` | = note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:57:20 + --> $DIR/trivially_copy_pass_by_ref.rs:56:20 | -57 | fn bad(x: &u32, y: &Foo, z: &Baz) { +56 | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:57:29 + --> $DIR/trivially_copy_pass_by_ref.rs:56:29 | -57 | fn bad(x: &u32, y: &Foo, z: &Baz) { +56 | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:12 + --> $DIR/trivially_copy_pass_by_ref.rs:63:12 | -67 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^^ help: consider passing by value instead: `self` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:22 + --> $DIR/trivially_copy_pass_by_ref.rs:63:22 | -67 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:31 + --> $DIR/trivially_copy_pass_by_ref.rs:63:31 | -67 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:40 + --> $DIR/trivially_copy_pass_by_ref.rs:63:40 | -67 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:70:16 + --> $DIR/trivially_copy_pass_by_ref.rs:65:16 | -70 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +65 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:70:25 + --> $DIR/trivially_copy_pass_by_ref.rs:65:25 | -70 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +65 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:70:34 + --> $DIR/trivially_copy_pass_by_ref.rs:65:34 | -70 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +65 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:84:16 + --> $DIR/trivially_copy_pass_by_ref.rs:77:16 | -84 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +77 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:84:25 + --> $DIR/trivially_copy_pass_by_ref.rs:77:25 | -84 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +77 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:84:34 + --> $DIR/trivially_copy_pass_by_ref.rs:77:34 | -84 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +77 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:89:34 + --> $DIR/trivially_copy_pass_by_ref.rs:81:34 | -89 | fn trait_method(&self, _foo: &Foo); +81 | fn trait_method(&self, _foo: &Foo); | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:93:37 + --> $DIR/trivially_copy_pass_by_ref.rs:85:37 | -93 | fn trait_method2(&self, _color: &Color); +85 | fn trait_method2(&self, _color: &Color); | ^^^^^^ help: consider passing by value instead: `Color` error: aborting due to 15 previous errors diff --git a/tests/ui/types.stderr b/tests/ui/types.stderr index 0940cd53b5c..e8770490abb 100644 --- a/tests/ui/types.stderr +++ b/tests/ui/types.stderr @@ -1,8 +1,8 @@ error: casting i32 to i64 may become silently lossy if types change - --> $DIR/types.rs:19:23 + --> $DIR/types.rs:18:22 | -19 | let c_i64 : i64 = c as i64; - | ^^^^^^^^ help: try: `i64::from(c)` +18 | let c_i64: i64 = c as i64; + | ^^^^^^^^ help: try: `i64::from(c)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index 8de848caec3..e27b5866372 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -1,7 +1,7 @@ error: zero-width space detected - --> $DIR/unicode.rs:16:12 + --> $DIR/unicode.rs:12:12 | -16 | print!("Here >​< is a ZWS, and ​another"); +12 | print!("Here >​< is a ZWS, and ​another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::zero-width-space` implied by `-D warnings` @@ -9,9 +9,9 @@ error: zero-width space detected ""Here >/u{200B}< is a ZWS, and /u{200B}another"" error: non-nfc unicode sequence detected - --> $DIR/unicode.rs:22:12 + --> $DIR/unicode.rs:18:12 | -22 | print!("̀àh?"); +18 | print!("̀àh?"); | ^^^^^ | = note: `-D clippy::unicode-not-nfc` implied by `-D warnings` @@ -19,9 +19,9 @@ error: non-nfc unicode sequence detected ""̀àh?"" error: literal non-ASCII character detected - --> $DIR/unicode.rs:28:12 + --> $DIR/unicode.rs:24:12 | -28 | print!("Üben!"); +24 | print!("Üben!"); | ^^^^^^^ | = note: `-D clippy::non-ascii-literal` implied by `-D warnings` diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr index 6e5cf8354bc..ed8d4cdfd3d 100644 --- a/tests/ui/unit_arg.stderr +++ b/tests/ui/unit_arg.stderr @@ -1,19 +1,32 @@ error: passing a unit value to a function - --> $DIR/unit_arg.rs:35:9 + --> $DIR/unit_arg.rs:32:9 | -35 | foo({}); +32 | foo({}); | ^^ | = note: `-D clippy::unit-arg` implied by `-D warnings` help: if you intended to pass a unit value, use a unit literal instead | -35 | foo(()); +32 | foo(()); + | ^^ + +error: passing a unit value to a function + --> $DIR/unit_arg.rs:33:9 + | +33 | foo({ + | _________^ +34 | | 1; +35 | | }); + | |_____^ +help: if you intended to pass a unit value, use a unit literal instead + | +33 | foo(()); | ^^ error: passing a unit value to a function --> $DIR/unit_arg.rs:36:9 | -36 | foo({ 1; }); +36 | foo(foo(1)); | ^^^^^^ help: if you intended to pass a unit value, use a unit literal instead | @@ -23,45 +36,38 @@ help: if you intended to pass a unit value, use a unit literal instead error: passing a unit value to a function --> $DIR/unit_arg.rs:37:9 | -37 | foo(foo(1)); - | ^^^^^^ +37 | foo({ + | _________^ +38 | | foo(1); +39 | | foo(2); +40 | | }); + | |_____^ help: if you intended to pass a unit value, use a unit literal instead | 37 | foo(()); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:38:9 + --> $DIR/unit_arg.rs:41:10 | -38 | foo({ - | _________^ -39 | | foo(1); -40 | | foo(2); -41 | | }); +41 | foo3({}, 2, 2); + | ^^ +help: if you intended to pass a unit value, use a unit literal instead + | +41 | foo3((), 2, 2); + | ^^ + +error: passing a unit value to a function + --> $DIR/unit_arg.rs:43:11 + | +43 | b.bar({ + | ___________^ +44 | | 1; +45 | | }); | |_____^ help: if you intended to pass a unit value, use a unit literal instead | -38 | foo(()); - | ^^ - -error: passing a unit value to a function - --> $DIR/unit_arg.rs:42:10 - | -42 | foo3({}, 2, 2); - | ^^ -help: if you intended to pass a unit value, use a unit literal instead - | -42 | foo3((), 2, 2); - | ^^ - -error: passing a unit value to a function - --> $DIR/unit_arg.rs:44:11 - | -44 | b.bar({ 1; }); - | ^^^^^^ -help: if you intended to pass a unit value, use a unit literal instead - | -44 | b.bar(()); +43 | b.bar(()); | ^^ error: aborting due to 6 previous errors diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index bd9ac25a64f..7c76945fe3e 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -1,16 +1,26 @@ error: ==-comparison of unit values detected. This will always be true - --> $DIR/unit_cmp.rs:26:8 + --> $DIR/unit_cmp.rs:21:8 | -26 | if { true; } == { false; } { - | ^^^^^^^^^^^^^^^^^^^^^^^ +21 | if { + | ________^ +22 | | true; +23 | | } == { +24 | | false; +25 | | } {} + | |_____^ | = note: `-D clippy::unit-cmp` implied by `-D warnings` error: >-comparison of unit values detected. This will always be false - --> $DIR/unit_cmp.rs:29:8 + --> $DIR/unit_cmp.rs:27:8 | -29 | if { true; } > { false; } { - | ^^^^^^^^^^^^^^^^^^^^^^ +27 | if { + | ________^ +28 | | true; +29 | | } > { +30 | | false; +31 | | } {} + | |_____^ error: aborting due to 2 previous errors diff --git a/tests/ui/unnecessary_clone.stderr b/tests/ui/unnecessary_clone.stderr index 5dcd5cae463..8a0bf9d55b5 100644 --- a/tests/ui/unnecessary_clone.stderr +++ b/tests/ui/unnecessary_clone.stderr @@ -1,95 +1,95 @@ error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:29:5 + --> $DIR/unnecessary_clone.rs:26:5 | -29 | 42.clone(); +26 | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call: `42` | = note: `-D clippy::clone-on-copy` implied by `-D warnings` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:33:5 + --> $DIR/unnecessary_clone.rs:30:5 | -33 | (&42).clone(); +30 | (&42).clone(); | ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:36:5 + --> $DIR/unnecessary_clone.rs:33:5 | -36 | rc.borrow().clone(); +33 | rc.borrow().clone(); | ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:46:5 + --> $DIR/unnecessary_clone.rs:43:5 | -46 | rc.clone(); +43 | rc.clone(); | ^^^^^^^^^^ help: try this: `Rc::::clone(&rc)` | = note: `-D clippy::clone-on-ref-ptr` implied by `-D warnings` +error: using '.clone()' on a ref-counted pointer + --> $DIR/unnecessary_clone.rs:46:5 + | +46 | arc.clone(); + | ^^^^^^^^^^^ help: try this: `Arc::::clone(&arc)` + error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:49:5 | -49 | arc.clone(); - | ^^^^^^^^^^^ help: try this: `Arc::::clone(&arc)` +49 | rcweak.clone(); + | ^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&rcweak)` error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:52:5 | -52 | rcweak.clone(); - | ^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&rcweak)` - -error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:55:5 - | -55 | arc_weak.clone(); +52 | arc_weak.clone(); | ^^^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&arc_weak)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:59:29 + --> $DIR/unnecessary_clone.rs:56:29 | -59 | let _: Arc = x.clone(); +56 | let _: Arc = x.clone(); | ^^^^^^^^^ help: try this: `Arc::::clone(&x)` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:63:5 + --> $DIR/unnecessary_clone.rs:60:5 | -63 | t.clone(); +60 | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call: `t` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:65:5 + --> $DIR/unnecessary_clone.rs:62:5 | -65 | Some(t).clone(); +62 | Some(t).clone(); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `Some(t)` error: using `clone` on a double-reference; this will copy the reference instead of cloning the inner type - --> $DIR/unnecessary_clone.rs:71:22 + --> $DIR/unnecessary_clone.rs:68:22 | -71 | let z: &Vec<_> = y.clone(); +68 | let z: &Vec<_> = y.clone(); | ^^^^^^^^^ | = note: #[deny(clippy::clone_double_ref)] on by default help: try dereferencing it | -71 | let z: &Vec<_> = &(*y).clone(); +68 | let z: &Vec<_> = &(*y).clone(); | ^^^^^^^^^^^^^ help: or try being explicit about what type to clone | -71 | let z: &Vec<_> = &std::vec::Vec::clone(y); +68 | let z: &Vec<_> = &std::vec::Vec::clone(y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/unnecessary_clone.rs:78:27 + --> $DIR/unnecessary_clone.rs:75:26 | -78 | let v2 : Vec = v.iter().cloned().collect(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +75 | let v2: Vec = v.iter().cloned().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::iter-cloned-collect` implied by `-D warnings` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:110:20 + --> $DIR/unnecessary_clone.rs:111:20 | -110 | let _: E = a.clone(); +111 | let _: E = a.clone(); | ^^^^^^^^^ help: try dereferencing it: `*****a` error: aborting due to 13 previous errors diff --git a/tests/ui/unnecessary_filter_map.stderr b/tests/ui/unnecessary_filter_map.stderr index 8fef6068167..53311b3d275 100644 --- a/tests/ui/unnecessary_filter_map.stderr +++ b/tests/ui/unnecessary_filter_map.stderr @@ -1,31 +1,37 @@ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:12:13 + --> $DIR/unnecessary_filter_map.rs:11:13 | -12 | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); +11 | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnecessary-filter-map` implied by `-D warnings` error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:13:13 + --> $DIR/unnecessary_filter_map.rs:12:13 | -13 | let _ = (0..4).filter_map(|x| { if x > 1 { return Some(x); }; None }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:14:13 - | -14 | let _ = (0..4).filter_map(|x| match x { +12 | let _ = (0..4).filter_map(|x| { | _____________^ -15 | | 0 | 1 => None, -16 | | _ => Some(x), +13 | | if x > 1 { +14 | | return Some(x); +15 | | }; +16 | | None 17 | | }); | |______^ -error: this `.filter_map` can be written more simply using `.map` - --> $DIR/unnecessary_filter_map.rs:19:13 +error: this `.filter_map` can be written more simply using `.filter` + --> $DIR/unnecessary_filter_map.rs:18:13 | -19 | let _ = (0..4).filter_map(|x| Some(x + 1)); +18 | let _ = (0..4).filter_map(|x| match x { + | _____________^ +19 | | 0 | 1 => None, +20 | | _ => Some(x), +21 | | }); + | |______^ + +error: this `.filter_map` can be written more simply using `.map` + --> $DIR/unnecessary_filter_map.rs:23:13 + | +23 | let _ = (0..4).filter_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/unnecessary_fold.stderr b/tests/ui/unnecessary_fold.stderr index b2865479c43..e0bd744265c 100644 --- a/tests/ui/unnecessary_fold.stderr +++ b/tests/ui/unnecessary_fold.stderr @@ -1,33 +1,33 @@ error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:14:19 + --> $DIR/unnecessary_fold.rs:13:19 | -14 | let _ = (0..3).fold(false, |acc, x| acc || x > 2); +13 | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` | = note: `-D clippy::unnecessary-fold` implied by `-D warnings` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:16:19 + --> $DIR/unnecessary_fold.rs:15:19 | -16 | let _ = (0..3).fold(true, |acc, x| acc && x > 2); +15 | let _ = (0..3).fold(true, |acc, x| acc && x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.all(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:18:19 + --> $DIR/unnecessary_fold.rs:17:19 | -18 | let _ = (0..3).fold(0, |acc, x| acc + x); +17 | let _ = (0..3).fold(0, |acc, x| acc + x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:20:19 + --> $DIR/unnecessary_fold.rs:19:19 | -20 | let _ = (0..3).fold(1, |acc, x| acc * x); +19 | let _ = (0..3).fold(1, |acc, x| acc * x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.product()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:25:34 + --> $DIR/unnecessary_fold.rs:24:34 | -25 | let _ = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); +24 | let _ = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` error: aborting due to 5 previous errors diff --git a/tests/ui/unnecessary_operation.stderr b/tests/ui/unnecessary_operation.stderr index 8e5417eb13e..8b576bef648 100644 --- a/tests/ui/unnecessary_operation.stderr +++ b/tests/ui/unnecessary_operation.stderr @@ -1,124 +1,128 @@ error: statement can be reduced - --> $DIR/unnecessary_operation.rs:48:5 + --> $DIR/unnecessary_operation.rs:54:5 | -48 | Tuple(get_number()); +54 | Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | = note: `-D clippy::unnecessary-operation` implied by `-D warnings` -error: statement can be reduced - --> $DIR/unnecessary_operation.rs:49:5 - | -49 | Struct { field: get_number() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` - -error: statement can be reduced - --> $DIR/unnecessary_operation.rs:50:5 - | -50 | Struct { ..get_struct() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_struct();` - -error: statement can be reduced - --> $DIR/unnecessary_operation.rs:51:5 - | -51 | Enum::Tuple(get_number()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` - -error: statement can be reduced - --> $DIR/unnecessary_operation.rs:52:5 - | -52 | Enum::Struct { field: get_number() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` - -error: statement can be reduced - --> $DIR/unnecessary_operation.rs:53:5 - | -53 | 5 + get_number(); - | ^^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` - -error: statement can be reduced - --> $DIR/unnecessary_operation.rs:54:5 - | -54 | *&get_number(); - | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` - error: statement can be reduced --> $DIR/unnecessary_operation.rs:55:5 | -55 | &get_number(); - | ^^^^^^^^^^^^^^ help: replace it with: `get_number();` +55 | Struct { field: get_number() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:56:5 | -56 | (5, 6, get_number()); - | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `5;6;get_number();` +56 | Struct { ..get_struct() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_struct();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:57:5 | -57 | box get_number(); - | ^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +57 | Enum::Tuple(get_number()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:58:5 | -58 | get_number()..; - | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +58 | Enum::Struct { field: get_number() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:59:5 | -59 | ..get_number(); - | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +59 | 5 + get_number(); + | ^^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:60:5 | -60 | 5..get_number(); - | ^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` +60 | *&get_number(); + | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:61:5 | -61 | [42, get_number()]; - | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` +61 | &get_number(); + | ^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:62:5 | -62 | [42, 55][get_number() as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42, 55];get_number() as usize;` +62 | (5, 6, get_number()); + | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `5;6;get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:63:5 | -63 | (42, get_number()).1; - | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` +63 | box get_number(); + | ^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:64:5 | -64 | [get_number(); 55]; - | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +64 | get_number()..; + | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:65:5 | -65 | [42; 55][get_number() as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42; 55];get_number() as usize;` +65 | ..get_number(); + | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:66:5 | -66 | {get_number()}; - | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +66 | 5..get_number(); + | ^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` error: statement can be reduced --> $DIR/unnecessary_operation.rs:67:5 | -67 | FooString { s: String::from("blah"), }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `String::from("blah");` +67 | [42, get_number()]; + | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` + +error: statement can be reduced + --> $DIR/unnecessary_operation.rs:68:5 + | +68 | [42, 55][get_number() as usize]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42, 55];get_number() as usize;` + +error: statement can be reduced + --> $DIR/unnecessary_operation.rs:69:5 + | +69 | (42, get_number()).1; + | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` + +error: statement can be reduced + --> $DIR/unnecessary_operation.rs:70:5 + | +70 | [get_number(); 55]; + | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` + +error: statement can be reduced + --> $DIR/unnecessary_operation.rs:71:5 + | +71 | [42; 55][get_number() as usize]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42; 55];get_number() as usize;` + +error: statement can be reduced + --> $DIR/unnecessary_operation.rs:72:5 + | +72 | / { +73 | | get_number() +74 | | }; + | |______^ help: replace it with: `get_number();` + +error: statement can be reduced + --> $DIR/unnecessary_operation.rs:75:5 + | +75 | / FooString { +76 | | s: String::from("blah"), +77 | | }; + | |______^ help: replace it with: `String::from("blah");` error: aborting due to 20 previous errors diff --git a/tests/ui/unnecessary_ref.stderr b/tests/ui/unnecessary_ref.stderr index a3d8f5e337c..f048df6e39b 100644 --- a/tests/ui/unnecessary_ref.stderr +++ b/tests/ui/unnecessary_ref.stderr @@ -1,13 +1,13 @@ error: Creating a reference that is immediately dereferenced. - --> $DIR/unnecessary_ref.rs:23:17 + --> $DIR/unnecessary_ref.rs:20:17 | -23 | let inner = (&outer).inner; +20 | let inner = (&outer).inner; | ^^^^^^^^ help: try this: `outer.inner` | note: lint level defined here - --> $DIR/unnecessary_ref.rs:20:8 + --> $DIR/unnecessary_ref.rs:17:8 | -20 | #[deny(clippy::ref_in_deref)] +17 | #[deny(clippy::ref_in_deref)] | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index 85982d75494..a1e43e493b7 100644 --- a/tests/ui/unneeded_field_pattern.stderr +++ b/tests/ui/unneeded_field_pattern.stderr @@ -1,16 +1,16 @@ error: You matched a field with a wildcard pattern. Consider using `..` instead - --> $DIR/unneeded_field_pattern.rs:27:15 + --> $DIR/unneeded_field_pattern.rs:23:15 | -27 | Foo { a: _, b: 0, .. } => {} +23 | Foo { a: _, b: 0, .. } => {}, | ^^^^ | = note: `-D clippy::unneeded-field-pattern` implied by `-D warnings` = help: Try with `Foo { b: 0, .. }` error: All the struct fields are matched to a wildcard pattern, consider using `..`. - --> $DIR/unneeded_field_pattern.rs:29:9 + --> $DIR/unneeded_field_pattern.rs:25:9 | -29 | Foo { a: _, b: _, c: _ } => {} +25 | Foo { a: _, b: _, c: _ } => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Try with `Foo { .. }` instead diff --git a/tests/ui/unreadable_literal.stderr b/tests/ui/unreadable_literal.stderr index b5ab6937d95..83372a2a5a7 100644 --- a/tests/ui/unreadable_literal.stderr +++ b/tests/ui/unreadable_literal.stderr @@ -1,33 +1,33 @@ error: long literal lacking separators - --> $DIR/unreadable_literal.rs:17:16 + --> $DIR/unreadable_literal.rs:24:16 | -17 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64` | = note: `-D clippy::unreadable-literal` implied by `-D warnings` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:17:30 + --> $DIR/unreadable_literal.rs:24:30 | -17 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:17:51 + --> $DIR/unreadable_literal.rs:24:51 | -17 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^ help: consider: `123_456_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:17:63 + --> $DIR/unreadable_literal.rs:24:63 | -17 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `1.234_567_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:19:19 + --> $DIR/unreadable_literal.rs:26:19 | -19 | let bad_sci = 1.123456e1; +26 | let bad_sci = 1.123456e1; | ^^^^^^^^^^ help: consider: `1.123_456e1` error: aborting due to 5 previous errors diff --git a/tests/ui/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index f4bb93735d7..3b285208978 100644 --- a/tests/ui/unsafe_removed_from_name.stderr +++ b/tests/ui/unsafe_removed_from_name.stderr @@ -1,21 +1,21 @@ error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCell` - --> $DIR/unsafe_removed_from_name.rs:17:1 + --> $DIR/unsafe_removed_from_name.rs:14:1 | -17 | use std::cell::{UnsafeCell as TotallySafeCell}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +14 | use std::cell::UnsafeCell as TotallySafeCell; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unsafe-removed-from-name` implied by `-D warnings` error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCellAgain` - --> $DIR/unsafe_removed_from_name.rs:19:1 + --> $DIR/unsafe_removed_from_name.rs:16:1 | -19 | use std::cell::UnsafeCell as TotallySafeCellAgain; +16 | use std::cell::UnsafeCell as TotallySafeCellAgain; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed "unsafe" from the name of `Unsafe` in use as `LieAboutModSafety` - --> $DIR/unsafe_removed_from_name.rs:33:1 + --> $DIR/unsafe_removed_from_name.rs:30:1 | -33 | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; +30 | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/unused_io_amount.stderr b/tests/ui/unused_io_amount.stderr index 329dfacd43b..f7b9b361502 100644 --- a/tests/ui/unused_io_amount.stderr +++ b/tests/ui/unused_io_amount.stderr @@ -1,42 +1,42 @@ error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:21:5 + --> $DIR/unused_io_amount.rs:17:5 | -21 | try!(s.write(b"test")); +17 | try!(s.write(b"test")); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unused-io-amount` implied by `-D warnings` = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:23:5 + --> $DIR/unused_io_amount.rs:19:5 | -23 | try!(s.read(&mut buf)); +19 | try!(s.read(&mut buf)); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:28:5 + --> $DIR/unused_io_amount.rs:24:5 | -28 | s.write(b"test")?; +24 | s.write(b"test")?; | ^^^^^^^^^^^^^^^^^ error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:30:5 + --> $DIR/unused_io_amount.rs:26:5 | -30 | s.read(&mut buf)?; +26 | s.read(&mut buf)?; | ^^^^^^^^^^^^^^^^^ error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:35:5 + --> $DIR/unused_io_amount.rs:31:5 | -35 | s.write(b"test").unwrap(); +31 | s.write(b"test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:37:5 + --> $DIR/unused_io_amount.rs:33:5 | -37 | s.read(&mut buf).unwrap(); +33 | s.read(&mut buf).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/unused_labels.stderr b/tests/ui/unused_labels.stderr index 5a31ada902e..cbade54c157 100644 --- a/tests/ui/unused_labels.stderr +++ b/tests/ui/unused_labels.stderr @@ -1,25 +1,29 @@ error: unused label `'label` - --> $DIR/unused_labels.rs:18:5 + --> $DIR/unused_labels.rs:14:5 | -18 | / 'label: for i in 1..2 { -19 | | if i > 4 { continue } -20 | | } +14 | / 'label: for i in 1..2 { +15 | | if i > 4 { +16 | | continue; +17 | | } +18 | | } | |_____^ | = note: `-D clippy::unused-label` implied by `-D warnings` error: unused label `'a` - --> $DIR/unused_labels.rs:31:5 + --> $DIR/unused_labels.rs:28:5 | -31 | 'a: loop { break } - | ^^^^^^^^^^^^^^^^^^ +28 | / 'a: loop { +29 | | break; +30 | | } + | |_____^ error: unused label `'same_label_in_two_fns` - --> $DIR/unused_labels.rs:42:5 + --> $DIR/unused_labels.rs:41:5 | -42 | / 'same_label_in_two_fns: loop { -43 | | let _ = 1; -44 | | } +41 | / 'same_label_in_two_fns: loop { +42 | | let _ = 1; +43 | | } | |_____^ error: aborting due to 3 previous errors diff --git a/tests/ui/unused_lt.stderr b/tests/ui/unused_lt.stderr index f5b788c16a7..e590cfc91aa 100644 --- a/tests/ui/unused_lt.stderr +++ b/tests/ui/unused_lt.stderr @@ -1,21 +1,21 @@ error: this lifetime isn't used in the function definition - --> $DIR/unused_lt.rs:26:14 + --> $DIR/unused_lt.rs:23:14 | -26 | fn unused_lt<'a>(x: u8) { +23 | fn unused_lt<'a>(x: u8) {} | ^^ | = note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings` error: this lifetime isn't used in the function definition - --> $DIR/unused_lt.rs:30:25 + --> $DIR/unused_lt.rs:25:25 | -30 | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { +25 | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { | ^^ error: this lifetime isn't used in the function definition - --> $DIR/unused_lt.rs:60:10 + --> $DIR/unused_lt.rs:50:10 | -60 | fn x<'a>(&self) {} +50 | fn x<'a>(&self) {} | ^^ error: aborting due to 3 previous errors diff --git a/tests/ui/unwrap_or.stderr b/tests/ui/unwrap_or.stderr index ffdeeb5307f..2432b7970f6 100644 --- a/tests/ui/unwrap_or.stderr +++ b/tests/ui/unwrap_or.stderr @@ -1,16 +1,16 @@ error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:15:47 + --> $DIR/unwrap_or.rs:13:47 | -15 | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); +13 | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` | = note: `-D clippy::or-fun-call` implied by `-D warnings` error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:20:10 + --> $DIR/unwrap_or.rs:17:47 | -20 | .unwrap_or("Fail".to_string()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` +17 | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` error: aborting due to 2 previous errors diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index b71c7a9a4c5..0904db2e942 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -1,39 +1,39 @@ error: unnecessary structure name repetition - --> $DIR/use_self.rs:23:21 + --> $DIR/use_self.rs:20:21 | -23 | fn new() -> Foo { +20 | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` | = note: `-D clippy::use-self` implied by `-D warnings` error: unnecessary structure name repetition - --> $DIR/use_self.rs:24:13 + --> $DIR/use_self.rs:21:13 | -24 | Foo {} +21 | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:26:22 + --> $DIR/use_self.rs:23:22 | -26 | fn test() -> Foo { +23 | fn test() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:27:13 + --> $DIR/use_self.rs:24:13 | -27 | Foo::new() +24 | Foo::new() | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:32:25 + --> $DIR/use_self.rs:29:25 | -32 | fn default() -> Foo { +29 | fn default() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:33:13 + --> $DIR/use_self.rs:30:13 | -33 | Foo::new() +30 | Foo::new() | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition @@ -75,56 +75,56 @@ error: unnecessary structure name repetition error: unnecessary structure name repetition --> $DIR/use_self.rs:108:28 | -108 | fn nested(_p1: Box, _p2: (&u8, &Bad)) { +108 | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition --> $DIR/use_self.rs:108:46 | -108 | fn nested(_p1: Box, _p2: (&u8, &Bad)) { +108 | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:111:20 + --> $DIR/use_self.rs:110:20 | -111 | fn vals(_: Bad) -> Bad { +110 | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:111:28 + --> $DIR/use_self.rs:110:28 | -111 | fn vals(_: Bad) -> Bad { +110 | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:112:13 + --> $DIR/use_self.rs:111:13 | -112 | Bad::default() +111 | Bad::default() | ^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:117:23 + --> $DIR/use_self.rs:116:23 | -117 | type Output = Bad; +116 | type Output = Bad; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:119:27 + --> $DIR/use_self.rs:118:27 | -119 | fn mul(self, rhs: Bad) -> Bad { +118 | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:119:35 + --> $DIR/use_self.rs:118:35 | -119 | fn mul(self, rhs: Bad) -> Bad { +118 | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:213:54 + --> $DIR/use_self.rs:210:56 | -213 | fn bad(foos: &[Self]) -> impl Iterator { - | ^^^ help: use the applicable keyword: `Self` +210 | fn bad(foos: &[Self]) -> impl Iterator { + | ^^^ help: use the applicable keyword: `Self` error: aborting due to 21 previous errors diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 8092119470e..c844a8cd75b 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -1,33 +1,33 @@ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:27:5 + --> $DIR/used_underscore_binding.rs:23:5 | -27 | _foo + 1 +23 | _foo + 1 | ^^^^ | = note: `-D clippy::used-underscore-binding` implied by `-D warnings` error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:32:20 + --> $DIR/used_underscore_binding.rs:28:20 | -32 | println!("{}", _foo); +28 | println!("{}", _foo); | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:33:16 + --> $DIR/used_underscore_binding.rs:29:16 | -33 | assert_eq!(_foo, _foo); +29 | assert_eq!(_foo, _foo); | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:33:22 + --> $DIR/used_underscore_binding.rs:29:22 | -33 | assert_eq!(_foo, _foo); +29 | assert_eq!(_foo, _foo); | ^^^^ error: used binding `_underscore_field` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:46:5 + --> $DIR/used_underscore_binding.rs:42:5 | -46 | s._underscore_field += 1; +42 | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/useless_asref.stderr b/tests/ui/useless_asref.stderr index 8e45facf587..397ec7108d4 100644 --- a/tests/ui/useless_asref.stderr +++ b/tests/ui/useless_asref.stderr @@ -1,73 +1,73 @@ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:43:18 + --> $DIR/useless_asref.rs:50:18 | -43 | foo_rstr(rstr.as_ref()); +50 | foo_rstr(rstr.as_ref()); | ^^^^^^^^^^^^^ help: try this: `rstr` | note: lint level defined here - --> $DIR/useless_asref.rs:13:9 + --> $DIR/useless_asref.rs:10:9 | -13 | #![deny(clippy::useless_asref)] +10 | #![deny(clippy::useless_asref)] | ^^^^^^^^^^^^^^^^^^^^^ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:45:20 + --> $DIR/useless_asref.rs:52:20 | -45 | foo_rslice(rslice.as_ref()); +52 | foo_rslice(rslice.as_ref()); | ^^^^^^^^^^^^^^^ help: try this: `rslice` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:49:21 + --> $DIR/useless_asref.rs:56:21 | -49 | foo_mrslice(mrslice.as_mut()); +56 | foo_mrslice(mrslice.as_mut()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` -error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:51:20 - | -51 | foo_rslice(mrslice.as_ref()); - | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` - error: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:58:20 | -58 | foo_rslice(rrrrrslice.as_ref()); +58 | foo_rslice(mrslice.as_ref()); + | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` + +error: this call to `as_ref` does nothing + --> $DIR/useless_asref.rs:65:20 + | +65 | foo_rslice(rrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^ help: try this: `rrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:60:18 + --> $DIR/useless_asref.rs:67:18 | -60 | foo_rstr(rrrrrstr.as_ref()); +67 | foo_rstr(rrrrrstr.as_ref()); | ^^^^^^^^^^^^^^^^^ help: try this: `rrrrrstr` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:65:21 + --> $DIR/useless_asref.rs:72:21 | -65 | foo_mrslice(mrrrrrslice.as_mut()); +72 | foo_mrslice(mrrrrrslice.as_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:67:20 + --> $DIR/useless_asref.rs:74:20 | -67 | foo_rslice(mrrrrrslice.as_ref()); +74 | foo_rslice(mrrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:70:16 + --> $DIR/useless_asref.rs:77:16 | -70 | foo_rrrrmr((&&&&MoreRef).as_ref()); +77 | foo_rrrrmr((&&&&MoreRef).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(&&&&MoreRef)` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:116:13 + --> $DIR/useless_asref.rs:127:13 | -116 | foo_mrt(mrt.as_mut()); +127 | foo_mrt(mrt.as_mut()); | ^^^^^^^^^^^^ help: try this: `mrt` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:118:12 + --> $DIR/useless_asref.rs:129:12 | -118 | foo_rt(mrt.as_ref()); +129 | foo_rt(mrt.as_ref()); | ^^^^^^^^^^^^ help: try this: `mrt` error: aborting due to 11 previous errors diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index 6b82b105b05..54d18fbf2e1 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -1,16 +1,22 @@ error: useless lint attribute - --> $DIR/useless_attribute.rs:15:1 + --> $DIR/useless_attribute.rs:12:1 | -15 | #[allow(dead_code)] +12 | #[allow(dead_code)] | ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]` | = note: `-D clippy::useless-attribute` implied by `-D warnings` error: useless lint attribute - --> $DIR/useless_attribute.rs:16:1 + --> $DIR/useless_attribute.rs:13:1 | -16 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] +13 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` -error: aborting due to 2 previous errors +error: useless lint attribute + --> $DIR/useless_attribute.rs:14:1 + | +14 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` + +error: aborting due to 3 previous errors diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index e4649eab5ec..94e9bcdd2a7 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -1,39 +1,39 @@ error: useless use of `vec!` - --> $DIR/vec.rs:34:14 + --> $DIR/vec.rs:30:14 | -34 | on_slice(&vec![]); +30 | on_slice(&vec![]); | ^^^^^^^ help: you can use a slice directly: `&[]` | = note: `-D clippy::useless-vec` implied by `-D warnings` error: useless use of `vec!` - --> $DIR/vec.rs:37:14 + --> $DIR/vec.rs:33:14 | -37 | on_slice(&vec![1, 2]); +33 | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:40:14 + --> $DIR/vec.rs:36:14 | -40 | on_slice(&vec ![1, 2]); - | ^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` - -error: useless use of `vec!` - --> $DIR/vec.rs:43:14 - | -43 | on_slice(&vec!(1, 2)); +36 | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:46:14 + --> $DIR/vec.rs:39:14 | -46 | on_slice(&vec![1; 2]); +39 | on_slice(&vec![1, 2]); + | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` + +error: useless use of `vec!` + --> $DIR/vec.rs:42:14 + | +42 | on_slice(&vec![1; 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1; 2]` error: useless use of `vec!` - --> $DIR/vec.rs:59:14 + --> $DIR/vec.rs:55:14 | -59 | for a in vec![1, 2, 3] { +55 | for a in vec![1, 2, 3] { | ^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2, 3]` error: aborting due to 6 previous errors diff --git a/tests/ui/while_loop.stderr b/tests/ui/while_loop.stderr index b166e8bacb5..57cfa14a392 100644 --- a/tests/ui/while_loop.stderr +++ b/tests/ui/while_loop.stderr @@ -1,114 +1,114 @@ error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:19:5 + --> $DIR/while_loop.rs:15:5 | -19 | / loop { -20 | | if let Some(_x) = y { -21 | | let _v = 1; -22 | | } else { -23 | | break -24 | | } -25 | | } +15 | / loop { +16 | | if let Some(_x) = y { +17 | | let _v = 1; +18 | | } else { +19 | | break; +20 | | } +21 | | } | |_____^ help: try: `while let Some(_x) = y { .. }` | = note: `-D clippy::while-let-loop` implied by `-D warnings` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:32:5 + --> $DIR/while_loop.rs:29:5 | -32 | / loop { -33 | | match y { -34 | | Some(_x) => true, -35 | | None => break -36 | | }; -37 | | } +29 | / loop { +30 | | match y { +31 | | Some(_x) => true, +32 | | None => break, +33 | | }; +34 | | } | |_____^ help: try: `while let Some(_x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:38:5 + --> $DIR/while_loop.rs:35:5 | -38 | / loop { -39 | | let x = match y { -40 | | Some(x) => x, -41 | | None => break +35 | / loop { +36 | | let x = match y { +37 | | Some(x) => x, +38 | | None => break, ... | -44 | | let _str = "foo"; -45 | | } +41 | | let _str = "foo"; +42 | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:46:5 + --> $DIR/while_loop.rs:43:5 | -46 | / loop { -47 | | let x = match y { -48 | | Some(x) => x, -49 | | None => break, +43 | / loop { +44 | | let x = match y { +45 | | Some(x) => x, +46 | | None => break, ... | -52 | | { let _b = "foobar"; } -53 | | } +53 | | } +54 | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:68:5 + --> $DIR/while_loop.rs:71:5 | -68 | / loop { -69 | | let (e, l) = match "".split_whitespace().next() { -70 | | Some(word) => (word.is_empty(), word.len()), -71 | | None => break +71 | / loop { +72 | | let (e, l) = match "".split_whitespace().next() { +73 | | Some(word) => (word.is_empty(), word.len()), +74 | | None => break, ... | -74 | | let _ = (e, l); -75 | | } +77 | | let _ = (e, l); +78 | | } | |_____^ help: try: `while let Some(word) = "".split_whitespace().next() { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:78:33 + --> $DIR/while_loop.rs:81:33 | -78 | while let Option::Some(x) = iter.next() { +81 | while let Option::Some(x) = iter.next() { | ^^^^^^^^^^^ help: try: `for x in iter { .. }` | = note: `-D clippy::while-let-on-iterator` implied by `-D warnings` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:83:25 + --> $DIR/while_loop.rs:86:25 | -83 | while let Some(x) = iter.next() { +86 | while let Some(x) = iter.next() { | ^^^^^^^^^^^ help: try: `for x in iter { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:88:25 + --> $DIR/while_loop.rs:91:25 | -88 | while let Some(_) = iter.next() {} +91 | while let Some(_) = iter.next() {} | ^^^^^^^^^^^ help: try: `for _ in iter { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:128:5 + --> $DIR/while_loop.rs:134:5 | -128 | / loop { -129 | | let _ = match iter.next() { -130 | | Some(ele) => ele, -131 | | None => break -132 | | }; -133 | | loop {} -134 | | } +134 | / loop { +135 | | let _ = match iter.next() { +136 | | Some(ele) => ele, +137 | | None => break, +138 | | }; +139 | | loop {} +140 | | } | |_____^ help: try: `while let Some(ele) = iter.next() { .. }` error: empty `loop {}` detected. You may want to either use `panic!()` or add `std::thread::sleep(..);` to the loop body. - --> $DIR/while_loop.rs:133:9 + --> $DIR/while_loop.rs:139:9 | -133 | loop {} +139 | loop {} | ^^^^^^^ | = note: `-D clippy::empty-loop` implied by `-D warnings` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:193:29 + --> $DIR/while_loop.rs:197:29 | -193 | while let Some(v) = y.next() { // use a for loop here +197 | while let Some(v) = y.next() { | ^^^^^^^^ help: try: `for v in y { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:220:26 + --> $DIR/while_loop.rs:225:26 | -220 | while let Some(..) = values.iter().next() { +225 | while let Some(..) = values.iter().next() { | ^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in values.iter() { .. }` error: aborting due to 12 previous errors diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index 2aa66c32049..40c21902bf2 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -1,88 +1,88 @@ error: literal with an empty format string - --> $DIR/write_literal.rs:39:79 + --> $DIR/write_literal.rs:36:79 | -39 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); +36 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ | = note: `-D clippy::write-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/write_literal.rs:40:32 + --> $DIR/write_literal.rs:37:32 | -40 | write!(&mut v, "Hello {}", "world"); +37 | write!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:41:44 + --> $DIR/write_literal.rs:38:44 | -41 | writeln!(&mut v, "Hello {} {}", world, "world"); +38 | writeln!(&mut v, "Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:42:34 + --> $DIR/write_literal.rs:39:34 | -42 | writeln!(&mut v, "Hello {}", "world"); +39 | writeln!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:43:38 + --> $DIR/write_literal.rs:40:38 | -43 | writeln!(&mut v, "10 / 4 is {}", 2.5); +40 | writeln!(&mut v, "10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:44:36 + --> $DIR/write_literal.rs:41:36 | -44 | writeln!(&mut v, "2 + 1 = {}", 3); +41 | writeln!(&mut v, "2 + 1 = {}", 3); | ^ error: literal with an empty format string - --> $DIR/write_literal.rs:49:33 + --> $DIR/write_literal.rs:46:33 | -49 | writeln!(&mut v, "{0} {1}", "hello", "world"); +46 | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:49:42 + --> $DIR/write_literal.rs:46:42 | -49 | writeln!(&mut v, "{0} {1}", "hello", "world"); +46 | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:50:33 + --> $DIR/write_literal.rs:47:33 | -50 | writeln!(&mut v, "{1} {0}", "hello", "world"); +47 | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:50:42 + --> $DIR/write_literal.rs:47:42 | -50 | writeln!(&mut v, "{1} {0}", "hello", "world"); +47 | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:53:41 + --> $DIR/write_literal.rs:50:43 | -53 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); - | ^^^^^^^ +50 | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:53:54 + --> $DIR/write_literal.rs:50:58 | -53 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); - | ^^^^^^^ +50 | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:54:41 + --> $DIR/write_literal.rs:51:43 | -54 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); - | ^^^^^^^ +51 | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:54:54 + --> $DIR/write_literal.rs:51:58 | -54 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); - | ^^^^^^^ +51 | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); + | ^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/write_with_newline.stderr b/tests/ui/write_with_newline.stderr index dd7f223c517..8d2ad1b4d97 100644 --- a/tests/ui/write_with_newline.stderr +++ b/tests/ui/write_with_newline.stderr @@ -1,27 +1,27 @@ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:22:5 + --> $DIR/write_with_newline.rs:19:5 | -22 | write!(&mut v, "Hello/n"); +19 | write!(&mut v, "Hello/n"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::write-with-newline` implied by `-D warnings` error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:23:5 + --> $DIR/write_with_newline.rs:20:5 | -23 | write!(&mut v, "Hello {}/n", "world"); +20 | write!(&mut v, "Hello {}/n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:24:5 + --> $DIR/write_with_newline.rs:21:5 | -24 | write!(&mut v, "Hello {} {}/n", "world", "#2"); +21 | write!(&mut v, "Hello {} {}/n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:25:5 + --> $DIR/write_with_newline.rs:22:5 | -25 | write!(&mut v, "{}/n", 1265); +22 | write!(&mut v, "{}/n", 1265); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr index 3e6ec33623a..5943dfa09b1 100644 --- a/tests/ui/writeln_empty_string.stderr +++ b/tests/ui/writeln_empty_string.stderr @@ -1,15 +1,15 @@ error: using `writeln!(&mut v, "")` - --> $DIR/writeln_empty_string.rs:21:5 + --> $DIR/writeln_empty_string.rs:18:5 | -21 | writeln!(&mut v, ""); +18 | writeln!(&mut v, ""); | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut v)` | = note: `-D clippy::writeln-empty-string` implied by `-D warnings` error: using `writeln!(&mut suggestion, "")` - --> $DIR/writeln_empty_string.rs:24:5 + --> $DIR/writeln_empty_string.rs:21:5 | -24 | writeln!(&mut suggestion, ""); +21 | writeln!(&mut suggestion, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut suggestion)` error: aborting due to 2 previous errors diff --git a/tests/ui/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index ee0f4f8a143..fa97713ed78 100644 --- a/tests/ui/wrong_self_convention.stderr +++ b/tests/ui/wrong_self_convention.stderr @@ -1,75 +1,75 @@ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:31:17 + --> $DIR/wrong_self_convention.rs:26:17 | -31 | fn from_i32(self) {} +26 | fn from_i32(self) {} | ^^^^ | = note: `-D clippy::wrong-self-convention` implied by `-D warnings` error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:37:21 + --> $DIR/wrong_self_convention.rs:32:21 | -37 | pub fn from_i64(self) {} +32 | pub fn from_i64(self) {} | ^^^^ error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:50:15 + --> $DIR/wrong_self_convention.rs:44:15 | -50 | fn as_i32(self) {} +44 | fn as_i32(self) {} | ^^^^ error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:52:17 + --> $DIR/wrong_self_convention.rs:46:17 | -52 | fn into_i32(&self) {} +46 | fn into_i32(&self) {} | ^^^^^ error: methods called `is_*` usually take self by reference or no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:54:15 + --> $DIR/wrong_self_convention.rs:48:15 | -54 | fn is_i32(self) {} +48 | fn is_i32(self) {} | ^^^^ error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:56:15 + --> $DIR/wrong_self_convention.rs:50:15 | -56 | fn to_i32(self) {} +50 | fn to_i32(self) {} | ^^^^ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:58:17 + --> $DIR/wrong_self_convention.rs:52:17 | -58 | fn from_i32(self) {} +52 | fn from_i32(self) {} | ^^^^ error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:60:19 + --> $DIR/wrong_self_convention.rs:54:19 | -60 | pub fn as_i64(self) {} +54 | pub fn as_i64(self) {} | ^^^^ error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:61:21 + --> $DIR/wrong_self_convention.rs:55:21 | -61 | pub fn into_i64(&self) {} +55 | pub fn into_i64(&self) {} | ^^^^^ error: methods called `is_*` usually take self by reference or no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:62:19 + --> $DIR/wrong_self_convention.rs:56:19 | -62 | pub fn is_i64(self) {} +56 | pub fn is_i64(self) {} | ^^^^ error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:63:19 + --> $DIR/wrong_self_convention.rs:57:19 | -63 | pub fn to_i64(self) {} +57 | pub fn to_i64(self) {} | ^^^^ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:64:21 + --> $DIR/wrong_self_convention.rs:58:21 | -64 | pub fn from_i64(self) {} +58 | pub fn from_i64(self) {} | ^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index 0c24a08a634..312392050c5 100644 --- a/tests/ui/zero_div_zero.stderr +++ b/tests/ui/zero_div_zero.stderr @@ -1,59 +1,59 @@ error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:17:15 + --> $DIR/zero_div_zero.rs:13:15 | -17 | let nan = 0.0 / 0.0; +13 | let nan = 0.0 / 0.0; | ^^^^^^^^^ | = note: #[deny(clippy::eq_op)] on by default error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:17:15 + --> $DIR/zero_div_zero.rs:13:15 | -17 | let nan = 0.0 / 0.0; +13 | let nan = 0.0 / 0.0; | ^^^^^^^^^ | = note: `-D clippy::zero-divided-by-zero` implied by `-D warnings` = help: Consider using `std::f64::NAN` if you would like a constant representing NaN error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:18:19 + --> $DIR/zero_div_zero.rs:14:19 | -18 | let f64_nan = 0.0 / 0.0f64; +14 | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:18:19 + --> $DIR/zero_div_zero.rs:14:19 | -18 | let f64_nan = 0.0 / 0.0f64; +14 | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:19:25 + --> $DIR/zero_div_zero.rs:15:25 | -19 | let other_f64_nan = 0.0f64 / 0.0; +15 | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:19:25 + --> $DIR/zero_div_zero.rs:15:25 | -19 | let other_f64_nan = 0.0f64 / 0.0; +15 | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:20:28 + --> $DIR/zero_div_zero.rs:16:28 | -20 | let one_more_f64_nan = 0.0f64/0.0f64; - | ^^^^^^^^^^^^^ +16 | let one_more_f64_nan = 0.0f64 / 0.0f64; + | ^^^^^^^^^^^^^^^ error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:20:28 + --> $DIR/zero_div_zero.rs:16:28 | -20 | let one_more_f64_nan = 0.0f64/0.0f64; - | ^^^^^^^^^^^^^ +16 | let one_more_f64_nan = 0.0f64 / 0.0f64; + | ^^^^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN diff --git a/tests/ui/zero_ptr.stderr b/tests/ui/zero_ptr.stderr index 7a0c8e70b22..15b27c7c0ad 100644 --- a/tests/ui/zero_ptr.stderr +++ b/tests/ui/zero_ptr.stderr @@ -1,15 +1,15 @@ error: `0 as *const _` detected. Consider using `ptr::null()` - --> $DIR/zero_ptr.rs:16:13 + --> $DIR/zero_ptr.rs:12:13 | -16 | let x = 0 as *const usize; +12 | let x = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::zero-ptr` implied by `-D warnings` error: `0 as *mut _` detected. Consider using `ptr::null_mut()` - --> $DIR/zero_ptr.rs:17:13 + --> $DIR/zero_ptr.rs:13:13 | -17 | let y = 0 as *mut f64; +13 | let y = 0 as *mut f64; | ^^^^^^^^^^^^^ error: aborting due to 2 previous errors