Skip to content

Ignore imported items in min_ident_chars #12285

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

Merged
merged 1 commit into from
Feb 14, 2024
Merged

Conversation

Ethiraric
Copy link
Contributor

@Ethiraric Ethiraric commented Feb 12, 2024

Suppress the min_ident_chars warning for items whose name we cannot control. Do not warn for use a::b, but warn for use a::b as c, since c is a local identifier.

Fixes #12232


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

changelog: [min_ident_chars]: Do not warn on non-local identifiers

@rustbot
Copy link
Collaborator

rustbot commented Feb 12, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dswij (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 12, 2024
|
LL | use extern_types::Aaa;
| ^^^
LL | use extern_types::{Aaa, N as W};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were 2 distinct changes which that diff does poorly reflect:

  • I started by making sure that use extern_types::Aaa does not trigger the warning
  • I added another identifier with an alias, to make sure the alias triggers the warning

Copy link
Member

@dswij dswij left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM, just a small request. I think it's good to merge after.

@@ -3,7 +3,7 @@
#![warn(clippy::min_ident_chars)]
Copy link
Member

Choose a reason for hiding this comment

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

Can you also help add a positive and negative case for const in the test?

@Ethiraric
Copy link
Contributor Author

Thanks for your review!

I was unsure about where the consts should be, so I added 2 const variables (one that triggers the warning, and one that doesn't) in the main file, as well as 2 other in the extern_types that are imported in the main file (none trigger the warning).

Suppress the `min_ident_chars` warning for items whose name we cannot
control. Do not warn for `use a::b`, but warn for `use a::b as c`, since
`c` is a local identifier.

Fixes rust-lang#12232
@Ethiraric
Copy link
Contributor Author

That last force-push fixes only 2 typos in the comments.

Copy link
Member

@dswij dswij left a comment

Choose a reason for hiding this comment

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

Thanks, the test cases look great :)

@dswij
Copy link
Member

dswij commented Feb 14, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Feb 14, 2024

📌 Commit c1c2c3e has been approved by dswij

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Feb 14, 2024

⌛ Testing commit c1c2c3e with merge 2c3213f...

@bors
Copy link
Contributor

bors commented Feb 14, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: dswij
Pushing 2c3213f to master...

@bors bors merged commit 2c3213f into rust-lang:master Feb 14, 2024
@Ethiraric Ethiraric deleted the fix-8573 branch February 25, 2024 22:04
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.

min_ident_chars triggers on imported identifiers, even from the standard library
4 participants