Skip to content

Commit 80447ad

Browse files
committed
update docs
1 parent 5c18d7d commit 80447ad

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

clippy_lints/src/methods/mod.rs

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

tests/ui/manual_try_fold.rs

Lines changed: 1 addition & 1 deletion
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)