Skip to content

Added identity_assign_op lint - #17038

Open
JaafarTanoukhi wants to merge 12 commits into
rust-lang:masterfrom
JaafarTanoukhi:new-lint-identity-assign-op
Open

JaafarTanoukhi wants to merge 12 commits into
rust-lang:masterfrom
JaafarTanoukhi:new-lint-identity-assign-op

Conversation

@JaafarTanoukhi

Copy link
Copy Markdown

changelog: [identity_assign_op]: new lint

fixes #16977

@rustbot rustbot added needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels May 19, 2026
@rustbot

rustbot commented May 19, 2026

Copy link
Copy Markdown
Collaborator

r? @llogiq

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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, llogiq, samueltardieu

@samueltardieu samueltardieu left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are a few problems with this proposed implementation:

  • Ignoring the statement means removing it, not just replacing it with the LHS expression.
  • Why is there a TODO in the source?
  • User types may implement those operators, and they might not be removable because they can contain side effects.
  • Floating points types are ignored.
  • Even if the snippet cannot be retrieved, the lint is currently marked MachineApplicable which is not true.
  • Tests involving macros should be added.

@rustbot author

View changes since this review

@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 May 20, 2026
@rustbot

rustbot commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@oscargus

Copy link
Copy Markdown
Contributor

In the original issue there was a suggestion to focus on that this may be a bug, rather than that it can be simplified.

@JaafarTanoukhi
JaafarTanoukhi force-pushed the new-lint-identity-assign-op branch from 2a135f9 to 53fc2b2 Compare July 18, 2026 18:49
@rustbot

This comment has been minimized.

@JaafarTanoukhi
JaafarTanoukhi force-pushed the new-lint-identity-assign-op branch from 53fc2b2 to 0112416 Compare July 25, 2026 18:44
@rustbot

This comment has been minimized.

@JaafarTanoukhi
JaafarTanoukhi force-pushed the new-lint-identity-assign-op branch from 0112416 to d340d41 Compare July 25, 2026 21:10
@JaafarTanoukhi

Copy link
Copy Markdown
Author

@rustbot ready

@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 25, 2026
@JaafarTanoukhi

JaafarTanoukhi commented Jul 25, 2026 •

Copy link
Copy Markdown
Author

I’ve also updated this PR so that identity_assign_op does not lint identity assignments that are part of a series of otherwise similar assignment operations, as discussed in #13813.

If this approach looks good, I can follow up with a separate PR applying the same logic to identity_op.

@rustbot

This comment has been minimized.

@rustbot

rustbot commented Aug 14, 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.

@rustbot

rustbot commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/rust-clippy.git master
    $ git push --force-with-lease
    

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Aug 14, 2026
@rustbot

rustbot commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #17607) made this pull request unmergeable. Please resolve the merge conflicts.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has-merge-commits PR has merge commits, merge with caution. needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) 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.

Detect assignment operators that do nothing (e.g. += 0)

5 participants