-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Consider operator's span when computing binop expr span #144711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+20
−17
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
rustbot has assigned @petrochenkov. Use |
compiler-errors
commented
Jul 31, 2025
Nice, this is a part of #126763. |
@bors r+ |
bors
added a commit
that referenced
this pull request
Jul 31, 2025
Rollup of 6 pull requests Successful merges: - #144688 (Uniform `enter_trace_span!` and add documentation) - #144702 (stall `ConstArgHasType` in `compute_goal_fast_path`) - #144711 (Consider operator's span when computing binop expr span) - #144712 (Deduplicate `IntTy`/`UintTy`/`FloatTy`.) - #144726 (merge rustc_attr_data_structures into rustc_hir) - #144733 (fix: Match width of ascii and unicode secondary file start) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
that referenced
this pull request
Jul 31, 2025
Rollup merge of #144711 - compiler-errors:op-span, r=petrochenkov Consider operator's span when computing binop expr span When computing the span of a binop consisting of `lhs` and `rhs`, we previously just took the spans of `lhs.span.to(rhs.span)`. In the case that both `lhs` and `rhs` are both arguments to a macro, this can produce a wildly incorrect span. To fix this, first compute the span between `lhs` and the binary operator, which will cause `lhs` to possibly be adjusted to a relevant macro metavar, and then compute that span extended to `rhs`, which will cause it to also be adjusted to a relevant macro metavar. This coincidentally fixes a FIXME in `tests/ui/lint/wide_pointer_comparisons.rs` and suppresses a nonsense suggestion.
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Aug 1, 2025
Rollup of 6 pull requests Successful merges: - rust-lang/rust#144688 (Uniform `enter_trace_span!` and add documentation) - rust-lang/rust#144702 (stall `ConstArgHasType` in `compute_goal_fast_path`) - rust-lang/rust#144711 (Consider operator's span when computing binop expr span) - rust-lang/rust#144712 (Deduplicate `IntTy`/`UintTy`/`FloatTy`.) - rust-lang/rust#144726 (merge rustc_attr_data_structures into rustc_hir) - rust-lang/rust#144733 (fix: Match width of ascii and unicode secondary file start) r? `@ghost` `@rustbot` modify labels: rollup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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.
When computing the span of a binop consisting of
lhs
andrhs
, we previously just took the spans oflhs.span.to(rhs.span)
. In the case that bothlhs
andrhs
are both arguments to a macro, this can produce a wildly incorrect span.To fix this, first compute the span between
lhs
and the binary operator, which will causelhs
to possibly be adjusted to a relevant macro metavar, and then compute that span extended torhs
, which will cause it to also be adjusted to a relevant macro metavar.This coincidentally fixes a FIXME in
tests/ui/lint/wide_pointer_comparisons.rs
and suppresses a nonsense suggestion.