`windows-bindgen` _Impl trait should use `unsafe fn` if any of its parameters are pointers
Author: saschanazCreated Feb 5, 2022Updated Jul 7, 2026
Labelsquestion
Which crate is this about?
windows
Crate version
0.32.0
Summary
#[implement(Windows::Win32::Graphics::Imaging::IWICBitmapFrameDecode)]
pub struct Foo {}
impl IWICBitmapSource_Impl for Foo {
fn GetSize(&mut self, puiwidth: *mut u32, puiheight: *mut u32) -> windows::core::Result<()> {
unsafe {
*puiwidth = 0u32;
*puiheight = 0u32;
}
Ok(())
}
/* ... */
}Expected behavior
It should be an unsafe fn as the implementation is expected to dereference the pointer parameters.
Actual behavior
Everything is just a safe fn.
Additional comments
cargo clippy is unsatisfied:
error: this public function might dereference a raw pointer but is not marked `unsafe`
--> src\lib.rs:149:14
|
149 | *puiwidth = self.decoded.borrow().basic_info.xsize;
| ^^^^^^^^
|
= note: `#[deny(clippy::not_unsafe_ptr_arg_deref)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_derefSource: microsoft/windows-rs