On Wed Mar 12, 2025 at 4:18 PM CET, Tamir Duberstein wrote: > On Wed, Mar 12, 2025 at 10:40 AM Benno Lossin <benno.lossin@xxxxxxxxx> wrote: >> >> On Sun Mar 9, 2025 at 5:00 PM CET, Tamir Duberstein wrote: >> > In Rust 1.51.0, Clippy introduced the `ptr_as_ptr` lint [1]: >> > >> >> Though `as` casts between raw pointers are not terrible, >> >> `pointer::cast` is safer because it cannot accidentally change the >> >> pointer's mutability, nor cast the pointer to other types like `usize`. >> > >> > There are a few classes of changes required: >> > - Modules generated by bindgen are marked >> > `#[allow(clippy::ptr_as_ptr)]`. >> > - Inferred casts (` as _`) are replaced with `.cast()`. >> > - Ascribed casts (` as *... T`) are replaced with `.cast::<T>()`. >> > - Multistep casts from references (` as *const _ as *const T`) are >> > replaced with `let x: *const _ = &x;` and `.cast()` or `.cast::<T>()` >> >> Similarly to the other patch, this could be `let x = &raw x;`. (but it's >> fine to leave it as-is for now, we can also make that a >> good-first-issue.) > > Yeah, same as the other patch; we can't directly do that here without > introducing some compiler infra or bumping MSRV. I think it's fine enabling the feature for this patch (or in a prior one) if you want to do the work. But someone already took up the issue I created, so maybe it's best to let them handle it. --- Cheers, Benno