Skip to content

Commit 22e4575

Browse files
authored
Rollup merge of rust-lang#145915 - coolreader18:stabilize-fmt_from_fn, r=dtolnay
Stabilize `fmt::from_fn` Resolves rust-lang#146705, pending its FCP. As discussed in that tracking issue and rust-lang#117729, this splits `fmt::from_fn` out from the `debug_closure_helpers` feature.
2 parents ea4e037 + 93c8bf1 commit 22e4575

File tree

7 files changed

+14
-17
lines changed

7 files changed

+14
-17
lines changed

compiler/rustc_hir/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
44
55
// tidy-alphabetical-start
6+
#![cfg_attr(bootstrap, feature(debug_closure_helpers))]
67
#![feature(associated_type_defaults)]
78
#![feature(closure_track_caller)]
8-
#![feature(debug_closure_helpers)]
99
#![feature(exhaustive_patterns)]
1010
#![feature(never_type)]
1111
#![feature(variant_count)]

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ This API is completely unstable and subject to change.
5959
#![allow(internal_features)]
6060
#![allow(rustc::diagnostic_outside_of_impl)]
6161
#![allow(rustc::untranslatable_diagnostic)]
62+
#![cfg_attr(bootstrap, feature(debug_closure_helpers))]
6263
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
6364
#![doc(rust_logo)]
6465
#![feature(assert_matches)]
65-
#![feature(debug_closure_helpers)]
6666
#![feature(gen_blocks)]
6767
#![feature(if_let_guard)]
6868
#![feature(iter_intersperse)]

compiler/rustc_target/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
1010
// tidy-alphabetical-start
1111
#![allow(internal_features)]
12+
#![cfg_attr(bootstrap, feature(debug_closure_helpers))]
1213
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1314
#![doc(rust_logo)]
14-
#![feature(debug_closure_helpers)]
1515
#![feature(iter_intersperse)]
1616
#![feature(rustdoc_internals)]
1717
// tidy-alphabetical-end

library/alloc/src/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ pub use core::fmt::{DebugAsHex, FormattingOptions, Sign};
602602
pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};
603603
#[stable(feature = "rust1", since = "1.0.0")]
604604
pub use core::fmt::{Formatter, Result, Write};
605-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
605+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
606606
pub use core::fmt::{FromFn, from_fn};
607607
#[stable(feature = "rust1", since = "1.0.0")]
608608
pub use core::fmt::{LowerExp, UpperExp};

library/core/src/fmt/builders.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,13 +1210,12 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
12101210
}
12111211
}
12121212

1213-
/// Creates a type whose [`fmt::Debug`] and [`fmt::Display`] impls are provided with the function
1214-
/// `f`.
1213+
/// Creates a type whose [`fmt::Debug`] and [`fmt::Display`] impls are
1214+
/// forwarded to the provided closure.
12151215
///
12161216
/// # Examples
12171217
///
12181218
/// ```
1219-
/// #![feature(debug_closure_helpers)]
12201219
/// use std::fmt;
12211220
///
12221221
/// let value = 'a';
@@ -1227,21 +1226,19 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
12271226
/// assert_eq!(format!("{}", wrapped), "'a'");
12281227
/// assert_eq!(format!("{:?}", wrapped), "'a'");
12291228
/// ```
1230-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
1229+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
12311230
#[must_use = "returns a type implementing Debug and Display, which do not have any effects unless they are used"]
12321231
pub fn from_fn<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result>(f: F) -> FromFn<F> {
12331232
FromFn(f)
12341233
}
12351234

1236-
/// Implements [`fmt::Debug`] and [`fmt::Display`] using a function.
1235+
/// Implements [`fmt::Debug`] and [`fmt::Display`] via the provided closure.
12371236
///
12381237
/// Created with [`from_fn`].
1239-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
1240-
pub struct FromFn<F>(F)
1241-
where
1242-
F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result;
1238+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
1239+
pub struct FromFn<F>(F);
12431240

1244-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
1241+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
12451242
impl<F> fmt::Debug for FromFn<F>
12461243
where
12471244
F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result,
@@ -1251,7 +1248,7 @@ where
12511248
}
12521249
}
12531250

1254-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
1251+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
12551252
impl<F> fmt::Display for FromFn<F>
12561253
where
12571254
F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result,

library/core/src/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub use num_buffer::{NumBuffer, NumBufferTrait};
3939

4040
#[stable(feature = "debug_builders", since = "1.2.0")]
4141
pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};
42-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
42+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
4343
pub use self::builders::{FromFn, from_fn};
4444

4545
/// The type returned by formatter methods.

src/librustdoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// tidy-alphabetical-start
2+
#![cfg_attr(bootstrap, feature(debug_closure_helpers))]
23
#![doc(
34
html_root_url = "https://doc.rust-lang.org/nightly/",
45
html_playground_url = "https://play.rust-lang.org/"
@@ -8,7 +9,6 @@
89
#![feature(assert_matches)]
910
#![feature(box_into_inner)]
1011
#![feature(box_patterns)]
11-
#![feature(debug_closure_helpers)]
1212
#![feature(file_buffered)]
1313
#![feature(formatting_options)]
1414
#![feature(if_let_guard)]

0 commit comments

Comments
 (0)