Skip to content

Commit

Permalink
Resolve ptr_eq clippy lint
Browse files Browse the repository at this point in the history
    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
  • Loading branch information
dtolnay committed Oct 28, 2020
1 parent 8084258 commit 0d5b6c1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion serde_derive/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 0d5b6c1

Please sign in to comment.