Skip to content

chore(lint): enable clippy::ptr_cast_constness - #71

Open
tupe12334 wants to merge 1 commit into
mainfrom
clippy/enable-ptr_cast_constness
Open

chore(lint): enable clippy::ptr_cast_constness#71
tupe12334 wants to merge 1 commit into
mainfrom
clippy/enable-ptr_cast_constness

Conversation

@tupe12334

Copy link
Copy Markdown
Member

Closes #70

What

Enables the pedantic lint clippy::ptr_cast_constness at deny in [workspace.lints.clippy], and fixes the 10 violations it surfaces.

Why

as on raw pointers can change the pointee type, the constness, and the provenance all at once — foo as *const u8 reads the same whether it is an innocuous mut -> const adjustment or a genuine reinterpretation. pointer::cast_const() is constness-only by construction, so intent is explicit and a later edit that also changes the pointee type stops compiling instead of being silently accepted.

Every hit is inside unsafe code at the WASM allocator boundary in core/src/wasm.rs — exactly the code where an accidental cast is hardest to spot.

Changes

  • Cargo.toml: one lint added (ptr_cast_constness = "deny", matching the existing deny convention), with a comment explaining the rationale. No other lint touched.
  • core/src/wasm.rs: 10 mechanical rewrites of ptr as *const u8 to ptr.cast_const(), all produced by cargo clippy --fix. No behavioural change.

Verification

Run locally on this branch:

  • cargo clippy --workspace --all-targets — clean, no warnings
  • cargo build --workspace — ok
  • cargo test --workspace — 236 passed, 0 failed

Opened by the moadim routine "Clippy lint improvements → issue + PR (Rust repos) → Slack".

Use pointer::cast_const() instead of `as` casts that only change a raw
pointer's constness, so genuine type-changing casts in the WASM FFI
layer are visually distinct from constness adjustments.

Closes #70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable clippy::ptr_cast_constness lint

1 participant