]> git.lizzy.rs Git - rust.git/blob - tests/ui/undropped_manually_drops.rs
Add new lint for undropped ManuallyDrop values
[rust.git] / tests / ui / undropped_manually_drops.rs
1 #![warn(clippy::undropped_manually_drops)]
2
3 struct S;
4
5 fn main() {
6     let f = drop;
7     let manual = std::mem::ManuallyDrop::new(S);
8
9     // These lines will not drop `S`
10     drop(std::mem::ManuallyDrop::new(S));
11     f(manual);
12
13     // These lines will
14     unsafe {
15         std::mem::ManuallyDrop::drop(std::mem::ManuallyDrop::new(S));
16         std::mem::ManuallyDrop::drop(manual);
17     }
18 }