Skip to content

refactor(allocator): fix ptr_cast_constness clippy warnings#21222

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/04-08-refactor_allocator_fix_ptr_cast_constness_clippy_warnings
Apr 9, 2026
Merged

refactor(allocator): fix ptr_cast_constness clippy warnings#21222
graphite-app[bot] merged 1 commit intomainfrom
om/04-08-refactor_allocator_fix_ptr_cast_constness_clippy_warnings

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Apr 9, 2026

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.

Copy link
Copy Markdown
Member Author

overlookmotel commented Apr 9, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 9, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/04-08-refactor_allocator_fix_ptr_cast_constness_clippy_warnings (af3fdeb) with om/04-08-refactor_allocator_fix_ptr_as_ptr_clippy_warnings (433d40b)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@overlookmotel overlookmotel marked this pull request as ready for review April 9, 2026 08:32
Copilot AI review requested due to automatic review settings April 9, 2026 08:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_constness from the file-level #![expect(...)] list.
  • Replaced as *const u8 casts in ChunkFooter::as_raw_parts() with cast_const().
  • Replaced one as *mut u8 cast in ChunkRawIter with cast_mut().
Comments suppressed due to low confidence (1)

crates/oxc_allocator/src/bump.rs:16

  • clippy::ptr_cast_constness was removed from the #![expect(...)] list, but there is still at least one raw-pointer as *const ... cast in this file (ChunkIter::next uses ptr as *const mem::MaybeUninit<u8>). If ptr_cast_constness is 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 with cast_const()), or keep the expect until 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
)]

Comment thread crates/oxc_allocator/src/bump.rs
@overlookmotel overlookmotel self-assigned this Apr 9, 2026
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Apr 9, 2026

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.
@graphite-app graphite-app Bot force-pushed the om/04-08-refactor_allocator_fix_ptr_as_ptr_clippy_warnings branch from 0a8342d to 433d40b Compare April 9, 2026 08:51
@graphite-app graphite-app Bot force-pushed the om/04-08-refactor_allocator_fix_ptr_cast_constness_clippy_warnings branch from f8dca2f to af3fdeb Compare April 9, 2026 08:52
Base automatically changed from om/04-08-refactor_allocator_fix_ptr_as_ptr_clippy_warnings to main April 9, 2026 09:14
@graphite-app graphite-app Bot merged commit af3fdeb into main Apr 9, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-allocator Area - Allocator C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants