Skip to content

Fix ICE in upper_case_acronyms #12903

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
Jun 17, 2024
Merged

Fix ICE in upper_case_acronyms #12903

merged 1 commit into from
Jun 17, 2024

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented Jun 8, 2024

fixes #12284

The logic has been rewritten to avoid allocations. The old version allocated multiple vecs and strings for each identifier. The new logic allocates a single string only when the lint triggers.

This also no longer lints on strings which don't start with an uppercase letter (e.g. something_FOO).

changelog: none

@rustbot
Copy link
Collaborator

rustbot commented Jun 8, 2024

r? @y21

rustbot has assigned @y21.
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 8, 2024
@Jarcho Jarcho changed the title Fix ICE in upper_case_acronyms and remove most of the string alloc… Fix ICE in upper_case_acronyms Jun 8, 2024
for c in s.chars() {
if c.is_ascii_uppercase() {
count += 1;
if count == 3 {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we check for 3 here (but then 2 in the tail expression)? Doesn't this mean that we won't warn on AB3 or ABc?
The documentation makes it sound like that we want to emit a warning there

Triggers if there is more than one uppercase char next to each other

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, the old logic doesn't really seem to follow that very strictly either. The old logic does catch AB3 but not ABc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because something like AFoo shouldn't lint, but AS should. It really shouldn't check the case for the third letter, but the old logic didn't handle that properly either.

Copy link
Member

@y21 y21 left a comment

Choose a reason for hiding this comment

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

Sorry for taking so long. This looks good to me. I also find this rewrite a lot easier to understand

Not sure if this is ready or you're planning to change something, but r=me if it is

@Jarcho
Copy link
Contributor Author

Jarcho commented Jun 17, 2024

The triple reverse the old one did was definitely fun to follow.

@bors r=@y21

@bors
Copy link
Contributor

bors commented Jun 17, 2024

📌 Commit 059eaf1 has been approved by y21

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jun 17, 2024

⌛ Testing commit 059eaf1 with merge 0625183...

@bors
Copy link
Contributor

bors commented Jun 17, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: y21
Pushing 0625183 to master...

@bors bors merged commit 0625183 into rust-lang:master Jun 17, 2024
5 checks passed
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.

ice: upper case acronyms, unnamed_fields
4 participants