Stream: git-wasmtime

Topic: wasmtime / PR #15159 cranelift-entity: remove unused `get...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 14:48):

b84330808 edited PR #15159:

This removes two methods in cranelift-entity whose unsafe code has no callers left in the workspace:

Motivation: reducing the unsafe surface where the code is dead anyway. There is no bug behind this — the methods were not called, they just carried unsafe contracts for no benefit. This kind of unsafe-reduction is also the class of change covered by Google's Patch Rewards program for OSS-Fuzz projects (Tier 2 hardening), which is part of why I went looking for it.

An earlier version of this PR also added #![forbid(unsafe_code)] to the crate; I removed that again after fitzgen's review, since the crate may legitimately want unsafe in the future.

Testing: cargo test -p cranelift-entity — 59 unit tests and 2 doc tests pass; cargo check -p wasmtime-environ passes.

Open question from the review thread: BoxedSlice itself now has no users and cannot be constructed from outside the crate. I'm happy to remove it in this PR too if the maintainers want that.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 14:48):

b84330808 commented on PR #15159:

Fair question, and sorry for the missing context — I should have written this in the description from the start.

The motivation is honestly pretty modest. I've been looking for places where unsafe can be removed outright rather than justified, and in this crate the only two remaining pieces of unsafe turned out to be methods with no callers: get_raw_mut and PrimaryMap::into_boxed_slice. There's no bug behind it — nothing crashed and nobody hit the get_raw_mut contract in practice; it was dead code carrying an unsafe API for no benefit. For background, this kind of unsafe-reduction is also what Google's Patch Rewards program covers for OSS-Fuzz projects (Tier 2 hardening), which is part of why I went looking — but I'm not attached to landing this for that reason, and if the change isn't useful to you it shouldn't stay open just for that.

On forbid(unsafe_code): you're right, and I don't want to lock the crate against future legitimate uses of unsafe. I've pushed a commit (47f59e9) that drops the #![forbid(unsafe_code)] attribute, so what's left is only the removal of the two unused methods, which bjorn3 already reviewed above. The BoxedSlice question I asked bjorn3 in the thread is still open — happy to fold that removal in here or leave the type in place, whichever you both prefer.

If even the trimmed-down version isn't something you want, please feel free to close this — no hard feelings.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 15:10):

fitzgen commented on PR #15159:

@b84330808 can you clarify whether your interactions here are abiding by the project's AI policy?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 15:26):

b84330808 commented on PR #15159:

Yes, happy to clarify. I'm directing this work myself and I review what goes in before anything is submitted. AI tools are part of my process, but there is no unattended agent acting here — the changes, the description and these replies are mine to answer for, and I can walk through the diff if that's useful (it's a small one: two methods with no callers in the workspace, plus their tests). The missing motivation up front was my oversight; the description has it now.

I also took your point on forbid(unsafe_code) and dropped that part — the PR is just the dead-code removal at this point. If you still judge it not worth the review time, I understand closing it.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:33):

:thumbs_up: cfallin submitted PR review:

The DCE seems fine to me; this is very old code that probably was written as a generic data structure library before most of Cranelift+Wasmtime grew up around it and solidified our usage patterns.

Agreed with Nick that we don't want to forbid unsafe code; passively reducing it (if free) is always great though.

Just one nit below re: formatting. Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:33):

:speech_balloon: cfallin created PR review comment:

stray blank line inserted here?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:43):

:memo: b84330808 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:43):

:speech_balloon: b84330808 created PR review comment:

Fixed in 860dab5f2d3c2b9ca5370db7bdf56f8c9840688a — thanks, that was left over from removing the test.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:43):

b84330808 updated PR #15159.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:45):

b84330808 updated PR #15159.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:46):

:memo: b84330808 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:46):

:speech_balloon: b84330808 created PR review comment:

Also ran rustfmt over the crate and fixed a second stray blank line of the same kind at the end of the impl block (e52e0eb). The crate is rustfmt-clean now.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:49):

b84330808 updated PR #15159.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:49):

:memo: b84330808 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 16:49):

:speech_balloon: b84330808 created PR review comment:

Went ahead with this: BoxedSlice is removed entirely in 7ddf5284191699ae98c59a8a69ba552b663b2a5d. After into_boxed_slice was deleted, BoxedSlice::new had no callers left, and CI (which builds with -D warnings) failed on the dead code, cascading into the dependent check and test jobs, so keeping the type was not viable. Locally, cargo check -p cranelift-entity --all-targets with -D warnings is clean, the tests pass (52 + 2; the seven dropped tests were BoxedSlice's own), and the crate is rustfmt-clean. Happy to restore the type if you would rather keep it.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 18:27):

cfallin commented on PR #15159:

Thanks; it looks like you have another rustfmt error with another stray line.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 18:46):

b84330808 updated PR #15159.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 18:46):

b84330808 commented on PR #15159:

Fixed in b33ef57f57ec4503cf873f2c90aa75d62cd97223 — you were right, there was one more. It was in crates/environ/src/collections/primary_map.rs: a stray blank line before the closing brace of the TryPrimaryMap impl, left over from removing get_raw_mut. My earlier rustfmt pass only covered the cranelift-entity crate, which is how I missed this one. I've now run rustfmt --check over every file this PR touches; they are clean.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 18:52):

cfallin has enabled auto merge for PR #15159.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 18:56):

cfallin added PR #15159 cranelift-entity: remove unused get_raw_mut and into_boxed_slice to the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 21:33):

:check: cfallin merged PR #15159.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 21:33):

cfallin removed PR #15159 cranelift-entity: remove unused get_raw_mut and into_boxed_slice from the merge queue


Last updated: Nov 19 2026 at 20:05 UTC