From e788410007831b266a6dcae677223ba70172b9f6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 14 Oct 2024 17:15:53 -0400 Subject: [PATCH] Mark LazyCell::into_inner unstably const Other cell `into_inner` functions are const and there shouldn't be any problem here. Make the unstable `LazyCell::into_inner` const under the same gate as its stability (`lazy_cell_into_inner`). Tracking issue: https://github.com/rust-lang/rust/issues/125623 --- core/src/cell/lazy.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/cell/lazy.rs b/core/src/cell/lazy.rs index 5bc13779af9f8..d323fbeac9c10 100644 --- a/core/src/cell/lazy.rs +++ b/core/src/cell/lazy.rs @@ -79,7 +79,7 @@ impl T> LazyCell { /// assert_eq!(LazyCell::into_inner(lazy).ok(), Some("HELLO, WORLD!".to_string())); /// ``` #[unstable(feature = "lazy_cell_into_inner", issue = "125623")] - pub fn into_inner(this: Self) -> Result { + pub const fn into_inner(this: Self) -> Result { match this.state.into_inner() { State::Init(data) => Ok(data), State::Uninit(f) => Err(f), @@ -306,6 +306,6 @@ impl fmt::Debug for LazyCell { #[cold] #[inline(never)] -fn panic_poisoned() -> ! { +const fn panic_poisoned() -> ! { panic!("LazyCell instance has previously been poisoned") }