Skip to content

Commit 7e6ad28

Browse files
committed
Add missing const stability attributes for bool methods
This fixes compilation errors in bootstrap tests by adding: - rustc_const_stable attribute for then_some method - rustc_const_unstable attribute for then method - [const] Destruct bound for const trait compatibility - Required Destruct import Resolves E0493 destructor evaluation errors and missing const stability attribute errors during bootstrap.
1 parent dba9cdf commit 7e6ad28

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

library/core/src/bool.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! impl bool {}
22
3+
use crate::marker::Destruct;
4+
35
impl bool {
46
/// Returns `Some(t)` if the `bool` is [`true`](../std/keyword.true.html),
57
/// or `None` otherwise.
@@ -29,6 +31,7 @@ impl bool {
2931
/// assert_eq!(a, 2);
3032
/// ```
3133
#[stable(feature = "bool_to_option", since = "1.62.0")]
34+
#[rustc_const_stable(feature = "bool_to_option", since = "1.62.0")]
3235
#[inline]
3336
pub const fn then_some<T>(self, t: T) -> Option<T> {
3437
if self { Some(t) } else { None }
@@ -56,11 +59,12 @@ impl bool {
5659
/// ```
5760
#[doc(alias = "then_with")]
5861
#[stable(feature = "lazy_bool_to_option", since = "1.50.0")]
62+
#[rustc_const_unstable(feature = "const_option_ops", issue = "143956")]
5963
#[rustc_diagnostic_item = "bool_then"]
6064
#[inline]
6165
pub const fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T>
6266
where
63-
F: [const] FnOnce() -> T,
67+
F: [const] FnOnce() -> T + [const] Destruct,
6468
{
6569
if self { Some(f()) } else { None }
6670
}

0 commit comments

Comments
 (0)