rt: remove a conditional compilation clause (#5104)

The `LocalSet` implementation includes a conditional compilation clause
that removes the `const` statement from the `thread_local` definition.
However, there already is an internal macro that does this:
`tokio_thread_local`.

This patch removes the conditional compilation in favor of using the
`tokio_thread_local` macro. This also fixes a conditional compilation
issue with an internal utility (`RcCell`).
This commit is contained in:
Carl Lerche 2022-10-13 16:45:15 -07:00 committed by GitHub
parent 964535eab0
commit f8097437dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 9 deletions

View File

@ -272,13 +272,6 @@ pin_project! {
}
}
#[cfg(any(loom, tokio_no_const_thread_local))]
tokio_thread_local!(static CURRENT: LocalData = LocalData {
thread_id: Cell::new(None),
ctx: RcCell::new(),
});
#[cfg(not(any(loom, tokio_no_const_thread_local)))]
tokio_thread_local!(static CURRENT: LocalData = const { LocalData {
thread_id: Cell::new(None),
ctx: RcCell::new(),

View File

@ -9,7 +9,7 @@ pub(crate) struct RcCell<T> {
}
impl<T> RcCell<T> {
#[cfg(not(loom))]
#[cfg(not(all(loom, test)))]
pub(crate) const fn new() -> Self {
Self {
inner: UnsafeCell::new(None),
@ -17,7 +17,7 @@ impl<T> RcCell<T> {
}
// The UnsafeCell in loom does not have a const `new` fn.
#[cfg(loom)]
#[cfg(all(loom, test))]
pub(crate) fn new() -> Self {
Self {
inner: UnsafeCell::new(None),