From ac9dd3685632d6a8a0159809e8dc671a327c4875 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Tue, 20 Jul 2021 23:23:22 -0400 Subject: [PATCH] Don't abort compilation after giving a lint error The only reason to use `abort_if_errors` is when the program is so broken that either: 1. later passes get confused and ICE 2. any diagnostics from later passes would be noise This is never the case for lints, because the compiler has to be able to deal with `allow`-ed lints. So it can continue to lint and compile even if there are lint errors. --- .../ui-toml/lint_decimal_readability/test.rs | 1 + .../lint_decimal_readability/test.stderr | 2 +- tests/ui/deref_addrof.fixed | 4 +- tests/ui/deref_addrof.rs | 4 +- tests/ui/double_neg.rs | 1 + tests/ui/double_neg.stderr | 2 +- tests/ui/fn_params_excessive_bools.rs | 1 + tests/ui/fn_params_excessive_bools.stderr | 12 ++--- tests/ui/formatting.rs | 1 + tests/ui/formatting.stderr | 12 ++--- tests/ui/literals.rs | 2 +- tests/ui/many_single_char_names.rs | 1 + tests/ui/many_single_char_names.stderr | 10 ++-- tests/ui/mistyped_literal_suffix.fixed | 2 +- tests/ui/mistyped_literal_suffix.rs | 2 +- tests/ui/mistyped_literal_suffix.stderr | 18 +++---- .../needless_arbitrary_self_type_unfixable.rs | 1 + ...dless_arbitrary_self_type_unfixable.stderr | 2 +- tests/ui/needless_continue.rs | 1 + tests/ui/needless_continue.stderr | 16 +++--- tests/ui/non_expressive_names.rs | 4 +- tests/ui/non_expressive_names.stderr | 12 ++--- tests/ui/redundant_closure_call_early.rs | 1 + tests/ui/redundant_else.rs | 4 +- tests/ui/similar_names.rs | 7 ++- tests/ui/similar_names.stderr | 28 +++++----- tests/ui/suspicious_else_formatting.rs | 1 + tests/ui/suspicious_else_formatting.stderr | 18 +++---- tests/ui/suspicious_operation_groupings.rs | 3 +- .../ui/suspicious_operation_groupings.stderr | 52 +++++++++---------- 30 files changed, 123 insertions(+), 102 deletions(-) diff --git a/tests/ui-toml/lint_decimal_readability/test.rs b/tests/ui-toml/lint_decimal_readability/test.rs index 9377eb69b233..2498672d77fb 100644 --- a/tests/ui-toml/lint_decimal_readability/test.rs +++ b/tests/ui-toml/lint_decimal_readability/test.rs @@ -1,3 +1,4 @@ +#![allow(clippy::excessive_precision)] #[deny(clippy::unreadable_literal)] fn allow_inconsistent_digit_grouping() { diff --git a/tests/ui-toml/lint_decimal_readability/test.stderr b/tests/ui-toml/lint_decimal_readability/test.stderr index 9119ef19a7be..be505bda4792 100644 --- a/tests/ui-toml/lint_decimal_readability/test.stderr +++ b/tests/ui-toml/lint_decimal_readability/test.stderr @@ -1,5 +1,5 @@ error: digits grouped inconsistently by underscores - --> $DIR/test.rs:18:18 + --> $DIR/test.rs:19:18 | LL | let _fail1 = 100_200_300.123456789; | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.123_456_789` diff --git a/tests/ui/deref_addrof.fixed b/tests/ui/deref_addrof.fixed index d4832daa6895..9a150c67a21e 100644 --- a/tests/ui/deref_addrof.fixed +++ b/tests/ui/deref_addrof.fixed @@ -52,12 +52,14 @@ macro_rules! m_mut { }; } +#[derive(Copy, Clone)] pub struct S; impl S { pub fn f(&self) -> &Self { m!(self) } - pub fn f_mut(&self) -> &Self { + #[allow(unused_mut)] // mut will be unused, once the macro is fixed + pub fn f_mut(mut self) -> Self { m_mut!(self) } } diff --git a/tests/ui/deref_addrof.rs b/tests/ui/deref_addrof.rs index be7cc669b5b6..80ba7e9bd0b8 100644 --- a/tests/ui/deref_addrof.rs +++ b/tests/ui/deref_addrof.rs @@ -52,12 +52,14 @@ macro_rules! m_mut { }; } +#[derive(Copy, Clone)] pub struct S; impl S { pub fn f(&self) -> &Self { m!(self) } - pub fn f_mut(&self) -> &Self { + #[allow(unused_mut)] // mut will be unused, once the macro is fixed + pub fn f_mut(mut self) -> Self { m_mut!(self) } } diff --git a/tests/ui/double_neg.rs b/tests/ui/double_neg.rs index d47dfcb5ba1e..38a8fbd74dcf 100644 --- a/tests/ui/double_neg.rs +++ b/tests/ui/double_neg.rs @@ -1,4 +1,5 @@ #[warn(clippy::double_neg)] +#[allow(clippy::no_effect)] fn main() { let x = 1; -x; diff --git a/tests/ui/double_neg.stderr b/tests/ui/double_neg.stderr index d82ed05f0543..7cdb040b6873 100644 --- a/tests/ui/double_neg.stderr +++ b/tests/ui/double_neg.stderr @@ -1,5 +1,5 @@ error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op - --> $DIR/double_neg.rs:6:5 + --> $DIR/double_neg.rs:7:5 | LL | --x; | ^^^ diff --git a/tests/ui/fn_params_excessive_bools.rs b/tests/ui/fn_params_excessive_bools.rs index 7d6fd607e654..1442ee08e754 100644 --- a/tests/ui/fn_params_excessive_bools.rs +++ b/tests/ui/fn_params_excessive_bools.rs @@ -1,4 +1,5 @@ #![warn(clippy::fn_params_excessive_bools)] +#![allow(clippy::too_many_arguments)] extern "C" { fn f(_: bool, _: bool, _: bool, _: bool); diff --git a/tests/ui/fn_params_excessive_bools.stderr b/tests/ui/fn_params_excessive_bools.stderr index 4e5dbc261d66..cd9d07fa115d 100644 --- a/tests/ui/fn_params_excessive_bools.stderr +++ b/tests/ui/fn_params_excessive_bools.stderr @@ -1,5 +1,5 @@ error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:17:1 + --> $DIR/fn_params_excessive_bools.rs:18:1 | LL | fn g(_: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | fn g(_: bool, _: bool, _: bool, _: bool) {} = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:20:1 + --> $DIR/fn_params_excessive_bools.rs:21:1 | LL | fn t(_: S, _: S, _: Box, _: Vec, _: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | fn t(_: S, _: S, _: Box, _: Vec, _: bool, _: bool, _: bool, _: bool = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:24:5 + --> $DIR/fn_params_excessive_bools.rs:25:5 | LL | fn f(_: bool, _: bool, _: bool, _: bool); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | fn f(_: bool, _: bool, _: bool, _: bool); = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:29:5 + --> $DIR/fn_params_excessive_bools.rs:30:5 | LL | fn f(&self, _: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | fn f(&self, _: bool, _: bool, _: bool, _: bool) {} = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:41:5 + --> $DIR/fn_params_excessive_bools.rs:42:5 | LL | / fn n(_: bool, _: u32, _: bool, _: Box, _: bool, _: bool) { LL | | fn nn(_: bool, _: bool, _: bool, _: bool) {} @@ -42,7 +42,7 @@ LL | | } = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:42:9 + --> $DIR/fn_params_excessive_bools.rs:43:9 | LL | fn nn(_: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/formatting.rs b/tests/ui/formatting.rs index 0d14807ff1cf..471a8e0de6e1 100644 --- a/tests/ui/formatting.rs +++ b/tests/ui/formatting.rs @@ -3,6 +3,7 @@ #![allow(unused_assignments)] #![allow(clippy::if_same_then_else)] #![allow(clippy::deref_addrof)] +#![allow(clippy::nonminimal_bool)] fn foo() -> bool { true diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index bde434c7e2e7..9272cd604844 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -1,5 +1,5 @@ error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` - --> $DIR/formatting.rs:15:6 + --> $DIR/formatting.rs:16:6 | LL | a =- 35; | ^^^^ @@ -8,7 +8,7 @@ LL | a =- 35; = 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:16:6 + --> $DIR/formatting.rs:17:6 | LL | a =* &191; | ^^^^ @@ -16,7 +16,7 @@ LL | 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:19:6 + --> $DIR/formatting.rs:20:6 | LL | b =! false; | ^^^^ @@ -24,7 +24,7 @@ LL | b =! false; = note: to remove this lint, use either `!=` or `= !` error: possibly missing a comma here - --> $DIR/formatting.rs:28:19 + --> $DIR/formatting.rs:29:19 | LL | -1, -2, -3 // <= no comma here | ^ @@ -33,7 +33,7 @@ LL | -1, -2, -3 // <= no comma here = 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:32:19 + --> $DIR/formatting.rs:33:19 | LL | -1, -2, -3 // <= no comma here | ^ @@ -41,7 +41,7 @@ LL | -1, -2, -3 // <= no comma here = 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:69:11 + --> $DIR/formatting.rs:70:11 | LL | -1 | ^ diff --git a/tests/ui/literals.rs b/tests/ui/literals.rs index e60ce8492fc7..0cadd5a3da19 100644 --- a/tests/ui/literals.rs +++ b/tests/ui/literals.rs @@ -4,7 +4,7 @@ #![warn(clippy::zero_prefixed_literal)] #![warn(clippy::unseparated_literal_suffix)] #![warn(clippy::separated_literal_suffix)] -#![allow(dead_code)] +#![allow(dead_code, overflowing_literals)] fn main() { let ok1 = 0xABCD; diff --git a/tests/ui/many_single_char_names.rs b/tests/ui/many_single_char_names.rs index 65769819110e..88fcce66873a 100644 --- a/tests/ui/many_single_char_names.rs +++ b/tests/ui/many_single_char_names.rs @@ -1,3 +1,4 @@ +#![allow(clippy::too_many_arguments, clippy::diverging_sub_expression)] #![warn(clippy::many_single_char_names)] fn bla() { diff --git a/tests/ui/many_single_char_names.stderr b/tests/ui/many_single_char_names.stderr index 27e62e641ade..ade0f84bc506 100644 --- a/tests/ui/many_single_char_names.stderr +++ b/tests/ui/many_single_char_names.stderr @@ -1,5 +1,5 @@ error: 5 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:4:9 + --> $DIR/many_single_char_names.rs:5:9 | LL | let a: i32; | ^ @@ -12,7 +12,7 @@ LL | let e: i32; = note: `-D clippy::many-single-char-names` implied by `-D warnings` error: 6 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:4:9 + --> $DIR/many_single_char_names.rs:5:9 | LL | let a: i32; | ^ @@ -25,7 +25,7 @@ LL | let f: i32; | ^ error: 5 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:4:9 + --> $DIR/many_single_char_names.rs:5:9 | LL | let a: i32; | ^ @@ -36,13 +36,13 @@ LL | e => panic!(), | ^ error: 8 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:29:13 + --> $DIR/many_single_char_names.rs:30:13 | LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {} | ^ ^ ^ ^ ^ ^ ^ ^ error: 8 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:32:10 + --> $DIR/many_single_char_names.rs:33:10 | LL | let (a, b, c, d, e, f, g, h): (bool, bool, bool, bool, bool, bool, bool, bool) = unimplemented!(); | ^ ^ ^ ^ ^ ^ ^ ^ diff --git a/tests/ui/mistyped_literal_suffix.fixed b/tests/ui/mistyped_literal_suffix.fixed index 70cdb067d913..5d57638af434 100644 --- a/tests/ui/mistyped_literal_suffix.fixed +++ b/tests/ui/mistyped_literal_suffix.fixed @@ -3,6 +3,7 @@ #![allow( dead_code, unused_variables, + overflowing_literals, clippy::excessive_precision, clippy::inconsistent_digit_grouping )] @@ -21,7 +22,6 @@ fn main() { let fail25 = 1E2_f32; let fail26 = 43E7_f64; let fail27 = 243E17_f32; - #[allow(overflowing_literals)] let fail28 = 241_251_235E723_f64; let ok29 = 42279.911_32; diff --git a/tests/ui/mistyped_literal_suffix.rs b/tests/ui/mistyped_literal_suffix.rs index 729990af3998..12171452885d 100644 --- a/tests/ui/mistyped_literal_suffix.rs +++ b/tests/ui/mistyped_literal_suffix.rs @@ -3,6 +3,7 @@ #![allow( dead_code, unused_variables, + overflowing_literals, clippy::excessive_precision, clippy::inconsistent_digit_grouping )] @@ -21,7 +22,6 @@ fn main() { let fail25 = 1E2_32; let fail26 = 43E7_64; let fail27 = 243E17_32; - #[allow(overflowing_literals)] let fail28 = 241251235E723_64; let ok29 = 42279.911_32; diff --git a/tests/ui/mistyped_literal_suffix.stderr b/tests/ui/mistyped_literal_suffix.stderr index b338b8aa6228..d24543c26e4b 100644 --- a/tests/ui/mistyped_literal_suffix.stderr +++ b/tests/ui/mistyped_literal_suffix.stderr @@ -1,5 +1,5 @@ error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:11:18 + --> $DIR/mistyped_literal_suffix.rs:12:18 | LL | let fail14 = 2_32; | ^^^^ help: did you mean to write: `2_i32` @@ -7,49 +7,49 @@ LL | let fail14 = 2_32; = note: `#[deny(clippy::mistyped_literal_suffixes)]` on by default error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:12:18 + --> $DIR/mistyped_literal_suffix.rs:13:18 | LL | let fail15 = 4_64; | ^^^^ help: did you mean to write: `4_i64` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:13:18 + --> $DIR/mistyped_literal_suffix.rs:14:18 | LL | let fail16 = 7_8; // | ^^^ help: did you mean to write: `7_i8` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:14:18 + --> $DIR/mistyped_literal_suffix.rs:15:18 | LL | let fail17 = 23_16; // | ^^^^^ help: did you mean to write: `23_i16` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:17:18 + --> $DIR/mistyped_literal_suffix.rs:18:18 | LL | let fail20 = 2__8; // | ^^^^ help: did you mean to write: `2_i8` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:18:18 + --> $DIR/mistyped_literal_suffix.rs:19:18 | LL | let fail21 = 4___16; // | ^^^^^^ help: did you mean to write: `4_i16` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:21:18 + --> $DIR/mistyped_literal_suffix.rs:22:18 | LL | let fail25 = 1E2_32; | ^^^^^^ help: did you mean to write: `1E2_f32` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:22:18 + --> $DIR/mistyped_literal_suffix.rs:23:18 | LL | let fail26 = 43E7_64; | ^^^^^^^ help: did you mean to write: `43E7_f64` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:23:18 + --> $DIR/mistyped_literal_suffix.rs:24:18 | LL | let fail27 = 243E17_32; | ^^^^^^^^^ help: did you mean to write: `243E17_f32` diff --git a/tests/ui/needless_arbitrary_self_type_unfixable.rs b/tests/ui/needless_arbitrary_self_type_unfixable.rs index a39d96109f17..ad0d694a2174 100644 --- a/tests/ui/needless_arbitrary_self_type_unfixable.rs +++ b/tests/ui/needless_arbitrary_self_type_unfixable.rs @@ -38,6 +38,7 @@ mod issue_6089 { // fn call_with_mut_self<'life0>(self: &'life0 mut Self) {} #[rename_my_lifetimes] impl T2 for S2 { + #[allow(clippy::needless_lifetimes)] fn call_with_mut_self(self: &mut Self) {} } } diff --git a/tests/ui/needless_arbitrary_self_type_unfixable.stderr b/tests/ui/needless_arbitrary_self_type_unfixable.stderr index 44a0e6ddeace..b2edbfe4323e 100644 --- a/tests/ui/needless_arbitrary_self_type_unfixable.stderr +++ b/tests/ui/needless_arbitrary_self_type_unfixable.stderr @@ -1,5 +1,5 @@ error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type_unfixable.rs:41:31 + --> $DIR/needless_arbitrary_self_type_unfixable.rs:42:31 | LL | fn call_with_mut_self(self: &mut Self) {} | ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'_ mut self` diff --git a/tests/ui/needless_continue.rs b/tests/ui/needless_continue.rs index 83ee27f4887a..f105d3d659ac 100644 --- a/tests/ui/needless_continue.rs +++ b/tests/ui/needless_continue.rs @@ -12,6 +12,7 @@ macro_rules! nonzero { }; } +#[allow(clippy::nonminimal_bool)] fn main() { let mut i = 1; while i < 10 { diff --git a/tests/ui/needless_continue.stderr b/tests/ui/needless_continue.stderr index 22b86f25e8f0..b8657c74caa6 100644 --- a/tests/ui/needless_continue.stderr +++ b/tests/ui/needless_continue.stderr @@ -1,5 +1,5 @@ error: this `else` block is redundant - --> $DIR/needless_continue.rs:28:16 + --> $DIR/needless_continue.rs:29:16 | LL | } else { | ________________^ @@ -35,7 +35,7 @@ LL | | } } error: there is no need for an explicit `else` block for this `if` expression - --> $DIR/needless_continue.rs:43:9 + --> $DIR/needless_continue.rs:44:9 | LL | / if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 { LL | | continue; @@ -55,7 +55,7 @@ LL | | } } error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:56:9 + --> $DIR/needless_continue.rs:57:9 | LL | continue; // should lint here | ^^^^^^^^^ @@ -63,7 +63,7 @@ LL | continue; // should lint here = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:63:9 + --> $DIR/needless_continue.rs:64:9 | LL | continue; // should lint here | ^^^^^^^^^ @@ -71,7 +71,7 @@ LL | continue; // should lint here = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:70:9 + --> $DIR/needless_continue.rs:71:9 | LL | continue // should lint here | ^^^^^^^^ @@ -79,7 +79,7 @@ LL | continue // should lint here = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:78:9 + --> $DIR/needless_continue.rs:79:9 | LL | continue // should lint here | ^^^^^^^^ @@ -87,7 +87,7 @@ LL | continue // should lint here = help: consider dropping the `continue` expression error: this `else` block is redundant - --> $DIR/needless_continue.rs:128:24 + --> $DIR/needless_continue.rs:129:24 | LL | } else { | ________________________^ @@ -110,7 +110,7 @@ LL | | } } error: there is no need for an explicit `else` block for this `if` expression - --> $DIR/needless_continue.rs:134:17 + --> $DIR/needless_continue.rs:135:17 | LL | / if condition() { LL | | continue; // should lint here diff --git a/tests/ui/non_expressive_names.rs b/tests/ui/non_expressive_names.rs index 961f6f409ddd..9937005d68d8 100644 --- a/tests/ui/non_expressive_names.rs +++ b/tests/ui/non_expressive_names.rs @@ -1,5 +1,5 @@ #![warn(clippy::all)] -#![allow(unused, clippy::println_empty_string)] +#![allow(unused, clippy::println_empty_string, non_snake_case)] #[derive(Clone, Debug)] enum MaybeInst { @@ -14,6 +14,7 @@ struct InstSplit { impl MaybeInst { fn fill(&mut self) { + #[allow(non_fmt_panics)] let filled = match *self { MaybeInst::Split1(goto1) => panic!("1"), MaybeInst::Split2(goto2) => panic!("2"), @@ -36,6 +37,7 @@ fn issue2927() { } fn issue3078() { + #[allow(clippy::single_match)] match "a" { stringify!(a) => {}, _ => {}, diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index a0ca46f0efc6..116d5da8729c 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,5 +1,5 @@ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:27:9 + --> $DIR/non_expressive_names.rs:28:9 | LL | let _1 = 1; //~ERROR Consider a more descriptive name | ^^ @@ -7,31 +7,31 @@ LL | 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:28:9 + --> $DIR/non_expressive_names.rs:29:9 | LL | let ____1 = 1; //~ERROR Consider a more descriptive name | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:29:9 + --> $DIR/non_expressive_names.rs:30:9 | LL | let __1___2 = 12; //~ERROR Consider a more descriptive name | ^^^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:49:13 + --> $DIR/non_expressive_names.rs:51:13 | LL | let _1 = 1; | ^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:50:13 + --> $DIR/non_expressive_names.rs:52:13 | LL | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:51:13 + --> $DIR/non_expressive_names.rs:53:13 | LL | let __1___2 = 12; | ^^^^^^^ diff --git a/tests/ui/redundant_closure_call_early.rs b/tests/ui/redundant_closure_call_early.rs index 3dd365620ccb..5649d8dd14c4 100644 --- a/tests/ui/redundant_closure_call_early.rs +++ b/tests/ui/redundant_closure_call_early.rs @@ -15,5 +15,6 @@ fn main() { #[allow(clippy::needless_return)] (|| return 2)(); (|| -> Option { None? })(); + #[allow(clippy::try_err)] (|| -> Result { Err(2)? })(); } diff --git a/tests/ui/redundant_else.rs b/tests/ui/redundant_else.rs index 737c8a9f8db4..e8a6e940c01c 100644 --- a/tests/ui/redundant_else.rs +++ b/tests/ui/redundant_else.rs @@ -1,5 +1,5 @@ #![warn(clippy::redundant_else)] -#![allow(clippy::needless_return)] +#![allow(clippy::needless_return, clippy::if_same_then_else)] fn main() { loop { @@ -105,7 +105,7 @@ fn main() { 1 }; // assign - let a; + let mut a; a = if foo() { return; } else { diff --git a/tests/ui/similar_names.rs b/tests/ui/similar_names.rs index daa073414577..76f6ce9ee6b4 100644 --- a/tests/ui/similar_names.rs +++ b/tests/ui/similar_names.rs @@ -1,5 +1,10 @@ #![warn(clippy::similar_names)] -#![allow(unused, clippy::println_empty_string)] +#![allow( + unused, + clippy::println_empty_string, + clippy::empty_loop, + clippy::diverging_sub_expression +)] struct Foo { apple: i32, diff --git a/tests/ui/similar_names.stderr b/tests/ui/similar_names.stderr index f621595abaea..faf572b0c6bc 100644 --- a/tests/ui/similar_names.stderr +++ b/tests/ui/similar_names.stderr @@ -1,84 +1,84 @@ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:15:9 + --> $DIR/similar_names.rs:20:9 | LL | let bpple: i32; | ^^^^^ | = note: `-D clippy::similar-names` implied by `-D warnings` note: existing binding defined here - --> $DIR/similar_names.rs:13:9 + --> $DIR/similar_names.rs:18:9 | LL | let apple: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:17:9 + --> $DIR/similar_names.rs:22:9 | LL | let cpple: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:13:9 + --> $DIR/similar_names.rs:18:9 | LL | let apple: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:41:9 + --> $DIR/similar_names.rs:46:9 | LL | let bluby: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:40:9 + --> $DIR/similar_names.rs:45:9 | LL | let blubx: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:45:9 + --> $DIR/similar_names.rs:50:9 | LL | let coke: i32; | ^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:43:9 + --> $DIR/similar_names.rs:48:9 | LL | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:63:9 + --> $DIR/similar_names.rs:68:9 | LL | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:61:9 + --> $DIR/similar_names.rs:66:9 | LL | let xyz1abc: i32; | ^^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:67:9 + --> $DIR/similar_names.rs:72:9 | LL | let parsee: i32; | ^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:65:9 + --> $DIR/similar_names.rs:70:9 | LL | let parser: i32; | ^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:88:16 + --> $DIR/similar_names.rs:93:16 | LL | bpple: sprang, | ^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:87:16 + --> $DIR/similar_names.rs:92:16 | LL | apple: spring, | ^^^^^^ diff --git a/tests/ui/suspicious_else_formatting.rs b/tests/ui/suspicious_else_formatting.rs index be8bc22bf98a..fcd827a91c7f 100644 --- a/tests/ui/suspicious_else_formatting.rs +++ b/tests/ui/suspicious_else_formatting.rs @@ -1,6 +1,7 @@ // aux-build:proc_macro_suspicious_else_formatting.rs #![warn(clippy::suspicious_else_formatting)] +#![allow(clippy::if_same_then_else)] extern crate proc_macro_suspicious_else_formatting; use proc_macro_suspicious_else_formatting::DeriveBadSpan; diff --git a/tests/ui/suspicious_else_formatting.stderr b/tests/ui/suspicious_else_formatting.stderr index d1db195cbb87..ee68eb5a791c 100644 --- a/tests/ui/suspicious_else_formatting.stderr +++ b/tests/ui/suspicious_else_formatting.stderr @@ -1,5 +1,5 @@ error: this looks like an `else {..}` but the `else` is missing - --> $DIR/suspicious_else_formatting.rs:16:6 + --> $DIR/suspicious_else_formatting.rs:17:6 | LL | } { | ^ @@ -8,7 +8,7 @@ LL | } { = note: to remove this lint, add the missing `else` or add a new line before the next block error: this looks like an `else if` but the `else` is missing - --> $DIR/suspicious_else_formatting.rs:20:6 + --> $DIR/suspicious_else_formatting.rs:21:6 | LL | } if foo() { | ^ @@ -16,7 +16,7 @@ LL | } 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/suspicious_else_formatting.rs:27:10 + --> $DIR/suspicious_else_formatting.rs:28:10 | LL | } if foo() { | ^ @@ -24,7 +24,7 @@ LL | } 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/suspicious_else_formatting.rs:35:10 + --> $DIR/suspicious_else_formatting.rs:36:10 | LL | } if foo() { | ^ @@ -32,7 +32,7 @@ LL | } 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 {..}` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:44:6 + --> $DIR/suspicious_else_formatting.rs:45:6 | LL | } else | ______^ @@ -42,7 +42,7 @@ LL | | { = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` error: this is an `else if` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:56:6 + --> $DIR/suspicious_else_formatting.rs:57:6 | LL | } else | ______^ @@ -52,7 +52,7 @@ LL | | 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/suspicious_else_formatting.rs:61:6 + --> $DIR/suspicious_else_formatting.rs:62:6 | LL | } | ______^ @@ -63,7 +63,7 @@ LL | | 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 {..}` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:88:6 + --> $DIR/suspicious_else_formatting.rs:89:6 | LL | } | ______^ @@ -75,7 +75,7 @@ LL | | { = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` error: this is an `else {..}` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:96:6 + --> $DIR/suspicious_else_formatting.rs:97:6 | LL | } | ______^ diff --git a/tests/ui/suspicious_operation_groupings.rs b/tests/ui/suspicious_operation_groupings.rs index 2f8c7cec50f8..3201d5de0f35 100644 --- a/tests/ui/suspicious_operation_groupings.rs +++ b/tests/ui/suspicious_operation_groupings.rs @@ -1,4 +1,5 @@ #![warn(clippy::suspicious_operation_groupings)] +#![allow(clippy::eq_op)] struct Vec3 { x: f64, @@ -187,7 +188,7 @@ fn inside_fn_with_similar_expression(s1: &S, s2: &S, strict: bool) -> bool { } } -fn inside_an_if_statement(s1: &S, s2: &S) { +fn inside_an_if_statement(s1: &mut S, s2: &S) { // There's no `s1.b` if s1.a < s2.a && s1.a < s2.b { s1.c = s2.c; diff --git a/tests/ui/suspicious_operation_groupings.stderr b/tests/ui/suspicious_operation_groupings.stderr index dd6f2f6641d6..baf9bc74b000 100644 --- a/tests/ui/suspicious_operation_groupings.stderr +++ b/tests/ui/suspicious_operation_groupings.stderr @@ -1,5 +1,5 @@ error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:14:9 + --> $DIR/suspicious_operation_groupings.rs:15:9 | LL | self.x == other.y && self.y == other.y && self.z == other.z | ^^^^^^^^^^^^^^^^^ help: did you mean: `self.x == other.x` @@ -7,151 +7,151 @@ LL | self.x == other.y && self.y == other.y && self.z == other.z = note: `-D clippy::suspicious-operation-groupings` implied by `-D warnings` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:27:20 + --> $DIR/suspicious_operation_groupings.rs:28:20 | LL | s1.a < s2.a && s1.a < s2.b | ^^^^^^^^^^^ help: did you mean: `s1.b < s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:75:33 + --> $DIR/suspicious_operation_groupings.rs:76:33 | LL | s1.a * s2.a + s1.b * s2.b + s1.c * s2.b + s1.d * s2.d | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:80:19 + --> $DIR/suspicious_operation_groupings.rs:81:19 | LL | s1.a * s2.a + s1.b * s2.c + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:80:19 + --> $DIR/suspicious_operation_groupings.rs:81:19 | LL | s1.a * s2.a + s1.b * s2.c + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:85:19 + --> $DIR/suspicious_operation_groupings.rs:86:19 | LL | s1.a * s2.a + s2.b * s2.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:90:19 + --> $DIR/suspicious_operation_groupings.rs:91:19 | LL | s1.a * s2.a + s1.b * s1.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:95:5 + --> $DIR/suspicious_operation_groupings.rs:96:5 | LL | s1.a * s1.a + s1.b * s2.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.a * s2.a` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:100:33 + --> $DIR/suspicious_operation_groupings.rs:101:33 | LL | s1.a * s2.a + s1.b * s2.b + s1.c * s1.c | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:113:20 + --> $DIR/suspicious_operation_groupings.rs:114:20 | LL | (s1.a * s2.a + s1.b * s1.b) | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:118:34 + --> $DIR/suspicious_operation_groupings.rs:119:34 | LL | (s1.a * s2.a + s1.b * s2.b + s1.c * s2.b + s1.d * s2.d) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:123:38 + --> $DIR/suspicious_operation_groupings.rs:124:38 | LL | (s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:128:39 + --> $DIR/suspicious_operation_groupings.rs:129:39 | LL | ((s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d)) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:133:42 + --> $DIR/suspicious_operation_groupings.rs:134:42 | LL | (((s1.a * s2.a) + (s1.b * s2.b)) + ((s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:133:42 + --> $DIR/suspicious_operation_groupings.rs:134:42 | LL | (((s1.a * s2.a) + (s1.b * s2.b)) + ((s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:138:40 + --> $DIR/suspicious_operation_groupings.rs:139:40 | LL | (((s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b)) + (s1.d * s2.d)) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:143:40 + --> $DIR/suspicious_operation_groupings.rs:144:40 | LL | ((s1.a * s2.a) + ((s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:148:20 + --> $DIR/suspicious_operation_groupings.rs:149:20 | LL | (s1.a * s2.a + s2.b * s2.b) / 2 | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:153:35 + --> $DIR/suspicious_operation_groupings.rs:154:35 | LL | i32::swap_bytes(s1.a * s2.a + s2.b * s2.b) | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:158:29 + --> $DIR/suspicious_operation_groupings.rs:159:29 | LL | s1.a > 0 && s1.b > 0 && s1.d == s2.c && s1.d == s2.d | ^^^^^^^^^^^^ help: did you mean: `s1.c == s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:163:17 + --> $DIR/suspicious_operation_groupings.rs:164:17 | LL | s1.a > 0 && s1.d == s2.c && s1.b > 0 && s1.d == s2.d | ^^^^^^^^^^^^ help: did you mean: `s1.c == s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:172:77 + --> $DIR/suspicious_operation_groupings.rs:173:77 | LL | (n1.inner.0).0 == (n2.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.1).0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `(n1.inner.2).0 == (n2.inner.2).0` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:186:25 + --> $DIR/suspicious_operation_groupings.rs:187:25 | LL | s1.a <= s2.a && s1.a <= s2.b | ^^^^^^^^^^^^ help: did you mean: `s1.b <= s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:192:23 + --> $DIR/suspicious_operation_groupings.rs:193:23 | LL | if s1.a < s2.a && s1.a < s2.b { | ^^^^^^^^^^^ help: did you mean: `s1.b < s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:199:48 + --> $DIR/suspicious_operation_groupings.rs:200:48 | LL | -(-(-s1.a * -s2.a) + (-(-s1.b * -s2.b) + -(-s1.c * -s2.b) + -(-s1.d * -s2.d))) | ^^^^^^^^^^^^^ help: did you mean: `-s1.c * -s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:204:27 + --> $DIR/suspicious_operation_groupings.rs:205:27 | LL | -(if -s1.a < -s2.a && -s1.a < -s2.b { s1.c } else { s2.a }) | ^^^^^^^^^^^^^ help: did you mean: `-s1.b < -s2.b`