Suppress garbled suggestions from strict provenance lints in macros#156861
Conversation
|
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
|
Reminder, once the PR becomes ready for a review, use |
0e706a1 to
13fae85
Compare
13fae85 to
ccac0d9
Compare
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
…stions, r=mu001999 Suppress garbled suggestions from strict provenance lints in macros 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 `Option` and checks `can_be_used_for_suggestions()` before constructing them. The lint itself still fires, you just don't get the garbled suggestion. Same approach already used in `op.rs` and `static_mut_refs.rs` in this crate. ### What changed - `errors.rs`: `sugg` fields in `LossyProvenanceInt2Ptr` and `LossyProvenancePtr2Int` are now `Option<...>` - `cast.rs`: suggestion construction in both `lossy_provenance_ptr2int_lint` and `fuzzy_provenance_int2ptr_lint` is guarded behind `can_be_used_for_suggestions()` - New regression test confirms both lints fire on casts inside macros, with no suggestion block in output Fixes #156850
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
💔 Test for 04f346b failed: CI. Failed job:
|
|
@bors retry |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 5b686bc (parent) -> 783eb8c (this PR) Test differencesShow 4 test diffsStage 1
Stage 2
Additionally, 2 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 783eb8c8682ddde0807c60ed8293670ef523794f --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (783eb8c): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (primary -4.4%, secondary -7.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -1.8%, secondary 3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 509.684s -> 511.327s (0.32%) |
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