Skip to content

Commit 601bf67

Browse files
davidbarskyhawkw
authored andcommitted
subscriber: remove Layer impls for Arcs (#1649)
Implementing `Layer` for `Arc`s, which are immutable, breaks the ability to implement `Layer::on_layer` with a mutable reference. This is necessary for per-layer filtering. See #1576 (comment) for details. Therefore, the `Layer` impls for `Arc`s should not be used. In 0.3, we have the opportunity to remove these APIs. Therefore, this PR removes them.
1 parent 0428412 commit 601bf67

File tree

1 file changed

+10
-16
lines changed
  • tracing-subscriber/src/subscribe

1 file changed

+10
-16
lines changed

tracing-subscriber/src/subscribe/mod.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,11 @@
417417
//! [`LevelFilter`]: crate::filter::LevelFilter
418418
//! [feat]: crate#feature-flags
419419
use crate::filter;
420-
use std::{any::TypeId, ops::Deref, ptr::NonNull, sync::Arc};
420+
use std::{
421+
any::TypeId,
422+
ops::{Deref, DerefMut},
423+
ptr::NonNull,
424+
};
421425
use tracing_core::{
422426
collect::{Collect, Interest},
423427
metadata::Metadata,
@@ -1083,6 +1087,11 @@ where
10831087

10841088
macro_rules! layer_impl_body {
10851089
() => {
1090+
#[inline]
1091+
fn on_subscribe(&mut self, collect: &mut C) {
1092+
self.deref_mut().on_subscribe(collect);
1093+
}
1094+
10861095
#[inline]
10871096
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
10881097
self.deref().on_new_span(attrs, id, ctx)
@@ -1146,21 +1155,6 @@ macro_rules! layer_impl_body {
11461155
};
11471156
}
11481157

1149-
impl<S, C> Subscribe<C> for Arc<S>
1150-
where
1151-
S: Subscribe<C>,
1152-
C: Collect,
1153-
{
1154-
layer_impl_body! {}
1155-
}
1156-
1157-
impl<C> Subscribe<C> for Arc<dyn Subscribe<C>>
1158-
where
1159-
C: Collect,
1160-
{
1161-
layer_impl_body! {}
1162-
}
1163-
11641158
impl<S, C> Subscribe<C> for Box<S>
11651159
where
11661160
S: Subscribe<C>,

0 commit comments

Comments
 (0)