Skip to content

Commit a4fc92c

Browse files
committed
subscriber: revert "impl LookupSpan for Box<LS> and Arc<LS> (#2247)"
This reverts commit a0824d3 (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
1 parent 8e35927 commit a4fc92c

File tree

2 files changed

+3
-66
lines changed

2 files changed

+3
-66
lines changed

tracing-subscriber/src/layer/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ use core::any::TypeId;
685685

686686
feature! {
687687
#![feature = "alloc"]
688-
use alloc::{vec::Vec, boxed::Box};
688+
use alloc::boxed::Box;
689689
use core::ops::{Deref, DerefMut};
690690
}
691691

@@ -1656,6 +1656,8 @@ where
16561656

16571657
feature! {
16581658
#![any(feature = "std", feature = "alloc")]
1659+
#[cfg(not(feature = "std"))]
1660+
use alloc::vec::Vec;
16591661

16601662
macro_rules! layer_impl_body {
16611663
() => {

tracing-subscriber/src/registry/mod.rs

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,6 @@ pub struct Scope<'a, R> {
230230
feature! {
231231
#![any(feature = "alloc", feature = "std")]
232232

233-
use alloc::{
234-
boxed::Box,
235-
sync::Arc
236-
};
237-
238233
#[cfg(not(feature = "smallvec"))]
239234
use alloc::vec::{self, Vec};
240235

@@ -256,66 +251,6 @@ feature! {
256251
#[cfg(feature = "smallvec")]
257252
type SpanRefVecArray<'span, L> = [SpanRef<'span, L>; 16];
258253

259-
impl<'a, S> LookupSpan<'a> for Arc<S>
260-
where
261-
S: LookupSpan<'a>,
262-
{
263-
type Data = <S as LookupSpan<'a>>::Data;
264-
265-
fn span_data(&'a self, id: &Id) -> Option<Self::Data> {
266-
self.as_ref().span_data(id)
267-
}
268-
269-
fn span(&'a self, id: &Id) -> Option<SpanRef<'_, Self>>
270-
where
271-
Self: Sized,
272-
{
273-
self.as_ref().span(id).map(
274-
|SpanRef {
275-
registry: _,
276-
data,
277-
#[cfg(feature = "registry")]
278-
filter,
279-
}| SpanRef {
280-
registry: self,
281-
data,
282-
#[cfg(feature = "registry")]
283-
filter,
284-
},
285-
)
286-
}
287-
}
288-
289-
impl<'a, S> LookupSpan<'a> for Box<S>
290-
where
291-
S: LookupSpan<'a>,
292-
{
293-
type Data = <S as LookupSpan<'a>>::Data;
294-
295-
fn span_data(&'a self, id: &Id) -> Option<Self::Data> {
296-
self.as_ref().span_data(id)
297-
}
298-
299-
fn span(&'a self, id: &Id) -> Option<SpanRef<'_, Self>>
300-
where
301-
Self: Sized,
302-
{
303-
self.as_ref().span(id).map(
304-
|SpanRef {
305-
registry: _,
306-
data,
307-
#[cfg(feature = "registry")]
308-
filter,
309-
}| SpanRef {
310-
registry: self,
311-
data,
312-
#[cfg(feature = "registry")]
313-
filter,
314-
},
315-
)
316-
}
317-
}
318-
319254
impl<'a, R> Scope<'a, R>
320255
where
321256
R: LookupSpan<'a>,

0 commit comments

Comments
 (0)