RS.CLIPPY.UNSAFE_DERIVE_DESERIALIZE
Deriving `serde::Deserialize` on a type that has methods using `unsafe`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: unsafe_derive_deserialize. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for deriving serde::Deserialize on a type that
has methods using unsafe.
Why is this bad?
Deriving serde::Deserialize will create a constructor
that may violate invariants held by another constructor.
Example
use serde::Deserialize;
#[derive(Deserialize)]
pub struct Foo {
// ..
}
impl Foo {
pub fn new() -> Self {
// setup here ..
}
pub unsafe fn parts() -> (&str, &str) {
// assumes invariants hold
}
}