diff --git a/tracing-subscriber/src/registry/mod.rs b/tracing-subscriber/src/registry/mod.rs index 6ee7ebba44..48b378d1ed 100644 --- a/tracing-subscriber/src/registry/mod.rs +++ b/tracing-subscriber/src/registry/mod.rs @@ -235,6 +235,11 @@ pub struct Scope<'a, R> { feature! { #![any(feature = "alloc", feature = "std")] + use alloc::{ + boxed::Box, + sync::Arc + }; + #[cfg(not(feature = "smallvec"))] use alloc::vec::{self, Vec}; use core::{fmt,iter}; @@ -255,6 +260,66 @@ feature! { #[cfg(feature = "smallvec")] type SpanRefVecArray<'span, L> = [SpanRef<'span, L>; 16]; + impl<'a, S> LookupSpan<'a> for Arc + where + S: LookupSpan<'a>, + { + type Data = >::Data; + + fn span_data(&'a self, id: &Id) -> Option { + self.as_ref().span_data(id) + } + + fn span(&'a self, id: &Id) -> Option> + where + Self: Sized, + { + self.as_ref().span(id).map( + |SpanRef { + registry: _, + data, + #[cfg(feature = "registry")] + filter, + }| SpanRef { + registry: self, + data, + #[cfg(feature = "registry")] + filter, + }, + ) + } + } + + impl<'a, S> LookupSpan<'a> for Box + where + S: LookupSpan<'a>, + { + type Data = >::Data; + + fn span_data(&'a self, id: &Id) -> Option { + self.as_ref().span_data(id) + } + + fn span(&'a self, id: &Id) -> Option> + where + Self: Sized, + { + self.as_ref().span(id).map( + |SpanRef { + registry: _, + data, + #[cfg(feature = "registry")] + filter, + }| SpanRef { + registry: self, + data, + #[cfg(feature = "registry")] + filter, + }, + ) + } + } + impl<'a, R> Scope<'a, R> where R: LookupSpan<'a>, diff --git a/tracing-subscriber/src/subscribe/mod.rs b/tracing-subscriber/src/subscribe/mod.rs index 6c1878b177..47bec36028 100644 --- a/tracing-subscriber/src/subscribe/mod.rs +++ b/tracing-subscriber/src/subscribe/mod.rs @@ -1656,7 +1656,7 @@ feature! { } - impl Subscribe for Vec + impl Subscribe for alloc::vec::Vec where S: Subscribe, C: Collect,