Skip to content

Commit

Permalink
futures: fix broken builds with tokio alpha support (#338)
Browse files Browse the repository at this point in the history
## Motivation

This branch fixes broken builds of `tracing-futures` with the
`tokio-alpha` feature.

## Solution

I've added the missing `WithDispatch` impl for 
`std::future::Future` that was breaking the build. I've also
updated the `tokio` alpha dependency, and added a CI check
that the tokio-alpha feature flag compiles.

Fixes #337 

* futures: add missing `WithDispatch` impl
* futures: update tokio alphas
* chore: add CI job to ensure tokio alpha compiles

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw committed Sep 12, 2019
1 parent 2d0072a commit 5c0fe77
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
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

0 comments on commit 5c0fe77

Please sign in to comment.