diff --git a/tracing-futures/Cargo.toml b/tracing-futures/Cargo.toml index 83b8a8c0..c5275d6b 100644 --- a/tracing-futures/Cargo.toml +++ b/tracing-futures/Cargo.toml @@ -21,14 +21,14 @@ license = "MIT" default = ["std-future", "std"] futures-01 = ["futures_01", "std"] futures-03 = ["std-future", "futures", "futures-task", "std"] -std-future = ["pin-project"] +std-future = ["pin-project-lite"] std = ["tracing/std"] [dependencies] futures_01 = { package = "futures", version = "0.1", optional = true } futures = { version = "0.3.0", optional = true } futures-task = { version = "0.3", optional = true } -pin-project = { version = "1.0", optional = true } +pin-project-lite = { version = "0.2.4", optional = true } tracing = { path = "../tracing", version = "0.1", default-features = false } tokio-executor = { version = "0.1", optional = true } tokio = { version = "0.1", optional = true } diff --git a/tracing-futures/src/lib.rs b/tracing-futures/src/lib.rs index a7b75f6c..7ac986aa 100644 --- a/tracing-futures/src/lib.rs +++ b/tracing-futures/src/lib.rs @@ -103,7 +103,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))] #[cfg(feature = "std-future")] -use pin_project::pin_project; +use pin_project_lite::pin_project; pub(crate) mod stdlib; @@ -242,30 +242,44 @@ pub trait WithSubscriber: Sized { } } +#[cfg(feature = "std-future")] +pin_project! { + /// A future, stream, sink, or executor that has been instrumented with a `tracing` span. + #[derive(Debug, Clone)] + pub struct Instrumented { + #[pin] + inner: T, + span: Span, + } +} + /// A future, stream, sink, or executor that has been instrumented with a `tracing` span. -#[cfg_attr(feature = "std-future", pin_project)] +#[cfg(not(feature = "std-future"))] #[derive(Debug, Clone)] pub struct Instrumented { - #[cfg(feature = "std-future")] - #[pin] - inner: T, - #[cfg(not(feature = "std-future"))] inner: T, span: Span, } +#[cfg(all(feature = "std", feature = "std-future"))] +pin_project! { + /// A future, stream, sink, or executor that has been instrumented with a + /// `tracing` subscriber. + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] + #[derive(Clone, Debug)] + pub struct WithDispatch { + #[pin] + inner: T, + dispatch: Dispatch, + } +} + /// A future, stream, sink, or executor that has been instrumented with a /// `tracing` subscriber. -#[cfg(feature = "std")] +#[cfg(all(feature = "std", not(feature = "std-future")))] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] -#[cfg_attr(feature = "std-future", pin_project)] #[derive(Clone, Debug)] pub struct WithDispatch { - // cfg_attr doesn't work inside structs, apparently... - #[cfg(feature = "std-future")] - #[pin] - inner: T, - #[cfg(not(feature = "std-future"))] inner: T, dispatch: Dispatch, } diff --git a/tracing-tower/Cargo.toml b/tracing-tower/Cargo.toml index 29703d0f..c4a272b9 100644 --- a/tracing-tower/Cargo.toml +++ b/tracing-tower/Cargo.toml @@ -20,7 +20,7 @@ license = "MIT" default = ["tower-layer", "tower-make", "http"] tower-make = [ "tower_make", - "pin-project", + "pin-project-lite", ] [dependencies] @@ -30,7 +30,7 @@ futures = "0.3" tower-service = "0.3" tower-layer = { version = "0.3", optional = true } tower_make = { package = "tower-make", version = "0.3", optional = true } -pin-project = { version = "1.0", optional = true } +pin-project-lite = { version = "0.2.4", optional = true } http = { version = "0.2", optional = true } [badges] diff --git a/tracing-tower/src/request_span.rs b/tracing-tower/src/request_span.rs index 3c9ed612..5bece32c 100644 --- a/tracing-tower/src/request_span.rs +++ b/tracing-tower/src/request_span.rs @@ -79,7 +79,7 @@ pub use self::make::MakeService; #[cfg_attr(docsrs, doc(cfg(feature = "tower-make")))] pub mod make { use super::*; - use pin_project::pin_project; + use pin_project_lite::pin_project; #[derive(Debug)] pub struct MakeService tracing::Span> { @@ -99,13 +99,14 @@ pub mod make { _p: PhantomData, } - #[pin_project] - #[derive(Debug)] - pub struct MakeFuture tracing::Span> { - get_span: Option, - #[pin] - inner: F, - _p: PhantomData, + pin_project! { + #[derive(Debug)] + pub struct MakeFuture tracing::Span> { + get_span: Option, + #[pin] + inner: F, + _p: PhantomData, + } } #[cfg(feature = "tower-layer")] diff --git a/tracing-tower/src/service_span.rs b/tracing-tower/src/service_span.rs index f81215fe..5e0fc9a6 100644 --- a/tracing-tower/src/service_span.rs +++ b/tracing-tower/src/service_span.rs @@ -79,7 +79,7 @@ mod layer { #[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] pub mod make { use super::*; - use pin_project::pin_project; + use pin_project_lite::pin_project; #[derive(Debug)] pub struct MakeService tracing::Span> @@ -91,12 +91,13 @@ pub mod make { _p: PhantomData, } - #[pin_project] - #[derive(Debug)] - pub struct MakeFuture { - #[pin] - inner: F, - span: Option, + pin_project! { + #[derive(Debug)] + pub struct MakeFuture { + #[pin] + inner: F, + span: Option, + } } #[derive(Debug)]