Skip to content

move unnecessary_get_then_check to complexity#16998

Merged
Jarcho merged 1 commit into
rust-lang:masterfrom
ChrisJr404:recategorize-unnecessary-get-then-check-as-complexity
May 21, 2026
Merged

move unnecessary_get_then_check to complexity#16998
Jarcho merged 1 commit into
rust-lang:masterfrom
ChrisJr404:recategorize-unnecessary-get-then-check-as-complexity

Conversation

@ChrisJr404

@ChrisJr404 ChrisJr404 commented May 11, 2026

Copy link
Copy Markdown
Contributor

The lint fires on .get(...).is_some() (or .is_none()) against HashSet/BTreeSet/HashMap/BTreeMap and suggests .contains() / .contains_key(). The two forms are semantically equivalent and the suggestion is purely a readability/shortness refactor, so complexity reads as a better fit than suspicious per the descriptions in the clippy book:

  • suspicious — "code that is most likely wrong or useless"
  • complexity — "suggestions on how to simplify your code... in a shorter and more readable way, while preserving the semantics"

#16302 made the same kind of move for multiple_bound_locations (suspicious -> style) with similar reasoning, so there is precedent for adjusting a lint's category when it no longer matches the original placement.

Happy to drop this if the team prefers to keep it in suspicious; the issue reporter raised the case and the category boundary is a judgement call.

Fixes #16990.

changelog: move unnecessary_get_then_check lint to complexity group

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 11, 2026
@rustbot

rustbot commented May 11, 2026

Copy link
Copy Markdown
Collaborator

r? @Jarcho

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

@rustbot

This comment has been minimized.

The lint suggests replacing `.get(...).is_some()` (or `.is_none()`) on
`HashSet`/`BTreeSet`/`HashMap`/`BTreeMap` with `.contains()` /
`.contains_key()`. That is a readability/shortness refactor with
identical semantics, which matches the `complexity` category
("suggestions on how to simplify your code... in a shorter and more
readable way, while preserving the semantics") more closely than
`suspicious` ("code that is most likely wrong or useless").

changelog: move `unnecessary_get_then_check` lint to `complexity` group

Signed-off-by: ChrisJr404 <chris@hacknow.com>
@ChrisJr404 ChrisJr404 force-pushed the recategorize-unnecessary-get-then-check-as-complexity branch from 9468853 to 34b9d99 Compare May 12, 2026 13:27
@Jarcho

Jarcho commented May 12, 2026

Copy link
Copy Markdown
Contributor

@rustbot label lint-nominated

I'll start an FCP for this, but I also don't understand the category selection for this one. Ping @GuillaumeGomez since you added the lint.

@rustbot rustbot added the lint-nominated Create an FCP-thread on Zulip for this PR label May 12, 2026
@rustbot

rustbot commented May 12, 2026

Copy link
Copy Markdown
Collaborator

This lint has been nominated for inclusion.

A FCP topic has been created on Zulip.

@GuillaumeGomez

Copy link
Copy Markdown
Member

complexity seems like a better fit indeed.

@Jarcho Jarcho 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.

@Jarcho Jarcho added this pull request to the merge queue May 21, 2026
Merged via the queue into rust-lang:master with commit 002aeaa May 21, 2026
11 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 21, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unnecessary_get_then_check miscategorised as "suspicious", should be "complexity"

4 participants