Fix generic expressions in error format arguments - #458
Open
sb123sb123 wants to merge 1 commit into
Open
sb123sb123 wants to merge 1 commit into
sb123sb123 wants to merge 1 commit into
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.
Fixes #332
A valid format argument such as
None::<i32>.is_some()was rejected because the parser treated the method-access dot after a generic expression as thiserror's leading field shorthand and dropped it. The parser now only rewrites leading.fieldand.0shorthand when the preceding tokens do not already form an expression.Tests run:
cargo test --test test_issue332— 1 passed.cargo test --test test_display— 29 passed.cargo test --test test_expr— 3 passed.cargo test --tests— passed; stable skipped the repository's nightly-only UI, backtrace, and option tests as configured.cargo test --workspace --exclude thiserror_no_std_test— passed.cargo test --manifest-path tests/no-std/Cargo.toml— passed.cargo test --no-default-features— passed.cargo clippy --tests --workspace -- -Dclippy::all -Dclippy::pedantic— passed.cargo fmt --all -- --check— passed.git diff --cached --check— passed before commit.AI disclosure: This pull request was prepared with AI assistance. The AI agent inspected the repository and contribution policies, screened open issues and pull requests, reproduced issue #332, implemented the narrow fix, added the regression test, and ran the checks listed above.