Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix deprecation and clippy warnings #1195

Merged
merged 7 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tracing-core/src/callsite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ mod inner {

impl PartialEq for Identifier {
fn eq(&self, other: &Identifier) -> bool {
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 (),
)
}
}

Expand Down
11 changes: 10 additions & 1 deletion tracing-core/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,16 @@ 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.
Comment on lines +311 to +312
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO explaining what compare_exchange does doesn't seem super necessary to me, but it's not a blocker...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd rather over-explain then under-explain here!

if GLOBAL_INIT
.compare_exchange(
UNINITIALIZED,
INITIALIZING,
Ordering::SeqCst,
Ordering::SeqCst,
)
.is_ok()
{
#[cfg(feature = "alloc")]
let collector = {
Expand Down
2 changes: 1 addition & 1 deletion tracing/tests/support/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ impl MockHandle {
}

impl Expect {
fn bad<'a>(&self, name: impl AsRef<str>, what: fmt::Arguments<'a>) {
fn bad(&self, name: impl AsRef<str>, what: fmt::Arguments<'_>) {
let name = name.as_ref();
match self {
Expect::Event(e) => panic!("[{}] expected event {}, but {} instead", name, e, what,),
Expand Down