Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetkov committed Jul 12, 2022
1 parent c09b90e commit cf181e8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
11 changes: 5 additions & 6 deletions tokio/src/runtime/blocking/pool.rs
Expand Up @@ -91,14 +91,13 @@ pub(crate) enum SpawnError {
NoThreads(io::Error),
}

#[allow(clippy::from_over_into)] // Orphan rules
impl Into<io::Error> for SpawnError {
fn into(self) -> io::Error {
match self {
Self::ShuttingDown => {
impl From<SpawnError> for io::Error {
fn from(e: SpawnError) -> Self {
match e {
SpawnError::ShuttingDown => {
io::Error::new(io::ErrorKind::Other, "blocking pool shutting down")
}
Self::NoThreads(e) => e,
SpawnError::NoThreads(e) => e,
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions tokio/src/task/builder.rs
Expand Up @@ -48,7 +48,7 @@ use std::{future::Future, io};
/// .spawn(async move {
/// // Process each socket concurrently.
/// process(socket).await
/// });
/// })?;
/// }
/// }
/// ```
Expand Down Expand Up @@ -198,6 +198,7 @@ impl<'a> Builder<'a> {
handle,
);

spawn_result.map(|()| join_handle).map_err(Into::into)
spawn_result?;
Ok(join_handle)
}
}
15 changes: 8 additions & 7 deletions tokio/src/task/join_set.rs
Expand Up @@ -6,7 +6,6 @@
//! details.
use std::fmt;
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};

Expand Down Expand Up @@ -102,13 +101,15 @@ impl<T: 'static> JoinSet<T> {
/// use tokio::task::JoinSet;
///
/// #[tokio::main]
/// async fn main() {
/// async fn main() -> std::io::Result<()> {
/// let mut set = JoinSet::new();
///
/// // Use the builder to configure a task's name before spawning it.
/// set.build_task()
/// .name("my_task")
/// .spawn(async { /* ... */ });
/// .spawn(async { /* ... */ })?;
///
/// Ok(())
/// }
/// ```
#[cfg(all(tokio_unstable, feature = "tracing"))]
Expand Down Expand Up @@ -378,7 +379,7 @@ impl<'a, T: 'static> Builder<'a, T> {
///
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn<F>(self, future: F) -> io::Result<AbortHandle>
pub fn spawn<F>(self, future: F) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: Send + 'static,
Expand All @@ -398,7 +399,7 @@ impl<'a, T: 'static> Builder<'a, T> {
/// [`AbortHandle`]: crate::task::AbortHandle
/// [runtime handle]: crate::runtime::Handle
#[track_caller]
pub fn spawn_on<F>(mut self, future: F, handle: &Handle) -> io::Result<AbortHandle>
pub fn spawn_on<F>(mut self, future: F, handle: &Handle) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: Send + 'static,
Expand All @@ -421,7 +422,7 @@ impl<'a, T: 'static> Builder<'a, T> {
/// [`LocalSet`]: crate::task::LocalSet
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_local<F>(self, future: F) -> io::Result<AbortHandle>
pub fn spawn_local<F>(self, future: F) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: 'static,
Expand All @@ -439,7 +440,7 @@ impl<'a, T: 'static> Builder<'a, T> {
/// [`LocalSet`]: crate::task::LocalSet
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_local_on<F>(self, future: F, local_set: &LocalSet) -> io::Result<AbortHandle>
pub fn spawn_local_on<F>(self, future: F, local_set: &LocalSet) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: 'static,
Expand Down

0 comments on commit cf181e8

Please sign in to comment.