-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #4382 - jeremystucki:unnecessary_fold_span, r=flip1995
Change span of unnecessary_fold lint Resolves #4381 changelog: Change linted span of `unnecessary_fold`
- Loading branch information
Showing
4 changed files
with
44 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,40 @@ | ||
error: this `.fold` can be written more succinctly using another method | ||
--> $DIR/unnecessary_fold.rs:8:19 | ||
--> $DIR/unnecessary_fold.rs:8:20 | ||
| | ||
LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| 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:10:19 | ||
--> $DIR/unnecessary_fold.rs:10:20 | ||
| | ||
LL | let _ = (0..3).fold(true, |acc, x| acc && x > 2); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.all(|x| x > 2)` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `all(|x| x > 2)` | ||
|
||
error: this `.fold` can be written more succinctly using another method | ||
--> $DIR/unnecessary_fold.rs:12:24 | ||
--> $DIR/unnecessary_fold.rs:12:25 | ||
| | ||
LL | let _: i32 = (0..3).fold(0, |acc, x| acc + x); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.sum()` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` | ||
|
||
error: this `.fold` can be written more succinctly using another method | ||
--> $DIR/unnecessary_fold.rs:14:24 | ||
--> $DIR/unnecessary_fold.rs:14:25 | ||
| | ||
LL | let _: i32 = (0..3).fold(1, |acc, x| acc * x); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.product()` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` | ||
|
||
error: this `.fold` can be written more succinctly using another method | ||
--> $DIR/unnecessary_fold.rs:19:40 | ||
--> $DIR/unnecessary_fold.rs:19:41 | ||
| | ||
LL | let _: bool = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` | ||
|
||
error: aborting due to 5 previous errors | ||
error: this `.fold` can be written more succinctly using another method | ||
--> $DIR/unnecessary_fold.rs:49:10 | ||
| | ||
LL | .fold(false, |acc, x| acc || x > 2); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` | ||
|
||
error: aborting due to 6 previous errors | ||
|