Scanner doc & correctness cleanups#7
Open
killerra wants to merge 3 commits into
Open
Conversation
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.
Follow-up tidy-up after the merged scanner work. Five low-risk items — four documentation clarifications and one small defensive correctness fix. No behaviour change on any real binary.
Changes
docs(pattern): clarify
Skip(0)and alternation capture semanticsSkip(0)is the pelite-style "skip one pointer width" convention (resolved at scan time via the view's pointer size; target-dependent, not zero) and that the parser never emits it, so it's only reachable when building atoms programmatically.Case/Break) capture semantics: a slot written only by an abandoned arm is rolled back to its initial value, so the save array does not tell you which arm matched — use a distinct per-armSaveslot to disambiguate.docs(scanner):
finds_preparedguidance + scratch borrow notefinds_codethat it re-analyses the pattern each call, and that repeated uniqueness scans shouldprepare_patternonce and usefinds_prepared/finds_prepared_with.scratchinexec_backtracking(work_savevs.calls/save_log/stack), so a future refactor doesn't route those fields through a&mut selfmethod and break the borrow check.fix(scanner): terminate match iteration on cursor overflow
Matches::nextadvancedcursorwithchecked_add(1)and, on theu64::MAXboundary, leftcursor = None, which restarts (and re-yields) the span. It now advances to the next range instead, matching the finds path's clean termination. This is unreachable with consistent views (mapped.len() == file.len()caps any match offset atu64::MAX - 1) and only matters for adversarial/synthetic views, so it's a defensive guard.Verification
cargo test --workspace --all-targets --all-features+cargo test --workspace --doc— green.cargo clippy --workspace --all-targets --all-features -- -D warnings -D clippy::allclean.cargo fmt --all -- --checkclean.