Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: compare
callsite::Identifier
data pointers only (tokio-rs#749)
## Motivation Clippy [now warns us][1] that comparing trait object pointers with `ptr::eq` is bad, because vtable addresses are not guaranteed to be unique due to the compiler merging vtables, and vtables for the same trait impl may have different addresses in different compilation units. In practice, I don't believe this actually effects `tracing-core`'s use case for this comparison. Because callsites must be static, the data component of the trait object wide pointer will always be unique, even if the compiler merges the vtables for all the identical generated `Callsite` impls (which it may very well do!). ## Solution Although this is probably not an issue in practice, I still thought it was good to fix the clippy warning, and to be more explicit that it's the data pointer comparison that's load-bearing here. I've updated the `PartialEq` impl for `callsite::Identifier` to cast to `*const ()` to extract the data address from the wide pointer. [1]: https://rust-lang.github.io/rust-clippy/master/index.html#vtable_address_comparisons Signed-off-by: Eliza Weisman <eliza@buoyant.io>
- Loading branch information