Skip to content

Consider operator's span when computing binop expr span - #144711

Merged
bors merged 1 commit into
rust-lang:masterfrom
compiler-errors:op-span
Jul 31, 2025
Merged

Consider operator's span when computing binop expr span#144711
bors merged 1 commit into
rust-lang:masterfrom
compiler-errors:op-span

Conversation

@compiler-errors

Copy link
Copy Markdown
Contributor

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.

@rustbot

Copy link
Copy Markdown
Collaborator

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 31, 2025
Comment threadtests/ui/lint/wide_pointer_comparisons.stderr
@petrochenkov

Copy link
Copy Markdown
Contributor

Nice, this is a part of #126763.

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jul 31, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 51cd9b5 has been approved by petrochenkov

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 31, 2025
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
@bors
bors merged commit edd2574 into rust-lang:masterJul 31, 2025
10 checks passed
@rustbotrustbot added this to the 1.90.0 milestone Jul 31, 2025
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-actionsBot 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
rust-cloud-vmsBot pushed a commit to makai410/rustc_public that referenced this pull request Aug 16, 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
rust-cloud-vmsBot pushed a commit to makai410/rustc_public that referenced this pull request Aug 20, 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
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 10, 2025
…zelmann
Rollup of 6 pull requests
Successful merges:
- rust-lang#144688 (Uniform `enter_trace_span!` and add documentation)
- rust-lang#144702 (stall `ConstArgHasType` in `compute_goal_fast_path`)
- rust-lang#144711 (Consider operator's span when computing binop expr span)
- rust-lang#144712 (Deduplicate `IntTy`/`UintTy`/`FloatTy`.)
- rust-lang#144726 (merge rustc_attr_data_structures into rustc_hir)
- rust-lang#144733 (fix: Match width of ascii and unicode secondary file start)
r? `@ghost`
`@rustbot` modify labels: rollup
Kobzol pushed a commit to Kobzol/rustc_codegen_gcc that referenced this pull request Dec 21, 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
makai410 pushed a commit to makai410/rust that referenced this pull request Aug 31, 2026
…zelmann
Rollup of 6 pull requests
Successful merges:
- rust-lang#144688 (Uniform `enter_trace_span!` and add documentation)
- rust-lang#144702 (stall `ConstArgHasType` in `compute_goal_fast_path`)
- rust-lang#144711 (Consider operator's span when computing binop expr span)
- rust-lang#144712 (Deduplicate `IntTy`/`UintTy`/`FloatTy`.)
- rust-lang#144726 (merge rustc_attr_data_structures into rustc_hir)
- rust-lang#144733 (fix: Match width of ascii and unicode secondary file start)
r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@compiler-errors@rustbot@petrochenkov@bors