You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lint should warn when casts using type inference are being used on pointers types.
Recently we had a bug on a FFI boundary where a *const T was being cast with self.inner() as *mut _ when calling a C function with signature sys::foo(T**), but inner function is defined as fn inner() -> *const T.
This lead to passing a pointer as pointer to pointer, and the application crashing at runtime.
Categories (optional)
Kind: clippy::correctness, clippy::pedantic
Original code might be buggy. Intent is to have a mechanism that warns or errors when such a code is found on particular scenarios, specifically for our case in code involving the FFI boundary.
Drawbacks
Might get annoying for most use cases, thats why it was suggested also as pedantic linter.
Example
sys::foo(self.inner()as*mut_);
Could be written as:
sys::foo(self.inner()as*mutT);
In this case code would fail to compile, but provides us the chance to catch and fix the error at compile time.
The text was updated successfully, but these errors were encountered:
What it does
Lint should warn when casts using type inference are being used on pointers types.
Recently we had a bug on a FFI boundary where a
*const T
was being cast withself.inner() as *mut _
when calling a C function with signaturesys::foo(T**)
, butinner
function is defined asfn inner() -> *const T
.This lead to passing a pointer as pointer to pointer, and the application crashing at runtime.
Categories (optional)
Original code might be buggy. Intent is to have a mechanism that warns or errors when such a code is found on particular scenarios, specifically for our case in code involving the FFI boundary.
Drawbacks
Might get annoying for most use cases, thats why it was suggested also as pedantic linter.
Example
Could be written as:
In this case code would fail to compile, but provides us the chance to catch and fix the error at compile time.
The text was updated successfully, but these errors were encountered: