Skip to content

Commit 8c1f726

Browse files
committed
Revert: Make Option.flatten const
Option.flatten relies on Option.and_then, which has a generic trait bound and can't be const yet. From @oli-obk: > please undo all constifications for functions that take generic things > with trait bounds (other than Sized), these require > rust-lang/rfcs#2632 first
1 parent 5744fe1 commit 8c1f726

File tree

2 files changed

+0
-14
lines changed

2 files changed

+0
-14
lines changed

src/libcore/option.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1742,16 +1742,6 @@ impl<T> Option<Option<T>> {
17421742
/// ```
17431743
#[inline]
17441744
#[stable(feature = "option_flattening", since = "1.40.0")]
1745-
#[rustc_const_unstable(feature = "const_option_match")]
1746-
#[cfg(not(bootstrap))]
1747-
pub const fn flatten(self) -> Option<T> {
1748-
self.and_then(convert::identity)
1749-
}
1750-
1751-
/// No docs for bootstrap.
1752-
#[inline]
1753-
#[stable(feature = "option_flattening", since = "1.40.0")]
1754-
#[cfg(bootstrap)]
17551745
pub fn flatten(self) -> Option<T> {
17561746
self.and_then(convert::identity)
17571747
}

src/test/ui/consts/const-option.rs

-4
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,4 @@ assert_same_const! {
5151
const TRANSPOSE_A: Result<Option<i32>, bool> = Some(Ok(2)).transpose();
5252
const TRANSPOSE_B: Result<Option<i32>, bool> = Some(Err(false)).transpose();
5353
const TRANSPOSE_C: Result<Option<i32>, bool> = None.transpose();
54-
55-
const FLATTEN_A: Option<i32> = Some(Some(2)).flatten();
56-
const FLATTEN_B: Option<i32> = Some(None).flatten();
57-
const FLATTEN_C: Option<i32> = None.flatten();
5854
}

0 commit comments

Comments
 (0)