Suppress garbled suggestions from strict provenance lints in macros#156861
Open
Dnreikronos wants to merge 1 commit into
Open
Suppress garbled suggestions from strict provenance lints in macros#156861Dnreikronos wants to merge 1 commit into
Dnreikronos wants to merge 1 commit into
Conversation
Collaborator
|
r? @TaKO8Ki rustbot has assigned @TaKO8Ki. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
46ace1f to
2afd8d3
Compare
mu001999
requested changes
May 24, 2026
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
0e706a1 to
13fae85
Compare
mu001999
reviewed
May 24, 2026
13fae85 to
ccac0d9
Compare
Author
|
@rustbot ready |
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.
The strict provenance lints (
lossy_provenance_casts,fuzzy_provenance_casts) build suggestions using span arithmetic (shrink_to_lo(),shrink_to_hi(),.to()). When the cast sits inside a macro, those span operations produce broken output like$e as ).addr()because the spans don't map cleanly back to source text.The fix wraps suggestion fields in
Optionand checkscan_be_used_for_suggestions()before constructing them. The lint itself still fires, you just don't get the garbled suggestion. Same approach already used inop.rsandstatic_mut_refs.rsin this crate.What changed
errors.rs:suggfields inLossyProvenanceInt2PtrandLossyProvenancePtr2Intare nowOption<...>cast.rs: suggestion construction in bothlossy_provenance_ptr2int_lintandfuzzy_provenance_int2ptr_lintis guarded behindcan_be_used_for_suggestions()Fixes #156850