Skip to content
/ rust Public
forked from rust-lang/rust
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0b3ac0f

Browse files
authoredFeb 4, 2025
Rollup merge of rust-lang#136502 - yotamofek:pr/fmt-from-fn-must-use, r=dtolnay
Mark `std::fmt::from_fn` as `#[must_use]` While working on rust-lang#135494 I managed to shoot my own foot a few times by forgetting to actually use the result of `fmt::from_fn`, so I think a `#[must_use]` could be appropriate! Didn't have a good message to put in the attr so left it blank, still unstable so we can come back to it I guess? cc rust-lang#117729 (and a huge +1 for getting it stabilized, it's very useful IMHO)
2 parents f5a9dd5 + 6b016d7 commit 0b3ac0f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed
 

‎library/core/src/fmt/builders.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
12281228
/// assert_eq!(format!("{:?}", wrapped), "'a'");
12291229
/// ```
12301230
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
1231+
#[must_use = "returns a type implementing Debug and Display, which do not have any effects unless they are used"]
12311232
pub fn from_fn<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result>(f: F) -> FromFn<F> {
12321233
FromFn(f)
12331234
}

0 commit comments

Comments
 (0)
Failed to load comments.