fix(manifest): TOML parse errors report filename:line:col#84
Merged
Conversation
Closes #55. `load_manifest` was just wrapping the underlying `toml::de::Error` in `anyhow::Context("Failed to parse manifest: <path>")`. The `toml` crate already carries span information per `toml::de::Error::span()`, but it was being thrown away. Editors couldn't jump to the offending line. Extract the span, convert the byte offset to a 1-based `(line, col)` via a small helper that counts newlines, and format as the editor- standard `<path>:<line>:<col>: <toml message>`. The conversion uses `bytes()` rather than chars for cheap O(n) scanning of the prefix; the result is a UTF-8 *byte* column, which is what most editors and IDE language servers expect for jump-to-position. Test `malformed_manifest_reports_line_and_column` writes a manifest with a broken assignment on line 3 and asserts the error string contains both the manifest path and a `:N:M:` span indicator. `cargo clippy --all-targets -- -D warnings` clean; 43 unit tests pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Per V-L3-H1: TOML parse errors were just wrapped in
anyhow::Context("Failed to parse manifest: <path>"). Thetomlcrate already provides span info viatoml::de::Error::span(); extract it and emitpath:line:col: <toml message>(editor-standard format).Closes
Test plan
cargo clippy --all-targets -- -D warningscleancargo test --lib --bins43/43 (1 new:malformed_manifest_reports_line_and_column):N:M:span