Skip to content

Fix: enum prefix/suffix matching lint should not fire when variant has the same name as the container type#16896

Open
lynzrand wants to merge 3 commits intorust-lang:masterfrom
lynzrand:rynco/variant-name-matches
Open

Fix: enum prefix/suffix matching lint should not fire when variant has the same name as the container type#16896
lynzrand wants to merge 3 commits intorust-lang:masterfrom
lynzrand:rynco/variant-name-matches

Conversation

@lynzrand
Copy link
Copy Markdown

@lynzrand lynzrand commented Apr 21, 2026

Fixes #16895

This PR fixes the issue where enum variant prefix/suffix matches container type is fired, when the variant have exactly the same name as the container type.

Changes TL;DR: Moved the prefix/suffix checking functions into the ItemNameRepetetions type and added a check that asserts non-equality between the variant name and container name.

Note: The issue hasn't been triaged when this PR was submitted. Feel free to close it if it's a false-false-positive.


Please write a short comment explaining your change (or "none" for internal only changes)

changelog: [enum_variant_names] no longer fires when the enum variant name equals the container name

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 21, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 21, 2026

r? @dswij

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

@github-actions
Copy link
Copy Markdown

Lintcheck changes for 038dbe3

Lint Added Removed Changed
clippy::enum_variant_names 0 2 2

This comment will be updated if you push new changes

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

Labels

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.

enum_variant_names warns on enum variants with the same name as the type

3 participants