Skip to content

Commit

Permalink
Clone once
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdplm committed Oct 16, 2020
1 parent 5ad3ab1 commit 521cf74
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tracing-core/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,12 @@ pub fn set_global_default(dispatcher: &Dispatch) -> Result<(), SetGlobalDefaultE
{
#[cfg(feature = "alloc")]
let subscriber = {
let subscriber = match &dispatcher.subscriber {
Kind::Global(s) => s.clone(),
let subscriber = match dispatcher.subscriber.clone() {
Kind::Global(s) => s,
Kind::Scoped(s) => unsafe {
// safety: this leaks the subscriber onto the heap. the
// reference count will always be at least 1.
&*Arc::into_raw(s.clone())
&*Arc::into_raw(s)
},
};
Kind::Global(subscriber)
Expand Down

0 comments on commit 521cf74

Please sign in to comment.