From 11c2a9fced05fca7b05045a27613e126e575d2da Mon Sep 17 00:00:00 2001 From: David Barsky Date: Fri, 15 Jan 2021 11:38:03 -0500 Subject: [PATCH 1/7] chore: fix clippy and deprecation warnings --- tracing-core/src/callsite.rs | 2 +- tracing-core/src/dispatch.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tracing-core/src/callsite.rs b/tracing-core/src/callsite.rs index 8fad4f8ae1..b1e852a33b 100644 --- a/tracing-core/src/callsite.rs +++ b/tracing-core/src/callsite.rs @@ -235,7 +235,7 @@ mod inner { impl PartialEq for Identifier { fn eq(&self, other: &Identifier) -> bool { - self.0 as *const _ as *const () == other.0 as *const _ as *const () + std::ptr::eq(self.0 as *const _, other.0 as *const _) } } diff --git a/tracing-core/src/dispatch.rs b/tracing-core/src/dispatch.rs index c007f3c75f..331a4ae1a8 100644 --- a/tracing-core/src/dispatch.rs +++ b/tracing-core/src/dispatch.rs @@ -308,8 +308,14 @@ pub fn set_default(dispatcher: &Dispatch) -> DefaultGuard { /// [span]: super::span /// [`Event`]: super::event::Event pub fn set_global_default(dispatcher: Dispatch) -> Result<(), SetGlobalDefaultError> { - if GLOBAL_INIT.compare_and_swap(UNINITIALIZED, INITIALIZING, Ordering::SeqCst) == UNINITIALIZED - { + // if `compare_exchange` returns Result::Ok(_), then `new` has been set and + // `current`—now the prior value—has been returned in the `Ok()` branch. + if let Ok(_) = GLOBAL_INIT.compare_exchange( + UNINITIALIZED, + INITIALIZING, + Ordering::SeqCst, + Ordering::SeqCst, + ) { #[cfg(feature = "alloc")] let collector = { let collector = match dispatcher.collector { From 5947c967328c45dc32eda12d42711f65930afc64 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Fri, 15 Jan 2021 12:57:38 -0500 Subject: [PATCH 2/7] whoops, `ptr::eq` is actually in core --- tracing-core/src/callsite.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracing-core/src/callsite.rs b/tracing-core/src/callsite.rs index b1e852a33b..8204ec383f 100644 --- a/tracing-core/src/callsite.rs +++ b/tracing-core/src/callsite.rs @@ -235,7 +235,7 @@ mod inner { impl PartialEq for Identifier { fn eq(&self, other: &Identifier) -> bool { - std::ptr::eq(self.0 as *const _, other.0 as *const _) + core::ptr::eq(self.0 as *const _, other.0 as *const _) } } From 611c707188ccd6a9f0384668fab5313318005877 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Fri, 15 Jan 2021 13:05:59 -0500 Subject: [PATCH 3/7] c'mon, clippy --- tracing-core/src/dispatch.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tracing-core/src/dispatch.rs b/tracing-core/src/dispatch.rs index 331a4ae1a8..d48ef5bb92 100644 --- a/tracing-core/src/dispatch.rs +++ b/tracing-core/src/dispatch.rs @@ -310,12 +310,15 @@ pub fn set_default(dispatcher: &Dispatch) -> DefaultGuard { pub fn set_global_default(dispatcher: Dispatch) -> Result<(), SetGlobalDefaultError> { // if `compare_exchange` returns Result::Ok(_), then `new` has been set and // `current`—now the prior value—has been returned in the `Ok()` branch. - if let Ok(_) = GLOBAL_INIT.compare_exchange( - UNINITIALIZED, - INITIALIZING, - Ordering::SeqCst, - Ordering::SeqCst, - ) { + if GLOBAL_INIT + .compare_exchange( + UNINITIALIZED, + INITIALIZING, + Ordering::SeqCst, + Ordering::SeqCst, + ) + .is_ok() + { #[cfg(feature = "alloc")] let collector = { let collector = match dispatcher.collector { From 872b11f532dad0e651a0bd3c4d611d8fec508f22 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Fri, 15 Jan 2021 13:06:55 -0500 Subject: [PATCH 4/7] okay, that's fair --- tracing-core/src/callsite.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracing-core/src/callsite.rs b/tracing-core/src/callsite.rs index 8204ec383f..56cae9d96b 100644 --- a/tracing-core/src/callsite.rs +++ b/tracing-core/src/callsite.rs @@ -235,7 +235,7 @@ mod inner { impl PartialEq for Identifier { fn eq(&self, other: &Identifier) -> bool { - core::ptr::eq(self.0 as *const _, other.0 as *const _) + core::ptr::eq(self.0, other.0) } } From 955b388dfe9e258031ed357cbccdcb96bf5557b3 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Sun, 17 Jan 2021 12:31:39 -0500 Subject: [PATCH 5/7] Update tracing-core/src/callsite.rs Co-authored-by: Eliza Weisman --- tracing-core/src/callsite.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracing-core/src/callsite.rs b/tracing-core/src/callsite.rs index 56cae9d96b..fb956f1ea5 100644 --- a/tracing-core/src/callsite.rs +++ b/tracing-core/src/callsite.rs @@ -235,7 +235,7 @@ mod inner { impl PartialEq for Identifier { fn eq(&self, other: &Identifier) -> bool { - core::ptr::eq(self.0, other.0) + core::ptr::eq(self.0 as *const _ as *const (), other.0 as *const _ as *const ()) } } From 9b9d5842470f11bfe9d8c698d4a4d3b4822d0319 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Mon, 25 Jan 2021 09:58:11 -0500 Subject: [PATCH 6/7] fmt --- tracing-core/src/callsite.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tracing-core/src/callsite.rs b/tracing-core/src/callsite.rs index fb956f1ea5..00cef02a4c 100644 --- a/tracing-core/src/callsite.rs +++ b/tracing-core/src/callsite.rs @@ -235,7 +235,10 @@ mod inner { impl PartialEq for Identifier { fn eq(&self, other: &Identifier) -> bool { - core::ptr::eq(self.0 as *const _ as *const (), other.0 as *const _ as *const ()) + core::ptr::eq( + self.0 as *const _ as *const (), + other.0 as *const _ as *const (), + ) } } From 97dae34c379bf8878f3b0f8eefdb4b1ff0c19137 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Mon, 25 Jan 2021 10:08:11 -0500 Subject: [PATCH 7/7] remove needless lifetime --- tracing/tests/support/collector.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracing/tests/support/collector.rs b/tracing/tests/support/collector.rs index 513bedfc00..3540f694f0 100644 --- a/tracing/tests/support/collector.rs +++ b/tracing/tests/support/collector.rs @@ -536,7 +536,7 @@ impl MockHandle { } impl Expect { - fn bad<'a>(&self, name: impl AsRef, what: fmt::Arguments<'a>) { + fn bad(&self, name: impl AsRef, what: fmt::Arguments<'_>) { let name = name.as_ref(); match self { Expect::Event(e) => panic!("[{}] expected event {}, but {} instead", name, e, what,),