Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

futures: fix broken builds with tokio alpha support #338

Merged
merged 3 commits into from Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Expand Up @@ -82,6 +82,8 @@ jobs:
- uses: actions/checkout@master
- name: "Test tracing-futures std::future support"
run: (cd tracing-futures/test_std_future && cargo test)
- name: "Test tracing-futures tokio alpha support"
run: (cd tracing-futures && cargo check --no-default-features --features "tokio-alpha")
- name: "Test tracing-attributes async/await support"
run: (cd tracing/test_static_max_level_features && cargo test)
- name: "Test tracing-core no-std support"
Expand Down
6 changes: 3 additions & 3 deletions tracing-futures/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tracing-futures"
version = "0.0.1-alpha.1"
version = "0.0.1-alpha.2"
authors = ["Eliza Weisman <eliza@buoyant.io>", "Tokio Contributors <team@tokio.rs>"]
edition = "2018"
repository = "https://github.com/tokio-rs/tracing"
Expand All @@ -27,12 +27,12 @@ tokio-alpha = ["std-future", "tokio_02"]

[dependencies]
futures = { version = "0.1", optional = true }
futures-core-preview = { version = "0.3.0-alpha.17", optional = true }
futures-core-preview = { version = "0.3.0-alpha.18", optional = true }
pin-utils = { version = "0.1.0-alpha.4", optional = true }
tracing = "0.1"
tokio-executor = { version = "0.1", optional = true }
tokio = { version = "0.1", optional = true }
tokio_02 = { package = "tokio", version = "0.2.0-alpha.1", optional = true }
tokio_02 = { package = "tokio", version = "0.2.0-alpha.4", optional = true }

[dev-dependencies]
tokio = "0.1.22"
Expand Down
16 changes: 15 additions & 1 deletion tracing-futures/src/lib.rs
Expand Up @@ -47,7 +47,6 @@ use std::{pin::Pin, task::Context};

#[cfg(feature = "futures-01")]
use futures::{Sink, StartSend, Stream};
#[cfg(feature = "futures-01")]
use tracing::dispatcher;
use tracing::{Dispatch, Span};

Expand Down Expand Up @@ -193,6 +192,21 @@ impl<T: futures::Future> futures::Future for WithDispatch<T> {
}
}

#[cfg(feature = "std-future")]
impl<T: std::future::Future> WithDispatch<T> {
pin_utils::unsafe_pinned!(inner: T);
}

#[cfg(feature = "std-future")]
impl<T: std::future::Future> std::future::Future for WithDispatch<T> {
type Output = T::Output;

fn poll(mut self: Pin<&mut Self>, lw: &mut Context) -> std::task::Poll<Self::Output> {
let dispatch = self.as_ref().dispatch.clone();
dispatcher::with_default(&dispatch, || self.as_mut().inner().poll(lw))
}
}

impl<T> WithDispatch<T> {
#[cfg(any(
feature = "tokio",
Expand Down