diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 8dffe04fd656..82f5d644e742 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -1,4 +1,5 @@ use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then}; +use clippy_utils::is_lint_allowed; use clippy_utils::source::snippet_opt; use clippy_utils::ty::has_drop; use rustc_errors::Applicability; @@ -79,12 +80,13 @@ impl<'tcx> LateLintPass<'tcx> for NoEffect { fn check_no_effect(cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) -> bool { if let StmtKind::Semi(expr) = stmt.kind { - if has_no_effect(cx, expr) { + if has_no_effect(cx, expr) && !is_lint_allowed(cx, NO_EFFECT, expr.hir_id) { span_lint_hir(cx, NO_EFFECT, expr.hir_id, stmt.span, "statement with no effect"); return true; } } else if let StmtKind::Local(local) = stmt.kind { if_chain! { + if !is_lint_allowed(cx, NO_EFFECT_UNDERSCORE_BINDING, local.hir_id); if let Some(init) = local.init; if !local.pat.span.from_expansion(); if has_no_effect(cx, init); diff --git a/tests/ui-internal/if_chain_style.stderr b/tests/ui-internal/if_chain_style.stderr index d0f100f00692..de6a0b599a2c 100644 --- a/tests/ui-internal/if_chain_style.stderr +++ b/tests/ui-internal/if_chain_style.stderr @@ -32,6 +32,14 @@ error: `let` expression should be inside `then { .. }` LL | let x = ""; | ^^^^^^^^^^^ +error: unnecessary operation + --> $DIR/if_chain_style.rs:26:13 + | +LL | (); + | ^^^ help: statement can be reduced to + | + = note: `-D clippy::unnecessary-operation` implied by `-D warnings` + error: this `if` can be part of the outer `if_chain!` --> $DIR/if_chain_style.rs:35:13 | @@ -81,5 +89,23 @@ LL | / let x = ""; LL | | let x = ""; | |_______________________^ -error: aborting due to 7 previous errors +error: unnecessary operation + --> $DIR/if_chain_style.rs:57:9 + | +LL | (); + | ^^^ help: statement can be reduced to + +error: unnecessary operation + --> $DIR/if_chain_style.rs:61:20 + | +LL | then { (); } + | ^^^ help: statement can be reduced to + +error: unnecessary operation + --> $DIR/if_chain_style.rs:68:16 + | +LL | then { (); } + | ^^^ help: statement can be reduced to + +error: aborting due to 11 previous errors diff --git a/tests/ui/author/blocks.rs b/tests/ui/author/blocks.rs index c8465cd59aae..ec26e866727e 100644 --- a/tests/ui/author/blocks.rs +++ b/tests/ui/author/blocks.rs @@ -1,4 +1,4 @@ -#![allow(redundant_semicolons, clippy::no_effect)] +#![allow(redundant_semicolons, clippy::no_effect, clippy::unnecessary_operation)] #[rustfmt::skip] fn main() { diff --git a/tests/ui/cfg_attr_rustfmt.fixed b/tests/ui/cfg_attr_rustfmt.fixed index 4e583a25b94c..061a4ab9b2ef 100644 --- a/tests/ui/cfg_attr_rustfmt.fixed +++ b/tests/ui/cfg_attr_rustfmt.fixed @@ -1,7 +1,7 @@ // run-rustfix #![feature(stmt_expr_attributes)] -#![allow(unused, clippy::no_effect)] +#![allow(unused, clippy::no_effect, clippy::unnecessary_operation)] #![warn(clippy::deprecated_cfg_attr)] // This doesn't get linted, see known problems diff --git a/tests/ui/cfg_attr_rustfmt.rs b/tests/ui/cfg_attr_rustfmt.rs index 9c0fcf6fb454..035169fab85b 100644 --- a/tests/ui/cfg_attr_rustfmt.rs +++ b/tests/ui/cfg_attr_rustfmt.rs @@ -1,7 +1,7 @@ // run-rustfix #![feature(stmt_expr_attributes)] -#![allow(unused, clippy::no_effect)] +#![allow(unused, clippy::no_effect, clippy::unnecessary_operation)] #![warn(clippy::deprecated_cfg_attr)] // This doesn't get linted, see known problems diff --git a/tests/ui/crashes/ice-7340.rs b/tests/ui/crashes/ice-7340.rs index 7d2351d606f1..62c78bcbbc56 100644 --- a/tests/ui/crashes/ice-7340.rs +++ b/tests/ui/crashes/ice-7340.rs @@ -1,4 +1,4 @@ -#![allow(clippy::no_effect)] +#![allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { const CONSTANT: usize = 8; diff --git a/tests/ui/erasing_op.stderr b/tests/ui/erasing_op.stderr index e54ce85f98ec..c07595120a64 100644 --- a/tests/ui/erasing_op.stderr +++ b/tests/ui/erasing_op.stderr @@ -1,3 +1,11 @@ +error: unnecessary operation + --> $DIR/erasing_op.rs:6:5 + | +LL | x * 0; + | ^^^^^^ help: statement can be reduced to: `x;0;` + | + = note: `-D clippy::unnecessary-operation` implied by `-D warnings` + error: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:6:5 | @@ -6,17 +14,29 @@ LL | x * 0; | = note: `-D clippy::erasing-op` implied by `-D warnings` +error: unnecessary operation + --> $DIR/erasing_op.rs:7:5 + | +LL | 0 & x; + | ^^^^^^ help: statement can be reduced to: `0;x;` + error: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:7:5 | LL | 0 & x; | ^^^^^ +error: unnecessary operation + --> $DIR/erasing_op.rs:8:5 + | +LL | 0 / x; + | ^^^^^^ help: statement can be reduced to: `0;x;` + error: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:8:5 | LL | 0 / x; | ^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/eta.fixed b/tests/ui/eta.fixed index 1de79667f55f..3f018adc0230 100644 --- a/tests/ui/eta.fixed +++ b/tests/ui/eta.fixed @@ -29,7 +29,7 @@ macro_rules! closure_mac { fn main() { let a = Some(1u8).map(foo); - let c = Some(1u8).map(|a| {1+2; foo}(a)); + let c = Some(1u8).map(|a| {1;2; foo}(a)); true.then(|| mac!()); // don't lint function in macro expansion Some(1).map(closure_mac!()); // don't lint closure in macro expansion let _: Option> = true.then(std::vec::Vec::new); // special case vec! diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index 8092f04c3fc3..b3916ac878ee 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -6,6 +6,14 @@ LL | let a = Some(1u8).map(|a| foo(a)); | = note: `-D clippy::redundant-closure` implied by `-D warnings` +error: unnecessary operation + --> $DIR/eta.rs:32:32 + | +LL | let c = Some(1u8).map(|a| {1+2; foo}(a)); + | ^^^^ help: statement can be reduced to: `1;2;` + | + = note: `-D clippy::unnecessary-operation` implied by `-D warnings` + error: redundant closure --> $DIR/eta.rs:35:40 | @@ -130,5 +138,5 @@ error: redundant closure LL | map_str_to_path(|s| s.as_ref()); | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::convert::AsRef::as_ref` -error: aborting due to 21 previous errors +error: aborting due to 22 previous errors diff --git a/tests/ui/if_same_then_else.stderr b/tests/ui/if_same_then_else.stderr index 2f38052fc209..5b999980b989 100644 --- a/tests/ui/if_same_then_else.stderr +++ b/tests/ui/if_same_then_else.stderr @@ -25,6 +25,92 @@ LL | | foo(); LL | | } | |_____^ +error: unnecessary operation + --> $DIR/if_same_then_else.rs:22:9 + | +LL | Foo { bar: 42 }; + | ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;` + | + = note: `-D clippy::unnecessary-operation` implied by `-D warnings` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:23:9 + | +LL | 0..10; + | ^^^^^^ help: statement can be reduced to: `0;10;` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:24:9 + | +LL | ..; + | ^^^ help: statement can be reduced to + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:25:9 + | +LL | 0..; + | ^^^^ help: statement can be reduced to: `0;` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:26:9 + | +LL | ..10; + | ^^^^^ help: statement can be reduced to: `10;` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:31:9 + | +LL | Foo { bar: 42 }; + | ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:32:9 + | +LL | 0..10; + | ^^^^^^ help: statement can be reduced to: `0;10;` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:33:9 + | +LL | ..; + | ^^^ help: statement can be reduced to + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:34:9 + | +LL | 0..; + | ^^^^ help: statement can be reduced to: `0;` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:35:9 + | +LL | ..10; + | ^^^^^ help: statement can be reduced to: `10;` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:41:9 + | +LL | Foo { bar: 42 }; + | ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:43:9 + | +LL | Foo { bar: 43 }; + | ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `43;` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:47:9 + | +LL | (); + | ^^^ help: statement can be reduced to + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:53:9 + | +LL | 0..10; + | ^^^^^^ help: statement can be reduced to: `0;10;` + error: this `if` has identical blocks --> $DIR/if_same_then_else.rs:65:21 | @@ -108,5 +194,17 @@ LL | | bar + 1; LL | | } | |_____^ -error: aborting due to 5 previous errors +error: unnecessary operation + --> $DIR/if_same_then_else.rs:101:9 + | +LL | bar + 1; + | ^^^^^^^^ help: statement can be reduced to: `bar;1;` + +error: unnecessary operation + --> $DIR/if_same_then_else.rs:109:9 + | +LL | bar + 1; + | ^^^^^^^^ help: statement can be reduced to: `bar;1;` + +error: aborting due to 21 previous errors diff --git a/tests/ui/let_unit.fixed b/tests/ui/let_unit.fixed index f398edc23cb5..250d7539f7a2 100644 --- a/tests/ui/let_unit.fixed +++ b/tests/ui/let_unit.fixed @@ -1,7 +1,7 @@ // run-rustfix #![warn(clippy::let_unit_value)] -#![allow(clippy::no_effect)] +#![allow(clippy::no_effect, clippy::unnecessary_operation)] #![allow(unused_variables)] macro_rules! let_and_return { diff --git a/tests/ui/let_unit.rs b/tests/ui/let_unit.rs index af5b1fb2ac7e..5166984b7876 100644 --- a/tests/ui/let_unit.rs +++ b/tests/ui/let_unit.rs @@ -1,7 +1,7 @@ // run-rustfix #![warn(clippy::let_unit_value)] -#![allow(clippy::no_effect)] +#![allow(clippy::no_effect, clippy::unnecessary_operation)] #![allow(unused_variables)] macro_rules! let_and_return { diff --git a/tests/ui/needless_bool/fixable.fixed b/tests/ui/needless_bool/fixable.fixed index a2e3988daff1..7f46fce56d35 100644 --- a/tests/ui/needless_bool/fixable.fixed +++ b/tests/ui/needless_bool/fixable.fixed @@ -5,6 +5,7 @@ unused, dead_code, clippy::no_effect, + clippy::unnecessary_operation, clippy::if_same_then_else, clippy::equatable_if_let, clippy::needless_return, diff --git a/tests/ui/needless_bool/fixable.rs b/tests/ui/needless_bool/fixable.rs index 75805e857891..18b1a5948c13 100644 --- a/tests/ui/needless_bool/fixable.rs +++ b/tests/ui/needless_bool/fixable.rs @@ -5,6 +5,7 @@ unused, dead_code, clippy::no_effect, + clippy::unnecessary_operation, clippy::if_same_then_else, clippy::equatable_if_let, clippy::needless_return, diff --git a/tests/ui/needless_bool/fixable.stderr b/tests/ui/needless_bool/fixable.stderr index 1fa12add1673..781a387fcb8a 100644 --- a/tests/ui/needless_bool/fixable.stderr +++ b/tests/ui/needless_bool/fixable.stderr @@ -1,5 +1,5 @@ error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:41:5 + --> $DIR/fixable.rs:42:5 | LL | / if x { LL | | true @@ -11,7 +11,7 @@ LL | | }; = note: `-D clippy::needless-bool` implied by `-D warnings` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:46:5 + --> $DIR/fixable.rs:47:5 | LL | / if x { LL | | false @@ -21,7 +21,7 @@ LL | | }; | |_____^ help: you can reduce it to: `!x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:51:5 + --> $DIR/fixable.rs:52:5 | LL | / if x && y { LL | | false @@ -31,7 +31,7 @@ LL | | }; | |_____^ help: you can reduce it to: `!(x && y)` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:71:5 + --> $DIR/fixable.rs:72:5 | LL | / if x { LL | | return true; @@ -41,7 +41,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:79:5 + --> $DIR/fixable.rs:80:5 | LL | / if x { LL | | return false; @@ -51,7 +51,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return !x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:87:5 + --> $DIR/fixable.rs:88:5 | LL | / if x && y { LL | | return true; @@ -61,7 +61,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return x && y` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:95:5 + --> $DIR/fixable.rs:96:5 | LL | / if x && y { LL | | return false; @@ -71,7 +71,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return !(x && y)` error: equality checks against true are unnecessary - --> $DIR/fixable.rs:103:8 + --> $DIR/fixable.rs:104:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` @@ -79,25 +79,25 @@ LL | if x == true {}; = note: `-D clippy::bool-comparison` implied by `-D warnings` error: equality checks against false can be replaced by a negation - --> $DIR/fixable.rs:107:8 + --> $DIR/fixable.rs:108:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/fixable.rs:117:8 + --> $DIR/fixable.rs:118:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/fixable.rs:118:8 + --> $DIR/fixable.rs:119:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:127:12 + --> $DIR/fixable.rs:128:12 | LL | } else if returns_bool() { | ____________^ diff --git a/tests/ui/needless_update.stderr b/tests/ui/needless_update.stderr index b154b3b306dd..b37a2a8c0e15 100644 --- a/tests/ui/needless_update.stderr +++ b/tests/ui/needless_update.stderr @@ -1,3 +1,23 @@ +error: unnecessary operation + --> $DIR/needless_update.rs:17:5 + | +LL | S { ..base }; // no error + | ^^^^^^^^^^^^^ help: statement can be reduced to: `base;` + | + = note: `-D clippy::unnecessary-operation` implied by `-D warnings` + +error: unnecessary operation + --> $DIR/needless_update.rs:18:5 + | +LL | S { a: 1, ..base }; // no error + | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `1;base;` + +error: unnecessary operation + --> $DIR/needless_update.rs:19:5 + | +LL | S { a: 1, b: 1, ..base }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `1;1;base;` + error: struct update has no effect, all the fields in the struct have already been specified --> $DIR/needless_update.rs:19:23 | @@ -6,5 +26,23 @@ LL | S { a: 1, b: 1, ..base }; | = note: `-D clippy::needless-update` implied by `-D warnings` -error: aborting due to previous error +error: unnecessary operation + --> $DIR/needless_update.rs:22:5 + | +LL | T { ..base }; // no error + | ^^^^^^^^^^^^^ help: statement can be reduced to: `base;` + +error: unnecessary operation + --> $DIR/needless_update.rs:23:5 + | +LL | T { x: 1, ..base }; // no error + | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `1;base;` + +error: unnecessary operation + --> $DIR/needless_update.rs:24:5 + | +LL | T { x: 1, y: 1, ..base }; // no error + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `1;1;base;` + +error: aborting due to 7 previous errors diff --git a/tests/ui/out_of_bounds_indexing/issue-3102.stderr b/tests/ui/out_of_bounds_indexing/issue-3102.stderr index 516c1df40be0..181a4f8349f5 100644 --- a/tests/ui/out_of_bounds_indexing/issue-3102.stderr +++ b/tests/ui/out_of_bounds_indexing/issue-3102.stderr @@ -1,3 +1,11 @@ +error: unnecessary operation + --> $DIR/issue-3102.rs:9:5 + | +LL | &x[num..10]; // should trigger out of bounds error + | ^^^^^^^^^^^^ help: statement can be reduced to: `x;num..10;` + | + = note: `-D clippy::unnecessary-operation` implied by `-D warnings` + error: range is out of bounds --> $DIR/issue-3102.rs:9:13 | @@ -6,11 +14,17 @@ LL | &x[num..10]; // should trigger out of bounds error | = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` +error: unnecessary operation + --> $DIR/issue-3102.rs:10:5 + | +LL | &x[10..num]; // should trigger out of bounds error + | ^^^^^^^^^^^^ help: statement can be reduced to: `x;10..num;` + error: range is out of bounds --> $DIR/issue-3102.rs:10:8 | LL | &x[10..num]; // should trigger out of bounds error | ^^ -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/redundant_field_names.fixed b/tests/ui/redundant_field_names.fixed index 5b4b8eeedd46..264b55e5c413 100644 --- a/tests/ui/redundant_field_names.fixed +++ b/tests/ui/redundant_field_names.fixed @@ -1,6 +1,6 @@ // run-rustfix #![warn(clippy::redundant_field_names)] -#![allow(clippy::no_effect, dead_code, unused_variables)] +#![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code, unused_variables)] #[macro_use] extern crate derive_new; diff --git a/tests/ui/redundant_field_names.rs b/tests/ui/redundant_field_names.rs index 3f97b80c5682..6778af5c4afd 100644 --- a/tests/ui/redundant_field_names.rs +++ b/tests/ui/redundant_field_names.rs @@ -1,6 +1,6 @@ // run-rustfix #![warn(clippy::redundant_field_names)] -#![allow(clippy::no_effect, dead_code, unused_variables)] +#![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code, unused_variables)] #[macro_use] extern crate derive_new; diff --git a/tests/ui/unnecessary_cast.stderr b/tests/ui/unnecessary_cast.stderr index 70aa448af68e..4b0cdceda562 100644 --- a/tests/ui/unnecessary_cast.stderr +++ b/tests/ui/unnecessary_cast.stderr @@ -1,3 +1,11 @@ +error: unnecessary operation + --> $DIR/unnecessary_cast.rs:6:5 + | +LL | 1i32 as i32; + | ^^^^^^^^^^^^ help: statement can be reduced to: `1i32;` + | + = note: `-D clippy::unnecessary-operation` implied by `-D warnings` + error: casting integer literal to `i32` is unnecessary --> $DIR/unnecessary_cast.rs:6:5 | @@ -6,17 +14,41 @@ LL | 1i32 as i32; | = note: `-D clippy::unnecessary-cast` implied by `-D warnings` +error: unnecessary operation + --> $DIR/unnecessary_cast.rs:7:5 + | +LL | 1f32 as f32; + | ^^^^^^^^^^^^ help: statement can be reduced to: `1f32;` + error: casting float literal to `f32` is unnecessary --> $DIR/unnecessary_cast.rs:7:5 | LL | 1f32 as f32; | ^^^^^^^^^^^ help: try: `1_f32` +error: unnecessary operation + --> $DIR/unnecessary_cast.rs:8:5 + | +LL | false as bool; + | ^^^^^^^^^^^^^^ help: statement can be reduced to: `false;` + error: casting to the same type is unnecessary (`bool` -> `bool`) --> $DIR/unnecessary_cast.rs:8:5 | LL | false as bool; | ^^^^^^^^^^^^^ help: try: `false` -error: aborting due to 3 previous errors +error: unnecessary operation + --> $DIR/unnecessary_cast.rs:9:5 + | +LL | &1i32 as &i32; + | ^^^^^^^^^^^^^^ help: statement can be reduced to: `1i32;` + +error: unnecessary operation + --> $DIR/unnecessary_cast.rs:25:5 + | +LL | 1 as std::os::raw::c_char; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `1;` + +error: aborting due to 8 previous errors diff --git a/tests/ui/unnecessary_wraps.stderr b/tests/ui/unnecessary_wraps.stderr index 8e31db395024..6f3e86c63a46 100644 --- a/tests/ui/unnecessary_wraps.stderr +++ b/tests/ui/unnecessary_wraps.stderr @@ -25,6 +25,14 @@ LL ~ 2 LL | } else { ... +error: unnecessary operation + --> $DIR/unnecessary_wraps.rs:13:9 + | +LL | Some(-1); + | ^^^^^^^^^ help: statement can be reduced to: `-1;` + | + = note: `-D clippy::unnecessary-operation` implied by `-D warnings` + error: this function's return value is unnecessarily wrapped by `Option` --> $DIR/unnecessary_wraps.rs:21:1 | @@ -124,6 +132,12 @@ LL ~ LL | } else { ... +error: unnecessary operation + --> $DIR/unnecessary_wraps.rs:109:9 + | +LL | Some(()); + | ^^^^^^^^^ help: statement can be reduced to: `();` + error: this function's return value is unnecessary --> $DIR/unnecessary_wraps.rs:117:1 | @@ -150,5 +164,5 @@ LL | } else { LL ~ return ; | -error: aborting due to 7 previous errors +error: aborting due to 9 previous errors diff --git a/tests/ui/unused_unit.fixed b/tests/ui/unused_unit.fixed index 7bb43cf7ae82..e5901e4f4e32 100644 --- a/tests/ui/unused_unit.fixed +++ b/tests/ui/unused_unit.fixed @@ -11,7 +11,7 @@ #![deny(clippy::unused_unit)] #![allow(dead_code)] -#![allow(clippy::from_over_into)] +#![allow(clippy::from_over_into, clippy::unnecessary_operation)] struct Unitter; impl Unitter { diff --git a/tests/ui/unused_unit.rs b/tests/ui/unused_unit.rs index 21073fb802ad..f9c126c5e3cc 100644 --- a/tests/ui/unused_unit.rs +++ b/tests/ui/unused_unit.rs @@ -11,7 +11,7 @@ #![deny(clippy::unused_unit)] #![allow(dead_code)] -#![allow(clippy::from_over_into)] +#![allow(clippy::from_over_into, clippy::unnecessary_operation)] struct Unitter; impl Unitter { diff --git a/tests/ui/use_self.fixed b/tests/ui/use_self.fixed index dcf818f80763..5cc3850689e0 100644 --- a/tests/ui/use_self.fixed +++ b/tests/ui/use_self.fixed @@ -5,6 +5,7 @@ #![warn(clippy::use_self)] #![allow(dead_code)] #![allow( + clippy::unnecessary_operation, clippy::should_implement_trait, clippy::upper_case_acronyms, clippy::from_over_into, diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index 9da6fef7a380..7a6b6778d5cc 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -5,6 +5,7 @@ #![warn(clippy::use_self)] #![allow(dead_code)] #![allow( + clippy::unnecessary_operation, clippy::should_implement_trait, clippy::upper_case_acronyms, clippy::from_over_into, diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index e14368a11aa7..c01db6b1b620 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -1,5 +1,5 @@ error: unnecessary structure name repetition - --> $DIR/use_self.rs:23:21 + --> $DIR/use_self.rs:24:21 | LL | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` @@ -7,163 +7,163 @@ LL | fn new() -> Foo { = note: `-D clippy::use-self` implied by `-D warnings` error: unnecessary structure name repetition - --> $DIR/use_self.rs:24:13 + --> $DIR/use_self.rs:25:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:26:22 + --> $DIR/use_self.rs:27:22 | LL | fn test() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:27:13 + --> $DIR/use_self.rs:28:13 | LL | Foo::new() | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:32:25 + --> $DIR/use_self.rs:33:25 | LL | fn default() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:33:13 + --> $DIR/use_self.rs:34:13 | LL | Foo::new() | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:98:24 + --> $DIR/use_self.rs:99:24 | LL | fn bad(foos: &[Foo]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:98:55 + --> $DIR/use_self.rs:99:55 | LL | fn bad(foos: &[Foo]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:113:13 + --> $DIR/use_self.rs:114:13 | LL | TS(0) | ^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:148:29 + --> $DIR/use_self.rs:149:29 | LL | fn bar() -> Bar { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:149:21 + --> $DIR/use_self.rs:150:21 | LL | Bar { foo: Foo {} } | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:160:21 + --> $DIR/use_self.rs:161:21 | LL | fn baz() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:161:13 + --> $DIR/use_self.rs:162:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:178:21 + --> $DIR/use_self.rs:179:21 | LL | let _ = Enum::B(42); | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:179:21 + --> $DIR/use_self.rs:180:21 | LL | let _ = Enum::C { field: true }; | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:180:21 + --> $DIR/use_self.rs:181:21 | LL | let _ = Enum::A; | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:222:13 + --> $DIR/use_self.rs:223:13 | LL | nested::A::fun_1(); | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:223:13 + --> $DIR/use_self.rs:224:13 | LL | nested::A::A; | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:225:13 + --> $DIR/use_self.rs:226:13 | LL | nested::A {}; | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:244:13 + --> $DIR/use_self.rs:245:13 | LL | TestStruct::from_something() | ^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:258:25 + --> $DIR/use_self.rs:259:25 | LL | async fn g() -> S { | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:259:13 + --> $DIR/use_self.rs:260:13 | LL | S {} | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:263:16 + --> $DIR/use_self.rs:264:16 | LL | &p[S::A..S::B] | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:263:22 + --> $DIR/use_self.rs:264:22 | LL | &p[S::A..S::B] | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:286:29 + --> $DIR/use_self.rs:287:29 | LL | fn foo(value: T) -> Foo { | ^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:287:13 + --> $DIR/use_self.rs:288:13 | LL | Foo:: { value } | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:459:13 + --> $DIR/use_self.rs:460:13 | LL | A::new::(submod::B {}) | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:496:13 + --> $DIR/use_self.rs:497:13 | LL | S2::new() | ^^ help: use the applicable keyword: `Self`