Fix invalid E0609 raw pointer deref suggestion inside macros#158358
Merged
Conversation
Collaborator
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
83b413d to
011ac7a
Compare
Contributor
|
@bors r+ rollup |
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jun 25, 2026
…henkov Fix invalid E0609 raw pointer deref suggestion inside macros Fixes rust-lang#158158 `suggest_first_deref_field` blindly applied span math (`shrink_to_lo()`, `between()`) to generate a dereference suggestion for E0609. When the base expression and field access originate from different macro expansions, the `SyntaxContext` mismatch caused the span combinations to fail. This resulted in the compiler falling back to incorrect source locations and generating malformed replacement strings like `&mut (*).`. * Added a `span.from_expansion()` guard at the top of `suggest_first_deref_field` to check both `base.span` and `field.span`. * Suppressed the multipart suggestion entirely when inside macro expansions to prevent emitting broken syntax, bypassing complex and unreliable cross-macro span traversals. * Added a new UI test to ensure the standard E0609 error is emitted cleanly without the garbled `help:` label.
rust-bors Bot
pushed a commit
that referenced
this pull request
Jun 25, 2026
Rollup of 10 pull requests Successful merges: - #158410 (Update LLVM for Mach-O __LINKEDIT alignment fix.) - #157397 (cmse: clear padding when crossing the secure boundary) - #158036 (Add -Zinstrument-mcount=fentry to -Zinstrument-mcount) - #158330 (llvm: use intrinsics for f16, f32 minimum/maximum) - #158359 (fix(tests): allow either branch direction in ilog_known_base) - #158067 (LLVM 23: Adapt codegen test to moved assume) - #158261 (Move part of the target checking for `#[may_dangle]` to the parser) - #158358 (Fix invalid E0609 raw pointer deref suggestion inside macros) - #158392 (delegation: add tests for defaults and infers in generics) - #158394 (Generate synthetic generic args only for delegation's child segment)
rust-timer
added a commit
that referenced
this pull request
Jun 26, 2026
Rollup merge of #158358 - raushan728:issues/158158, r=petrochenkov Fix invalid E0609 raw pointer deref suggestion inside macros Fixes #158158 `suggest_first_deref_field` blindly applied span math (`shrink_to_lo()`, `between()`) to generate a dereference suggestion for E0609. When the base expression and field access originate from different macro expansions, the `SyntaxContext` mismatch caused the span combinations to fail. This resulted in the compiler falling back to incorrect source locations and generating malformed replacement strings like `&mut (*).`. * Added a `span.from_expansion()` guard at the top of `suggest_first_deref_field` to check both `base.span` and `field.span`. * Suppressed the multipart suggestion entirely when inside macro expansions to prevent emitting broken syntax, bypassing complex and unreliable cross-macro span traversals. * Added a new UI test to ensure the standard E0609 error is emitted cleanly without the garbled `help:` label.
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 #158158
suggest_first_deref_fieldblindly applied span math (shrink_to_lo(),between()) to generate a dereference suggestion for E0609. When the base expression and field access originate from different macro expansions, theSyntaxContextmismatch caused the span combinations to fail. This resulted in the compiler falling back to incorrect source locations and generating malformed replacement strings like&mut (*)..span.from_expansion()guard at the top ofsuggest_first_deref_fieldto check bothbase.spanandfield.span.help:label.