Skip to content

Commit

Permalink
Revert "Expose fs internally when process is enabled on windows"
Browse files Browse the repository at this point in the history
This reverts commit c02fde8.
  • Loading branch information
ipetkov committed Jul 20, 2022
1 parent 5b4cb69 commit 9ae9c4c
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 43 deletions.
1 change: 1 addition & 0 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ net = [
"winapi/minwindef",
]
process = [
"fs", # TODO: remove this and expose the internals privately
"bytes",
"once_cell",
"libc",
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/blocking.rs
Original file line number Diff line number Diff line change
@@ -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;
}
Expand All @@ -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, R>(_f: F) -> Option<JoinHandle<R>>
where
F: FnOnce() -> R + Send + 'static,
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 3 additions & 16 deletions tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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! {
Expand Down
14 changes: 4 additions & 10 deletions tokio/src/macros/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,19 @@ 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
)*
}
}

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 )*
}
}

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/blocking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/blocking/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 1 addition & 9 deletions tokio/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -218,7 +210,7 @@ cfg_rt! {
pub(crate) use blocking::Mandatory;
}

cfg_fs_internal! {
cfg_fs! {
pub(crate) use blocking::spawn_mandatory_blocking;
}

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/util/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl<L: Link> fmt::Debug for LinkedList<L, L::Target> {
#[cfg(any(
feature = "fs",
feature = "rt",
feature = "process",
all(unix, feature = "process"),
feature = "signal",
feature = "sync",
))]
Expand Down

0 comments on commit 9ae9c4c

Please sign in to comment.