Skip to content

add span to struct pattern rest (..) #145783

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Erk-
Copy link
Contributor

@Erk- Erk- commented Aug 23, 2025

Struct pattern rest (..) did not retain span information compared to normal fields. This patch adds span information for it.

The motivation of this patch comes from when I implemented this PR for Clippy: rust-lang/rust-clippy#15000 (comment)

It is possible to get the span of the Et cetera in a bit roundabout way, but I thought this would be nicer.

@rustbot
Copy link
Collaborator

rustbot commented Aug 23, 2025

r? @spastorino

rustbot has assigned @spastorino.
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

@rustbot
Copy link
Collaborator

rustbot commented Aug 23, 2025

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

@rustbot rustbot 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. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. labels Aug 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 23, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Aug 23, 2025
@samueltardieu
Copy link
Member

It looks like this might be good for consistency, but the span doesn't seem to be used anywhere (except through .is_some() or .is_none()). A timer run would be useful to see how the 11%/17% size increase of Pat/PatKind affects performances.

@y21
Copy link
Member

y21 commented Aug 23, 2025

I assume this is "needed" for rust-lang/rust-clippy#15000 (comment)? Would probably be useful to put this in the PR body for context/motivation if that's the case

@Erk-
Copy link
Contributor Author

Erk- commented Aug 23, 2025

I assume this is "needed" for rust-lang/rust-clippy#15000 (comment)? Would probably be useful to put this in the PR body for context/motivation if that's the case

Yeah that was my main motivation, looking throught the changes I made here I can at least spot one other location in Clippy where it could be useful to make better lints (rest_pat_in_fully_bound_structs).

I will add the motivation to the main body above as well.

@compiler-errors
Copy link
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 23, 2025
add span to struct pattern rest (..)
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 23, 2025
@rust-bors
Copy link

rust-bors bot commented Aug 23, 2025

☀️ Try build successful (CI)
Build commit: bb08434 (bb0843444108618334e794c7f681dc2bd1bf208f, parent: 6d6a08cf590ec26296447b8d2cf2329bb64c303a)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bb08434): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 1.3%, secondary 1.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.3% [1.2%, 1.4%] 2
Regressions ❌
(secondary)
2.4% [2.0%, 2.8%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.9% [-0.9%, -0.9%] 1
All ❌✅ (primary) 1.3% [1.2%, 1.4%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 468.355s -> 466.756s (-0.34%)
Artifact size: 378.17 MiB -> 378.15 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 23, 2025
@compiler-errors
Copy link
Member

Please squash into one commit

@compiler-errors
Copy link
Member

I'm fine with adding this new span to the AST + HIR. The size changes don't look significant.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 24, 2025

📌 Commit 03ab224 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors 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 Aug 24, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 24, 2025
…rors

add span to struct pattern rest (..)

Struct pattern rest (`..`) did not retain span information compared to normal fields. This patch adds span information for it.

The motivation of this patch comes from when I implemented this PR for Clippy: rust-lang/rust-clippy#15000 (comment)

It is possible to get the span of the Et cetera in a bit roundabout way, but I thought this would be nicer.
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 24, 2025
…rors

add span to struct pattern rest (..)

Struct pattern rest (`..`) did not retain span information compared to normal fields. This patch adds span information for it.

The motivation of this patch comes from when I implemented this PR for Clippy: rust-lang/rust-clippy#15000 (comment)

It is possible to get the span of the Et cetera in a bit roundabout way, but I thought this would be nicer.
bors added a commit that referenced this pull request Aug 24, 2025
Rollup of 6 pull requests

Successful merges:

 - #135761 (Dial down detail of B-tree description)
 - #144373 (remove deprecated Error::description in impls)
 - #145620 (Account for impossible bounds making seemingly unsatisfyable dyn-to-dyn casts)
 - #145783 (add span to struct pattern rest (..))
 - #145817 (cg_llvm: Replace the `llvm::Bool` typedef with a proper newtype)
 - #145820 (raw-dylib-elf: set correct `DT_VERDEFNUM`)

r? `@ghost`
`@rustbot` modify labels: rollup
@jhpratt
Copy link
Member

jhpratt commented Aug 24, 2025

@bors r- #145831 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 25, 2025

Changes to the size of AST and/or HIR nodes.

cc @nnethercote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.