mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-09-29 22:10:38 +00:00
subscriber: revert "impl LookupSpan
for Box<LS>
and Arc<LS>
(#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
This commit is contained in:
parent
8e35927d7e
commit
a4fc92ccf8
@ -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 {
|
||||
() => {
|
||||
|
@ -230,11 +230,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};
|
||||
|
||||
@ -256,66 +251,6 @@ feature! {
|
||||
#[cfg(feature = "smallvec")]
|
||||
type SpanRefVecArray<'span, L> = [SpanRef<'span, L>; 16];
|
||||
|
||||
impl<'a, S> LookupSpan<'a> for Arc<S>
|
||||
where
|
||||
S: LookupSpan<'a>,
|
||||
{
|
||||
type Data = <S as LookupSpan<'a>>::Data;
|
||||
|
||||
fn span_data(&'a self, id: &Id) -> Option<Self::Data> {
|
||||
self.as_ref().span_data(id)
|
||||
}
|
||||
|
||||
fn span(&'a self, id: &Id) -> Option<SpanRef<'_, Self>>
|
||||
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<S>
|
||||
where
|
||||
S: LookupSpan<'a>,
|
||||
{
|
||||
type Data = <S as LookupSpan<'a>>::Data;
|
||||
|
||||
fn span_data(&'a self, id: &Id) -> Option<Self::Data> {
|
||||
self.as_ref().span_data(id)
|
||||
}
|
||||
|
||||
fn span(&'a self, id: &Id) -> Option<SpanRef<'_, Self>>
|
||||
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>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user