Skip to content

Commit

Permalink
Revert shadowing change and remove no_effect allows
Browse files Browse the repository at this point in the history
  • Loading branch information
F3real committed Oct 18, 2021
1 parent ef24685 commit 5f164c3
Show file tree
Hide file tree
Showing 55 changed files with 145 additions and 449 deletions.
6 changes: 3 additions & 3 deletions clippy_lints/src/no_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ declare_clippy_lint! {
/// Checks for statements which have no effect.
///
/// ### Why is this bad?
/// Similar to dead code, these statements are actually
/// Unlike dead code, these statements are actually
/// executed. However, as they have no effect, all they do is make the code less
/// readable.
///
Expand All @@ -32,7 +32,7 @@ declare_clippy_lint! {
/// Checks for binding to underscore prefixed variable without side-effects.
///
/// ### Why is this bad?
/// Similar to dead code, these bindings are actually
/// Unlike dead code, these bindings are actually
/// executed. However, as they have no effect and shouldn't be used further on, all they
/// do is make the code less readable.
///
Expand Down Expand Up @@ -80,7 +80,7 @@ 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) && !is_lint_allowed(cx, NO_EFFECT, expr.hir_id) {
if has_no_effect(cx, expr) {
span_lint_hir(cx, NO_EFFECT, expr.hir_id, stmt.span, "statement with no effect");
return true;
}
Expand Down
28 changes: 1 addition & 27 deletions tests/ui-internal/if_chain_style.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ 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
|
Expand Down Expand Up @@ -89,23 +81,5 @@ LL | / let x = "";
LL | | let x = "";
| |_______________________^

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
error: aborting due to 7 previous errors

1 change: 0 additions & 1 deletion tests/ui/async_yields_async.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// edition:2018

#![feature(async_closure)]
#![allow(clippy::no_effect)]
#![warn(clippy::async_yields_async)]

use core::future::Future;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/async_yields_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// edition:2018

#![feature(async_closure)]
#![allow(clippy::no_effect)]
#![warn(clippy::async_yields_async)]

use core::future::Future;
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/async_yields_async.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:41:9
--> $DIR/async_yields_async.rs:40:9
|
LL | let _h = async {
| ____________________-
Expand All @@ -20,7 +20,7 @@ LL + }.await
|

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:46:9
--> $DIR/async_yields_async.rs:45:9
|
LL | let _i = async {
| ____________________-
Expand All @@ -33,7 +33,7 @@ LL | | };
| |_____- outer async construct

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:52:9
--> $DIR/async_yields_async.rs:51:9
|
LL | let _j = async || {
| _______________________-
Expand All @@ -53,7 +53,7 @@ LL + }.await
|

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:57:9
--> $DIR/async_yields_async.rs:56:9
|
LL | let _k = async || {
| _______________________-
Expand All @@ -66,7 +66,7 @@ LL | | };
| |_____- outer async construct

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:59:23
--> $DIR/async_yields_async.rs:58:23
|
LL | let _l = async || CustomFutureType;
| ^^^^^^^^^^^^^^^^
Expand All @@ -76,7 +76,7 @@ LL | let _l = async || CustomFutureType;
| help: consider awaiting this value: `CustomFutureType.await`

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:65:9
--> $DIR/async_yields_async.rs:64:9
|
LL | let _m = async || {
| _______________________-
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/author/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(redundant_semicolons, clippy::no_effect, clippy::unnecessary_operation)]
#![allow(redundant_semicolons, clippy::no_effect)]

#[rustfmt::skip]
fn main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/auxiliary/proc_macro_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![crate_type = "proc-macro"]
#![feature(repr128, proc_macro_quote)]
#![allow(incomplete_features)]
#![allow(clippy::field_reassign_with_default, clippy::no_effect)]
#![allow(clippy::field_reassign_with_default)]
#![allow(clippy::eq_op)]

extern crate proc_macro;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/crashes/ice-7340.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::no_effect, clippy::unnecessary_operation)]
#![allow(clippy::no_effect)]

fn main() {
const CONSTANT: usize = 8;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/empty_line_after_outer_attribute.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// aux-build:proc_macro_attr.rs
#![warn(clippy::empty_line_after_outer_attr)]
#![allow(clippy::assertions_on_constants, clippy::no_effect)]
#![allow(clippy::assertions_on_constants)]
#![feature(custom_inner_attributes)]
#![rustfmt::skip]

Expand Down
22 changes: 1 addition & 21 deletions tests/ui/erasing_op.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
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
|
Expand All @@ -14,29 +6,17 @@ 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 6 previous errors
error: aborting due to 3 previous errors

2 changes: 1 addition & 1 deletion tests/ui/eta.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<u8>> = true.then(std::vec::Vec::new); // special case vec!
Expand Down
10 changes: 1 addition & 9 deletions tests/ui/eta.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ 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
|
Expand Down Expand Up @@ -138,5 +130,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 22 previous errors
error: aborting due to 21 previous errors

1 change: 0 additions & 1 deletion tests/ui/for_loop_fixable.fixed
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-rustfix

#![allow(clippy::no_effect)]
#![allow(dead_code, unused)]

use std::collections::*;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/for_loop_fixable.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-rustfix

#![allow(clippy::no_effect)]
#![allow(dead_code, unused)]

use std::collections::*;
Expand Down
30 changes: 15 additions & 15 deletions tests/ui/for_loop_fixable.stderr
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:39:15
--> $DIR/for_loop_fixable.rs:38:15
|
LL | 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_fixable.rs:41:15
--> $DIR/for_loop_fixable.rs:40:15
|
LL | 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_fixable.rs:44:15
--> $DIR/for_loop_fixable.rs:43:15
|
LL | 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_fixable.rs:49:15
--> $DIR/for_loop_fixable.rs:48:15
|
LL | 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_fixable.rs:53:15
--> $DIR/for_loop_fixable.rs:52:15
|
LL | 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_fixable.rs:58:15
--> $DIR/for_loop_fixable.rs:57:15
|
LL | 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_fixable.rs:61:15
--> $DIR/for_loop_fixable.rs:60:15
|
LL | 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_fixable.rs:64:15
--> $DIR/for_loop_fixable.rs:63:15
|
LL | 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_fixable.rs:67:15
--> $DIR/for_loop_fixable.rs:66:15
|
LL | 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_fixable.rs:70:15
--> $DIR/for_loop_fixable.rs:69:15
|
LL | 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_fixable.rs:73:15
--> $DIR/for_loop_fixable.rs:72:15
|
LL | 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_fixable.rs:76:15
--> $DIR/for_loop_fixable.rs:75:15
|
LL | for _v in bs.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&bs`

error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:251:18
--> $DIR/for_loop_fixable.rs:250:18
|
LL | for i in iterator.into_iter() {
| ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `iterator`

error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:271:18
--> $DIR/for_loop_fixable.rs:270:18
|
LL | for _ in t.into_iter() {}
| ^^^^^^^^^^^^^ help: to write this more concisely, try: `&t`

error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:273:18
--> $DIR/for_loop_fixable.rs:272:18
|
LL | for _ in r.into_iter() {}
| ^^^^^^^^^^^^^ help: to write this more concisely, try: `r`
Expand Down
Loading

0 comments on commit 5f164c3

Please sign in to comment.