diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index 09994e47f0a69..8b4e3697c9d9e 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -152,7 +152,10 @@ impl fmt::Debug for LocalKey { /// ``` /// use std::cell::Cell; /// thread_local! { -/// pub static FOO: Cell = const { Cell::new(1) }; +/// pub static FOO: Cell = const { +/// let value = 1; +/// Cell::new(value) +/// }; /// } /// /// FOO.with(|foo| assert_eq!(foo.get(), 1)); @@ -170,12 +173,12 @@ macro_rules! thread_local { // empty (base case for the recursion) () => {}; - ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = const { $init:expr }; $($rest:tt)*) => ( + ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = const $init:block; $($rest:tt)*) => ( $crate::thread::local_impl::thread_local_inner!($(#[$attr])* $vis $name, $t, const $init); $crate::thread_local!($($rest)*); ); - ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = const { $init:expr }) => ( + ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = const $init:block) => ( $crate::thread::local_impl::thread_local_inner!($(#[$attr])* $vis $name, $t, const $init); );