From 63b254dc6eab499fba1528fbd8507aff8d3adcb0 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Thu, 6 Oct 2022 14:02:12 -0700 Subject: [PATCH] subscriber: revert "impl `LookupSpan` for `Box` and `Arc` (#2247)" This reverts commit a0824d398aa2511de28371d30dda9203360a6cf5 (PR #2247). As discussed in [this comment][1], the implementation for `Arc`s may cause subtly incorrect behavior if actually used, due to the `&mut self` receiver of the `LookupSpan::register_filter` method, since the `Arc` cannot be mutably borrowed if any clones of it exist. The APIs added in PRs #2269 and #2293 offer an alternative solution to the same problems this change was intended to solve, and --- since this change hasn't been published yet --- it can safely be reverted. [1]: https://giethub.com/tokio-rs/tracing/pull/2247#issuecomment-1199924876 --- tracing-subscriber/src/layer/mod.rs | 4 +- tracing-subscriber/src/registry/mod.rs | 65 -------------------------- 2 files changed, 3 insertions(+), 66 deletions(-) diff --git a/tracing-subscriber/src/layer/mod.rs b/tracing-subscriber/src/layer/mod.rs index b4533771c5..bdc154301a 100644 --- a/tracing-subscriber/src/layer/mod.rs +++ b/tracing-subscriber/src/layer/mod.rs @@ -685,7 +685,7 @@ use core::any::TypeId; feature! { #![feature = "alloc"] - use alloc::{vec::Vec, boxed::Box}; + use alloc::boxed::Box; use core::ops::{Deref, DerefMut}; } @@ -1656,6 +1656,8 @@ where feature! { #![any(feature = "std", feature = "alloc")] + #[cfg(not(feature = "std"))] + use alloc::vec::Vec; macro_rules! layer_impl_body { () => { diff --git a/tracing-subscriber/src/registry/mod.rs b/tracing-subscriber/src/registry/mod.rs index 61e97a2ccd..b492de2e58 100644 --- a/tracing-subscriber/src/registry/mod.rs +++ b/tracing-subscriber/src/registry/mod.rs @@ -234,11 +234,6 @@ 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}; @@ -260,66 +255,6 @@ 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>,