1 #![warn(clippy::undropped_manually_drops)] 2 3 struct S; 4 main()5fn main() { 6 let f = std::mem::drop; 7 let g = std::mem::ManuallyDrop::drop; 8 let mut manual1 = std::mem::ManuallyDrop::new(S); 9 let mut manual2 = std::mem::ManuallyDrop::new(S); 10 let mut manual3 = std::mem::ManuallyDrop::new(S); 11 let mut manual4 = std::mem::ManuallyDrop::new(S); 12 13 // These lines will not drop `S` and should be linted 14 drop(std::mem::ManuallyDrop::new(S)); 15 drop(manual1); 16 17 // FIXME: this line is not linted, though it should be 18 f(manual2); 19 20 // These lines will drop `S` and should be okay. 21 unsafe { 22 std::mem::ManuallyDrop::drop(&mut std::mem::ManuallyDrop::new(S)); 23 std::mem::ManuallyDrop::drop(&mut manual3); 24 g(&mut manual4); 25 } 26 } 27