Use u64 internally to track file offsets instead of usize#2573
Draft
WorldSEnder wants to merge 1 commit into
Draft
Use u64 internally to track file offsets instead of usize#2573WorldSEnder wants to merge 1 commit into
WorldSEnder wants to merge 1 commit into
Conversation
This replaces usize in a lot of places. Besides being a technically breaking change, this should not impact functionality. Solves a TODO left long ago in the entry code of parse.
WorldSEnder
force-pushed
the
u64-position
branch
from
July 18, 2026 14:31
45e1141 to
2a6f9db
Compare
Contributor
Author
|
A lot of consumers seem to hold the entire wasm input in memory, hence these need some ergonomics to convert their offsets back to |
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.
This replaces usize in a lot of places. Besides being a breaking change, this should not impact functionality for most users. Tracking file offset with
u64is the more principled choice.Fixes #838
Solves a TODO left long ago in the entry code of parse. Most of the places used
usizeto pass it along to other functions, sinking into Error code for nice error messages, and are thus not sensitive to the data type used. I found two cases that usedusize::MAXas a dummy index in a path that calledexpect()on the eventual error.Everything else ported rather easily. Not quite happy with the abstractions in
offset.rsjust now, and the module needs a few doc comments, everything else should work.This is a work-in-progress as conversion is for now limited to wasmparser, I will check things off as I get to other crates in the repo.