diff --git a/tests-integration/tests/macros_main.rs b/tests-integration/tests/macros_main.rs index 37fda810d3d..c7a0be0a978 100644 --- a/tests-integration/tests/macros_main.rs +++ b/tests-integration/tests/macros_main.rs @@ -16,7 +16,6 @@ async fn spawning() -> usize { join.await.unwrap() } -#[cfg(tokio_unstable)] #[tokio::main(flavor = "local")] async fn local_main() -> usize { let join = tokio::task::spawn_local(async { 1 }); @@ -33,6 +32,5 @@ fn shell() { assert_eq!(1, basic_main()); assert_eq!(bool::default(), generic_fun::()); - #[cfg(tokio_unstable)] assert_eq!(1, local_main()); } diff --git a/tokio-macros/src/entry.rs b/tokio-macros/src/entry.rs index abd9b9e9834..1f85acbb06b 100644 --- a/tokio-macros/src/entry.rs +++ b/tokio-macros/src/entry.rs @@ -421,12 +421,7 @@ fn parse_knobs(mut input: ItemFn, is_test: bool, config: FinalConfig) -> TokenSt }, }; - let mut checks = vec![]; - let mut errors = vec![]; - let build = if let RuntimeFlavor::Local = config.flavor { - checks.push(quote! { tokio_unstable }); - errors.push("The local runtime flavor is only available when `tokio_unstable` is set."); quote_spanned! {last_stmt_start_span=> build_local(Default::default())} } else { quote_spanned! {last_stmt_start_span=> build()} @@ -451,23 +446,10 @@ fn parse_knobs(mut input: ItemFn, is_test: bool, config: FinalConfig) -> TokenSt quote! {} }; - let do_checks: TokenStream = checks - .iter() - .zip(&errors) - .map(|(check, error)| { - quote! { - #[cfg(not(#check))] - compile_error!(#error); - } - }) - .collect(); - let body_ident = quote! { body }; // This explicit `return` is intentional. See tokio-rs/tokio#4636 let last_block = quote_spanned! {last_stmt_end_span=> - #do_checks - #[cfg(all(#(#checks),*))] #[allow(clippy::expect_used, clippy::diverging_sub_expression, clippy::needless_return)] { return #rt @@ -477,10 +459,6 @@ fn parse_knobs(mut input: ItemFn, is_test: bool, config: FinalConfig) -> TokenSt .block_on(#body_ident); } - #[cfg(not(all(#(#checks),*)))] - { - panic!("fell through checks") - } }; let body = input.body(); diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs index 207727fe15a..1efe88c4272 100644 --- a/tokio-macros/src/lib.rs +++ b/tokio-macros/src/lib.rs @@ -78,16 +78,11 @@ use proc_macro::TokenStream; /// /// ## Local /// -/// [Unstable API][unstable] only. -/// /// To use the [local runtime], the macro can be configured using /// /// ```rust -/// # #[cfg(tokio_unstable)] /// #[tokio::main(flavor = "local")] /// # async fn main() {} -/// # #[cfg(not(tokio_unstable))] -/// # fn main() {} /// ``` /// /// # Function arguments @@ -146,25 +141,19 @@ use proc_macro::TokenStream; /// /// ## Using the local runtime /// -/// Available in the [unstable API][unstable] only. -/// /// The [local runtime] is similar to the current-thread runtime but /// supports [`task::spawn_local`](../tokio/task/fn.spawn_local.html). /// /// ```rust -/// # #[cfg(tokio_unstable)] /// #[tokio::main(flavor = "local")] /// async fn main() { /// println!("Hello world"); /// } -/// # #[cfg(not(tokio_unstable))] -/// # fn main() {} /// ``` /// /// Equivalent code not using `#[tokio::main]` /// /// ```rust -/// # #[cfg(tokio_unstable)] /// fn main() { /// tokio::runtime::Builder::new_current_thread() /// .enable_all() @@ -174,8 +163,6 @@ use proc_macro::TokenStream; /// println!("Hello world"); /// }) /// } -/// # #[cfg(not(tokio_unstable))] -/// # fn main() {} /// ``` /// /// diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index 76800296a27..c9987bb9900 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -1,9 +1,11 @@ #![cfg_attr(loom, allow(unused_imports))] use crate::runtime::handle::Handle; -use crate::runtime::{blocking, driver, Callback, HistogramBuilder, Runtime, TaskCallback}; +use crate::runtime::{ + blocking, driver, Callback, HistogramBuilder, LocalOptions, LocalRuntime, Runtime, TaskCallback, +}; #[cfg(tokio_unstable)] -use crate::runtime::{metrics::HistogramConfiguration, LocalOptions, LocalRuntime, TaskMeta}; +use crate::runtime::{metrics::HistogramConfiguration, TaskMeta}; use crate::util::rand::{RngSeed, RngSeedGenerator}; use crate::runtime::blocking::BlockingPool; @@ -923,7 +925,6 @@ impl Builder { /// }); /// ``` #[allow(unused_variables, unreachable_patterns)] - #[cfg(tokio_unstable)] #[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] pub fn build_local(&mut self, options: LocalOptions) -> io::Result { match &self.kind { @@ -1438,7 +1439,6 @@ impl Builder { )) } - #[cfg(tokio_unstable)] fn build_current_thread_local_runtime(&mut self) -> io::Result { use crate::runtime::local_runtime::LocalRuntimeScheduler; diff --git a/tokio/src/runtime/handle.rs b/tokio/src/runtime/handle.rs index 8f9d95090b9..80fd217a782 100644 --- a/tokio/src/runtime/handle.rs +++ b/tokio/src/runtime/handle.rs @@ -361,14 +361,13 @@ impl Handle { { let id = crate::runtime::task::Id::next(); #[cfg(all( - tokio_unstable, tokio_taskdump, feature = "rt", target_os = "linux", any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64") ))] let future = super::task::trace::Trace::root(future); - #[cfg(all(tokio_unstable, feature = "tracing"))] + #[cfg(feature = "tracing")] let future = crate::util::trace::task(future, "task", meta, id.as_u64()); self.inner.spawn_local(future, id, meta.spawned_at) } diff --git a/tokio/src/runtime/local_runtime/runtime.rs b/tokio/src/runtime/local_runtime/runtime.rs index 2e9d14e13b4..6166fa41dd9 100644 --- a/tokio/src/runtime/local_runtime/runtime.rs +++ b/tokio/src/runtime/local_runtime/runtime.rs @@ -29,7 +29,6 @@ use std::time::Duration; /// [runtime]: crate::runtime::Runtime /// [module]: crate::runtime #[derive(Debug)] -#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))] pub struct LocalRuntime { /// Task scheduler scheduler: LocalRuntimeScheduler, @@ -231,7 +230,6 @@ impl LocalRuntime { #[track_caller] fn block_on_inner(&self, future: F, _meta: SpawnMeta<'_>) -> F::Output { #[cfg(all( - tokio_unstable, tokio_taskdump, feature = "rt", target_os = "linux", @@ -239,7 +237,7 @@ impl LocalRuntime { ))] let future = crate::runtime::task::trace::Trace::root(future); - #[cfg(all(tokio_unstable, feature = "tracing"))] + #[cfg(feature = "tracing")] let future = crate::util::trace::task( future, "block_on", @@ -320,6 +318,7 @@ impl LocalRuntime { /// use std::time::Duration; /// /// fn main() { + /// # if cfg!(miri) { return } // Miri reports error when main thread terminated without waiting all remaining threads. /// let runtime = LocalRuntime::new().unwrap(); /// /// runtime.block_on(async move { diff --git a/tokio/src/runtime/mod.rs b/tokio/src/runtime/mod.rs index 031fde5d0b0..6250c444046 100644 --- a/tokio/src/runtime/mod.rs +++ b/tokio/src/runtime/mod.rs @@ -371,8 +371,6 @@ cfg_rt! { pub use self::builder::UnhandledPanic; pub use crate::util::rand::RngSeed; - mod local_runtime; - pub use local_runtime::{LocalRuntime, LocalOptions}; } cfg_taskdump! { @@ -394,6 +392,9 @@ cfg_rt! { mod runtime; pub use runtime::{Runtime, RuntimeFlavor}; + mod local_runtime; + pub use local_runtime::{LocalRuntime, LocalOptions}; + /// Boundary value to prevent stack overflow caused by a large-sized /// Future being placed in the stack. pub(crate) const BOX_FUTURE_THRESHOLD: usize = if cfg!(debug_assertions) { diff --git a/tokio/src/task/local.rs b/tokio/src/task/local.rs index 22b1b9bb522..d31403f902b 100644 --- a/tokio/src/task/local.rs +++ b/tokio/src/task/local.rs @@ -327,7 +327,7 @@ cfg_rt! { /// Spawns a `!Send` future on the current [`LocalSet`] or [`LocalRuntime`]. /// /// This is possible when either using one of these types - /// explicitly, or (with `tokio_unstable`) by opting to use the + /// explicitly by opting to use the /// `"local"` runtime flavor in `tokio::main`: /// /// ```ignore @@ -407,7 +407,6 @@ cfg_rt! { let future = future.take().unwrap(); #[cfg(all( - tokio_unstable, tokio_taskdump, feature = "rt", target_os = "linux", diff --git a/tokio/tests/async_send_sync.rs b/tokio/tests/async_send_sync.rs index 19cc6aed711..0074d80179c 100644 --- a/tokio/tests/async_send_sync.rs +++ b/tokio/tests/async_send_sync.rs @@ -559,6 +559,9 @@ assert_value!(tokio::runtime::EnterGuard<'_>: !Send & Sync & Unpin); assert_value!(tokio::runtime::Handle: Send & Sync & Unpin); assert_value!(tokio::runtime::Runtime: Send & Sync & Unpin); +assert_value!(tokio::runtime::LocalRuntime: !Send & !Sync & Unpin); +assert_value!(tokio::runtime::LocalOptions: !Send & !Sync & Unpin); + assert_value!(tokio::time::Interval: Send & Sync & Unpin); assert_value!(tokio::time::Instant: Send & Sync & Unpin); assert_value!(tokio::time::Sleep: Send & Sync & !Unpin); @@ -768,11 +771,3 @@ mod unix_asyncfd { async_assert_fn!(AsyncFd>::writable(_): !Send & !Sync & !Unpin); async_assert_fn!(AsyncFd>::writable_mut(_): !Send & !Sync & !Unpin); } - -#[cfg(tokio_unstable)] -mod unstable { - use super::*; - - assert_value!(tokio::runtime::LocalRuntime: !Send & !Sync & Unpin); - assert_value!(tokio::runtime::LocalOptions: !Send & !Sync & Unpin); -} diff --git a/tokio/tests/rt_local.rs b/tokio/tests/rt_local.rs index 4eb88d48a4d..5fb0e62677d 100644 --- a/tokio/tests/rt_local.rs +++ b/tokio/tests/rt_local.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", tokio_unstable))] +#![cfg(feature = "full")] use tokio::runtime::LocalOptions; use tokio::task::spawn_local;