]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/src/docs/unsafe_derive_deserialize.txt
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / unsafe_derive_deserialize.txt
1 ### What it does
2 Checks for deriving `serde::Deserialize` on a type that
3 has methods using `unsafe`.
4
5 ### Why is this bad?
6 Deriving `serde::Deserialize` will create a constructor
7 that may violate invariants hold by another constructor.
8
9 ### Example
10 ```
11 use serde::Deserialize;
12
13 #[derive(Deserialize)]
14 pub struct Foo {
15 // ..
16 }
17
18 impl Foo {
19 pub fn new() -> Self {
20 // setup here ..
21 }
22
23 pub unsafe fn parts() -> (&str, &str) {
24 // assumes invariants hold
25 }
26 }
27 ```