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

unsafe_derive_deserialize can't be enabled/disabled per struct #5789

Closed
alecmocatta opened this issue Jul 13, 2020 · 0 comments · Fixed by #5870
Closed

unsafe_derive_deserialize can't be enabled/disabled per struct #5789

alecmocatta opened this issue Jul 13, 2020 · 0 comments · Fixed by #5870
Labels
C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@alecmocatta
Copy link

clippy::unsafe_derive_deserialize can't be allowed/warned/denied by outer attributes on the struct or its impls. Minor inconvenience but might be worth making one of these allows functional?

#![allow(dead_code, unused_unsafe)]
#![warn(clippy::unsafe_derive_deserialize)]

use serde::Deserialize;

#[allow(clippy::unsafe_derive_deserialize)]
#[derive(Deserialize)]
struct Foo;

#[allow(clippy::unsafe_derive_deserialize)]
impl Foo {
    fn bar(&mut self) {
        let _ = self;
        unsafe {}
    }
}

(Playground)

Clippy:

    Checking playground v0.0.1 (/playground)
warning: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
 --> src/lib.rs:7:10
  |
7 | #[derive(Deserialize)]
  |          ^^^^^^^^^^^
  |
note: the lint level is defined here
 --> src/lib.rs:2:9
  |
2 | #![warn(clippy::unsafe_derive_deserialize)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: consider implementing `serde::Deserialize` manually. See https://serde.rs/impl-deserialize.html
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unsafe_derive_deserialize
  = note: this warning originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
@alecmocatta alecmocatta added the C-bug Category: Clippy is not doing the correct thing label Jul 13, 2020
@flip1995 flip1995 added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Jul 13, 2020
bors added a commit that referenced this issue Aug 7, 2020
…flip1995

enable #[allow(clippy::unsafe_derive_deserialize)]

Before this change this lint could not be allowed as the code we are checking is automatically generated.

changelog: Enable using the `allow` attribute on top of an ADT linted by [`unsafe_derive_deserialize`].

Fixes: #5789
bors added a commit that referenced this issue Aug 7, 2020
…flip1995

enable #[allow(clippy::unsafe_derive_deserialize)]

Before this change this lint could not be allowed as the code we are checking is automatically generated.

changelog: Enable using the `allow` attribute on top of an ADT linted by [`unsafe_derive_deserialize`].

Fixes: #5789
@bors bors closed this as completed in 08ab29b Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants