Resolve ptr_eq clippy lint

error: use `std::ptr::eq` when comparing raw pointers
       --> serde_derive/src/de.rs:362:12
        |
    362 |         if field as *const Field == transparent_field as *const Field {
        |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(field, transparent_field)`
        |
    note: the lint level is defined here
       --> serde_derive/src/lib.rs:18:9
        |
    18  | #![deny(clippy::all, clippy::pedantic)]
        |         ^^^^^^^^^^^
        = note: `#[deny(clippy::ptr_eq)]` implied by `#[deny(clippy::all)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq
This commit is contained in:
David Tolnay 2020-10-27 19:18:27 -07:00
parent 8084258a3e
commit 0d5b6c180c
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -12,6 +12,7 @@ use internals::{attr, ungroup, Ctxt, Derive};
use pretend;
use std::collections::BTreeSet;
use std::ptr;
pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result<TokenStream, Vec<syn::Error>> {
let ctxt = Ctxt::new();
@ -359,7 +360,7 @@ fn deserialize_transparent(cont: &Container, params: &Parameters) -> Fragment {
let assign = fields.iter().map(|field| {
let member = &field.member;
if field as *const Field == transparent_field as *const Field {
if ptr::eq(field, transparent_field) {
quote!(#member: __transparent)
} else {
let value = match field.attrs.default() {