Skip to content

Commit

Permalink
Unrolled build for rust-lang#136502
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
rust-timer authored Feb 5, 2025
2 parents 8df89d1 + 6b016d7 commit eafa13d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions library/core/src/fmt/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
/// assert_eq!(format!("{:?}", wrapped), "'a'");
/// ```
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
#[must_use = "returns a type implementing Debug and Display, which do not have any effects unless they are used"]
pub fn from_fn<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result>(f: F) -> FromFn<F> {
FromFn(f)
}
Expand Down

0 comments on commit eafa13d

Please sign in to comment.