diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index f7430c209d1..42d6744e90a 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -60,6 +60,7 @@ net = [ "winapi/minwindef", ] process = [ + "fs", # TODO: remove this and expose the internals privately "bytes", "once_cell", "libc", diff --git a/tokio/src/blocking.rs b/tokio/src/blocking.rs index 7de815d66a0..f172399d5ef 100644 --- a/tokio/src/blocking.rs +++ b/tokio/src/blocking.rs @@ -1,7 +1,7 @@ cfg_rt! { pub(crate) use crate::runtime::spawn_blocking; - cfg_fs_internal! { + cfg_fs! { #[allow(unused_imports)] pub(crate) use crate::runtime::spawn_mandatory_blocking; } @@ -24,7 +24,7 @@ cfg_not_rt! { panic!("requires the `rt` Tokio feature flag") } - cfg_fs_internal! { + cfg_fs! { pub(crate) fn spawn_mandatory_blocking(_f: F) -> Option> where F: FnOnce() -> R + Send + 'static, diff --git a/tokio/src/io/blocking.rs b/tokio/src/io/blocking.rs index 11024821fa8..f6db4500af1 100644 --- a/tokio/src/io/blocking.rs +++ b/tokio/src/io/blocking.rs @@ -268,7 +268,7 @@ impl Buf { } } -cfg_fs_internal! { +cfg_fs! { impl Buf { pub(crate) fn discard_read(&mut self) -> i64 { let ret = -(self.bytes().len() as i64); diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index c7498b7b324..c0d7e6252e4 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -401,16 +401,8 @@ compile_error! { #[doc(hidden)] pub mod macros; -#[cfg(feature = "fs")] -#[cfg_attr(docsrs, doc(cfg(feature = "fs")))] -pub mod fs; - -cfg_fs_internal! { - #[cfg(not(feature = "fs"))] - #[allow(dead_code)] - #[allow(unreachable_pub)] - // TODO: this can be thinner without importing the entire fs module - pub(crate) mod fs; +cfg_fs! { + pub mod fs; } mod future; @@ -425,12 +417,7 @@ cfg_process! { pub mod process; } -#[cfg(any( - feature = "fs", - feature = "io-std", - feature = "net", - all(windows, feature = "process"), -))] +#[cfg(any(feature = "net", feature = "fs", feature = "io-std"))] mod blocking; cfg_rt! { diff --git a/tokio/src/macros/cfg.rs b/tokio/src/macros/cfg.rs index eb20cbb4a9c..52448a9ac19 100644 --- a/tokio/src/macros/cfg.rs +++ b/tokio/src/macros/cfg.rs @@ -57,13 +57,11 @@ macro_rules! cfg_aio { } } -macro_rules! cfg_fs_internal { +macro_rules! cfg_fs { ($($item:item)*) => { $( - #[cfg(any( - feature = "fs", - all(windows, feature = "process")), - )] + #[cfg(feature = "fs")] + #[cfg_attr(docsrs, doc(cfg(feature = "fs")))] $item )* } @@ -71,11 +69,7 @@ macro_rules! cfg_fs_internal { macro_rules! cfg_io_blocking { ($($item:item)*) => { - $( #[cfg(any( - feature = "fs", - feature = "io-std", - all(windows, feature = "process"), - ))] $item )* + $( #[cfg(any(feature = "io-std", feature = "fs"))] $item )* } } diff --git a/tokio/src/runtime/blocking/mod.rs b/tokio/src/runtime/blocking/mod.rs index 297d7128d19..88d5e6b6a99 100644 --- a/tokio/src/runtime/blocking/mod.rs +++ b/tokio/src/runtime/blocking/mod.rs @@ -6,7 +6,7 @@ mod pool; pub(crate) use pool::{spawn_blocking, BlockingPool, Mandatory, Spawner, Task}; -cfg_fs_internal! { +cfg_fs! { pub(crate) use pool::spawn_mandatory_blocking; } diff --git a/tokio/src/runtime/blocking/pool.rs b/tokio/src/runtime/blocking/pool.rs index eac401b367c..f73868ee9e7 100644 --- a/tokio/src/runtime/blocking/pool.rs +++ b/tokio/src/runtime/blocking/pool.rs @@ -114,7 +114,7 @@ where rt.spawn_blocking(func) } -cfg_fs_internal! { +cfg_fs! { #[cfg_attr(any( all(loom, not(test)), // the function is covered by loom tests test diff --git a/tokio/src/runtime/handle.rs b/tokio/src/runtime/handle.rs index 00d64092e77..cfe1c96419f 100644 --- a/tokio/src/runtime/handle.rs +++ b/tokio/src/runtime/handle.rs @@ -356,7 +356,7 @@ impl HandleInner { join_handle } - cfg_fs_internal! { + cfg_fs! { #[track_caller] #[cfg_attr(any( all(loom, not(test)), // the function is covered by loom tests diff --git a/tokio/src/runtime/mod.rs b/tokio/src/runtime/mod.rs index 35f51886ac8..b9e7e2de958 100644 --- a/tokio/src/runtime/mod.rs +++ b/tokio/src/runtime/mod.rs @@ -198,14 +198,6 @@ cfg_not_metrics! { pub(crate) use metrics::{SchedulerMetrics, WorkerMetrics, MetricsBatch}; } -cfg_not_rt! { - cfg_fs_internal! { - mod blocking; - use blocking::BlockingPool; - pub(crate) use blocking::spawn_blocking; - } -} - cfg_rt! { mod basic_scheduler; use basic_scheduler::BasicScheduler; @@ -218,7 +210,7 @@ cfg_rt! { pub(crate) use blocking::Mandatory; } - cfg_fs_internal! { + cfg_fs! { pub(crate) use blocking::spawn_mandatory_blocking; } diff --git a/tokio/src/sync/mod.rs b/tokio/src/sync/mod.rs index 2a9641b7005..457e6ab2946 100644 --- a/tokio/src/sync/mod.rs +++ b/tokio/src/sync/mod.rs @@ -473,7 +473,7 @@ cfg_sync! { } cfg_not_sync! { - cfg_fs_internal! { + cfg_fs! { pub(crate) mod batch_semaphore; mod mutex; pub(crate) use mutex::Mutex; diff --git a/tokio/src/util/linked_list.rs b/tokio/src/util/linked_list.rs index b841aa3a957..e6bdde68c7a 100644 --- a/tokio/src/util/linked_list.rs +++ b/tokio/src/util/linked_list.rs @@ -227,7 +227,7 @@ impl fmt::Debug for LinkedList { #[cfg(any( feature = "fs", feature = "rt", - feature = "process", + all(unix, feature = "process"), feature = "signal", feature = "sync", ))]