Skip to content

add new lints: rest_pattern_accessible_field and unnecessary_rest_pattern#15000

Open
Erk- wants to merge 21 commits into
rust-lang:masterfrom
Erk-:lint/rest_when_destructuring_struct
Open

add new lints: rest_pattern_accessible_field and unnecessary_rest_pattern#15000
Erk- wants to merge 21 commits into
rust-lang:masterfrom
Erk-:lint/rest_when_destructuring_struct

Conversation

@Erk-

@Erk- Erk- commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

View all comments

Add a new lint that warns when using a rest pattern when destructuring a struct. This lint was requested in this comment #10666 (comment) by @xxchan.

changelog: [rest_pattern_accessible_field] new lint
changelog: [unnecessary_rest_pattern] new lint

@rustbot

rustbot commented Jun 6, 2025

Copy link
Copy Markdown
Collaborator

r? @Alexendoo

rustbot has assigned @Alexendoo.
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 rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 6, 2025
@Erk- Erk- force-pushed the lint/rest_when_destructuring_struct branch from 1504461 to 4cdbec3 Compare June 6, 2025 12:47
Comment thread clippy_lints/src/rest_when_destructuring_struct.rs Outdated
Comment thread clippy_lints/src/rest_when_destructuring_struct.rs Outdated
@Erk- Erk- requested a review from Centri3 June 14, 2025 10:20
@Erk- Erk- force-pushed the lint/rest_when_destructuring_struct branch from 72913a1 to a314686 Compare August 17, 2025 15:09
@github-actions

github-actions Bot commented Aug 17, 2025

Copy link
Copy Markdown

Lintcheck changes for fa7fe29

Lint Added Removed Changed
clippy::rest_pattern_accessible_field 773 0 0
clippy::unnecessary_rest_pattern 18 0 0

This comment will be updated if you push new changes

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.
fmease added a commit to fmease/rust that referenced this pull request Sep 1, 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 Sep 2, 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.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 2, 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.
rust-timer added a commit to rust-lang/rust that referenced this pull request Sep 2, 2025
Rollup merge of #145783 - Erk-:et-cetera-span, r=compiler-errors

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.
github-actions Bot pushed a commit to rust-lang/miri that referenced this pull request Sep 3, 2025
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.
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Sep 4, 2025
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#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.
mohe2015 pushed a commit to tucan-plus/rustfmt that referenced this pull request Sep 6, 2025
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.
@rustbot

This comment has been minimized.

@Erk- Erk- force-pushed the lint/rest_when_destructuring_struct branch from 6868cd5 to b52ea0e Compare September 10, 2025 04:47
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@Erk- Erk- force-pushed the lint/rest_when_destructuring_struct branch from b52ea0e to 45d2dfa Compare October 7, 2025 20:36
@rustbot

This comment has been minimized.

Comment thread clippy_lints/src/rest_when_destructuring_struct.rs Outdated
Comment thread clippy_lints/src/rest_when_destructuring_struct.rs Outdated
Comment thread clippy_lints/src/rest_when_destructuring_struct.rs Outdated
Comment thread clippy_utils/src/check_proc_macro.rs Outdated
Comment thread clippy_utils/src/check_proc_macro.rs Outdated
Comment thread clippy_utils/src/check_proc_macro.rs Outdated
Comment thread clippy_utils/src/check_proc_macro.rs Outdated
Comment thread clippy_utils/src/check_proc_macro.rs Outdated
Comment thread tests/ui/rest_when_destructuring_struct.rs Outdated
Comment thread tests/ui/rest_when_destructuring_struct.rs Outdated
Comment thread tests/ui/rest_when_destructuring_struct.stderr Outdated
Comment thread tests/ui/rest_when_destructuring_struct.stderr Outdated
Comment thread clippy_lints/src/rest_when_destructuring_struct.rs Outdated
Comment thread clippy_lints/src/rest_when_destructuring_struct.rs Outdated
@rustbot rustbot added the needs-fcp PRs that add, remove, or rename lints and need an FCP label Oct 12, 2025

@ada4a ada4a left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the messages be a bit more specific really goes a long way!

Some final touches, and then it should be good to go^^

View changes since this review

Comment thread clippy_lints/src/rest_when_destructuring_struct.rs Outdated
Comment thread clippy_utils/src/check_proc_macro.rs Outdated
@Erk- Erk- requested a review from Alexendoo October 31, 2025 03:46
@Erk- Erk- force-pushed the lint/rest_when_destructuring_struct branch from 7770ee6 to e7b7c82 Compare November 2, 2025 09:18
Comment thread clippy_lints/src/rest_when_destructuring_struct.rs Outdated
Comment thread clippy_lints/src/rest_when_destructuring_struct.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jul 6, 2026
@Erk- Erk- force-pushed the lint/rest_when_destructuring_struct branch from 21edfe2 to fa7fe29 Compare July 8, 2026 05:33
@rustbot

rustbot commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Erk-

Erk- commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

For some reason GitHub did not give me any notifications for this, but the review should be resolved now.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Jul 8, 2026
@Erk- Erk- requested a review from Jarcho July 8, 2026 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lint-nominated Create an FCP-thread on Zulip for this PR needs-fcp PRs that add, remove, or rename lints and need an FCP S-final-comment-period Status: final comment period it will be merged unless new objections are raised (~1 week) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants