Repository navigation
Fix subslice offsets when synthesizing the license field - #320
Merged
Jake-Shadle merged 1 commit intoSep 18, 2026
Merged
Conversation
Jake-Shadle
force-pushed
the
fix/314-subslice-offset
branch
from
September 18, 2026 07:25
7fe3cbd to
ab61ce4
Compare
Contributor
Author
|
Thanks for merging this, @Jake-Shadle. Rebasing that subslice-relative insert position was a good reminder of how carefully cargo-about tracks byte offsets so diagnostics keep pointing at the right span. Glad the multibyte CRLF regression test earned its place. Thanks for maintaining such a useful tool for the Rust packaging ecosystem. |
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.
Fixes #314.
The insert position was computed relative to the subslice after the package marker but used to index the full manifest, so it landed five bytes early.
That either panics on a split UTF-8 character or silently corrupts an unrelated value, depending on the manifest.
The fix adds the subslice base back before indexing, and the returned offset still points at the start of the expression.
Two regression tests cover the panic case (multibyte description with CRLF endings) and the silent corruption case, plus a TOML round-trip check.
Note: clippy on a current toolchain reports a pre-existing collapsible_if at src/lib.rs:399, untouched by this change.