Skip to content

Commit fbb3f75

Browse files
committed
update docs
1 parent 04b0857 commit fbb3f75

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

clippy_lints/src/methods/mod.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -3292,10 +3292,15 @@ declare_clippy_lint! {
32923292
/// Checks for usage of `Iterator::fold` with a type that implements `Try`.
32933293
///
32943294
/// ### Why is this bad?
3295-
/// This is better represented with `try_fold`, but this has one major difference: It will
3296-
/// short-circuit on failure. *This is almost always what you want*. This can also open the door
3297-
/// for additional optimizations as well, as rustc can guarantee the function is never
3298-
/// called on `None`, `Err`, etc., alleviating otherwise necessary checks.
3295+
/// This should use `try_fold` instead, which short-circuits on failure, thus opening the door
3296+
/// for additional optimizations not possible with `fold` as rustc can guarantee the function is
3297+
/// never called on `None`, `Err`, etc., alleviating otherwise necessary checks. It's also
3298+
/// slightly more idiomatic.
3299+
///
3300+
/// ### Known issues
3301+
/// This lint doesn't take into account whether a function does something on the failure case,
3302+
/// i.e., whether short-circuiting will affect behavior. Refactoring to `try_fold` is not
3303+
/// desirable in those cases.
32993304
///
33003305
/// ### Example
33013306
/// ```rust

tests/ui/manual_try_fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@aux-build:proc_macros.rs
1+
//@aux-build:proc_macros.rs:proc-macro
22
#![allow(clippy::unnecessary_fold, unused)]
33
#![warn(clippy::manual_try_fold)]
44
#![feature(try_trait_v2)]

0 commit comments

Comments
 (0)