writeln!(w, "impl Drop for {} {{", mangled_container).unwrap();
writeln!(w, "\tfn drop(&mut self) {{").unwrap();
writeln!(w, "\t\tif self.datalen == 0 {{ return; }}").unwrap();
- writeln!(w, "\t\tunsafe {{ Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }};").unwrap();
+ writeln!(w, "\t\tlet _ = unsafe {{ Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }};").unwrap();
writeln!(w, "\t}}").unwrap();
writeln!(w, "}}").unwrap();
if clonable {
writeln!(w, "#[allow(unused)]").unwrap();
writeln!(w, "/// Used only if an object of this type is returned as a trait impl by a method").unwrap();
writeln!(w, "pub(crate) extern \"C\" fn {}_free_void(this_ptr: *mut c_void) {{", struct_name).unwrap();
- writeln!(w, "\tunsafe {{ let _ = Box::from_raw(this_ptr as *mut native{}); }}\n}}", struct_name).unwrap();
+ writeln!(w, "\tlet _ = unsafe {{ Box::from_raw(this_ptr as *mut native{}) }};\n}}", struct_name).unwrap();
writeln!(w, "#[allow(unused)]").unwrap();
writeln!(w, "impl {} {{", struct_name).unwrap();
writeln!(w, "\tpub(crate) fn get_native_ref(&self) -> &'static native{} {{", struct_name).unwrap();
fn drop(&mut self) {
if self.result_ok {
if unsafe { !self.contents.result.is_null() } {
- unsafe { Box::from_raw(self.contents.result) };
+ let _ = unsafe { Box::from_raw(self.contents.result) };
}
} else if unsafe { !self.contents.err.is_null() } {
- unsafe { Box::from_raw(self.contents.err) };
+ let _ = unsafe { Box::from_raw(self.contents.err) };
}
}
}
impl<T> Drop for SmartPtr<T> {
fn drop(&mut self) {
if self.ptr != core::ptr::null_mut() {
- unsafe { Box::from_raw(self.ptr); }
+ let _ = unsafe { Box::from_raw(self.ptr) };
}
}
}