about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCatherine <114838443+Centri3@users.noreply.github.com>2023-06-29 02:26:45 -0500
committerCatherine <114838443+Centri3@users.noreply.github.com>2023-07-01 12:37:16 -0500
commitcb5d7e344a4f42eefb5b7d3df42f8899a684e73b (patch)
tree7a22ea2f58cafabdde1af082e60245c60876efe1
parentfbb3f759e2c6d90456f42a72eaaa741201d8e463 (diff)
downloadrust-cb5d7e344a4f42eefb5b7d3df42f8899a684e73b.tar.gz
rust-cb5d7e344a4f42eefb5b7d3df42f8899a684e73b.zip
address comments
-rw-r--r--book/src/lint_configuration.md1
-rw-r--r--clippy_lints/src/methods/manual_try_fold.rs2
-rw-r--r--clippy_lints/src/methods/mod.rs8
-rw-r--r--clippy_lints/src/utils/conf.rs2
-rw-r--r--tests/ui/manual_try_fold.stderr8
5 files changed, 11 insertions, 10 deletions
diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md
index ae0b5140316..60d7ce6e615 100644
--- a/book/src/lint_configuration.md
+++ b/book/src/lint_configuration.md
@@ -150,6 +150,7 @@ The minimum rust version that the project supports
 * [`manual_retain`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain)
 * [`type_repetition_in_bounds`](https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds)
 * [`tuple_array_conversions`](https://rust-lang.github.io/rust-clippy/master/index.html#tuple_array_conversions)
+* [`manual_try_fold`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold)
 
 
 ## `cognitive-complexity-threshold`
diff --git a/clippy_lints/src/methods/manual_try_fold.rs b/clippy_lints/src/methods/manual_try_fold.rs
index a1d83cf1419..576a58499b1 100644
--- a/clippy_lints/src/methods/manual_try_fold.rs
+++ b/clippy_lints/src/methods/manual_try_fold.rs
@@ -46,7 +46,7 @@ pub(super) fn check<'tcx>(
             cx,
             MANUAL_TRY_FOLD,
             fold_span,
-            "you seem to be using `Iterator::fold` on a type that implements `Try`",
+            "usage of `Iterator::fold` on a type that implements `Try`",
             "use `try_fold` instead",
             format!("try_fold({init_snip}, {args_snip} ...)", ),
             Applicability::HasPlaceholders,
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
index 2cd7ca02755..24dbe8c1d75 100644
--- a/clippy_lints/src/methods/mod.rs
+++ b/clippy_lints/src/methods/mod.rs
@@ -3292,10 +3292,10 @@ declare_clippy_lint! {
     /// Checks for usage of `Iterator::fold` with a type that implements `Try`.
     ///
     /// ### Why is this bad?
-    /// This should use `try_fold` instead, which short-circuits on failure, thus opening the door
-    /// for additional optimizations not possible with `fold` as rustc can guarantee the function is
-    /// never called on `None`, `Err`, etc., alleviating otherwise necessary checks. It's also
-    /// slightly more idiomatic.
+    /// The code should use `try_fold` instead, which short-circuits on failure, thus opening the
+    /// door for additional optimizations not possible with `fold` as rustc can guarantee the
+    /// function is never called on `None`, `Err`, etc., alleviating otherwise necessary checks. It's
+    /// also slightly more idiomatic.
     ///
     /// ### Known issues
     /// This lint doesn't take into account whether a function does something on the failure case,
diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs
index 89063964622..f1d05c7529b 100644
--- a/clippy_lints/src/utils/conf.rs
+++ b/clippy_lints/src/utils/conf.rs
@@ -294,7 +294,7 @@ define_Conf! {
     ///
     /// Suppress lints whenever the suggested change would cause breakage for other crates.
     (avoid_breaking_exported_api: bool = true),
-    /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS.
+    /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD.
     ///
     /// The minimum rust version that the project supports
     (msrv: Option<String> = None),
diff --git a/tests/ui/manual_try_fold.stderr b/tests/ui/manual_try_fold.stderr
index 2c0b0c67fd1..a0cf5b3b5fc 100644
--- a/tests/ui/manual_try_fold.stderr
+++ b/tests/ui/manual_try_fold.stderr
@@ -1,4 +1,4 @@
-error: you seem to be using `Iterator::fold` on a type that implements `Try`
+error: usage of `Iterator::fold` on a type that implements `Try`
   --> $DIR/manual_try_fold.rs:61:10
    |
 LL |         .fold(Some(0i32), |sum, i| sum?.checked_add(*i))
@@ -6,19 +6,19 @@ LL |         .fold(Some(0i32), |sum, i| sum?.checked_add(*i))
    |
    = note: `-D clippy::manual-try-fold` implied by `-D warnings`
 
-error: you seem to be using `Iterator::fold` on a type that implements `Try`
+error: usage of `Iterator::fold` on a type that implements `Try`
   --> $DIR/manual_try_fold.rs:65:10
    |
 LL |         .fold(NotOption(0i32, 0i32), |sum, i| NotOption(0i32, 0i32));
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(..., |sum, i| ...)`
 
-error: you seem to be using `Iterator::fold` on a type that implements `Try`
+error: usage of `Iterator::fold` on a type that implements `Try`
   --> $DIR/manual_try_fold.rs:68:10
    |
 LL |         .fold(NotOptionButWorse(0i32), |sum, i| NotOptionButWorse(0i32));
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)`
 
-error: you seem to be using `Iterator::fold` on a type that implements `Try`
+error: usage of `Iterator::fold` on a type that implements `Try`
   --> $DIR/manual_try_fold.rs:98:10
    |
 LL |         .fold(Some(0i32), |sum, i| sum?.checked_add(*i))