chore(lint): enable clippy::ptr_cast_constness - #71
Open
tupe12334 wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #70
What
Enables the pedantic lint
clippy::ptr_cast_constnessatdenyin[workspace.lints.clippy], and fixes the 10 violations it surfaces.Why
ason raw pointers can change the pointee type, the constness, and the provenance all at once —foo as *const u8reads the same whether it is an innocuousmut -> constadjustment 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
unsafecode at the WASM allocator boundary incore/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 existingdenyconvention), with a comment explaining the rationale. No other lint touched.core/src/wasm.rs: 10 mechanical rewrites ofptr as *const u8toptr.cast_const(), all produced bycargo clippy --fix. No behavioural change.Verification
Run locally on this branch:
cargo clippy --workspace --all-targets— clean, no warningscargo build --workspace— okcargo test --workspace— 236 passed, 0 failedOpened by the moadim routine "Clippy lint improvements → issue + PR (Rust repos) → Slack".