refactor(allocator): fix ptr_cast_constness clippy warnings#21222
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR continues the allocator refactor in oxc_allocator by replacing raw pointer constness casts (as *const T / as *mut T) with the explicit pointer APIs (cast_const() / cast_mut()), aiming to eliminate clippy::ptr_cast_constness warnings and remove the corresponding #![expect(...)] entry.
Changes:
- Removed
clippy::ptr_cast_constnessfrom the file-level#![expect(...)]list. - Replaced
as *const u8casts inChunkFooter::as_raw_parts()withcast_const(). - Replaced one
as *mut u8cast inChunkRawIterwithcast_mut().
Comments suppressed due to low confidence (1)
crates/oxc_allocator/src/bump.rs:16
clippy::ptr_cast_constnesswas removed from the#![expect(...)]list, but there is still at least one raw-pointeras *const ...cast in this file (ChunkIter::nextusesptr as *const mem::MaybeUninit<u8>). Ifptr_cast_constnessis enabled in CI, this will reintroduce the clippy warning/error. Please update the remaining cast(s) to use the pointer casting APIs (e.g.cast::<T>()combined withcast_const()), or keep theexpectuntil all occurrences are eliminated.
#![expect(
clippy::cast_ptr_alignment,
clippy::cast_sign_loss,
clippy::inline_always,
clippy::missing_errors_doc,
clippy::missing_panics_doc,
clippy::mut_from_ref,
clippy::undocumented_unsafe_blocks,
clippy::unnecessary_safety_comment,
unsafe_op_in_unsafe_fn
)]
Merge activity
|
Continuation of #21210. Replace `ptr as *const T` / `ptr as *mut T` with `ptr.cast_const()` / `ptr.cast_mut()`. This reveals one dodgy `const` to `mut` conversion in `ChunkRawIter`, which I'll address in a later PR.
0a8342d to
433d40b
Compare
f8dca2f to
af3fdeb
Compare

Continuation of #21210.
Replace
ptr as *const T/ptr as *mut Twithptr.cast_const()/ptr.cast_mut(). This reveals one dodgyconsttomutconversion inChunkRawIter, which I'll address in a later PR.