Skip to content
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

chore: multipart suggestions for let_unit_value lint #13754

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scottgerring
Copy link
Contributor

This should address #13099 for the let_unit test.

changelog: [let_unit]: Updated let_unit to use multipart_suggestions where appropriate

@rustbot
Copy link
Collaborator

rustbot commented Nov 29, 2024

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 29, 2024
@scottgerring
Copy link
Contributor Author

Flip1995 has the context of these, so if they have time:

r? flip1995

(But this is still a draft!)

@rustbot rustbot assigned flip1995 and unassigned llogiq Nov 29, 2024
@scottgerring scottgerring reopened this Dec 2, 2024
@scottgerring scottgerring marked this pull request as ready for review December 2, 2024 14:33
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

Great work! Just 2 codestyle comments.

Please also rebase your PR on top of the current master. We changed our CI recently and GitHub isn't good at picking this up on older PRs.

clippy_lints/src/unit_types/let_unit_value.rs Outdated Show resolved Hide resolved
clippy_lints/src/unit_types/let_unit_value.rs Outdated Show resolved Hide resolved
@scottgerring scottgerring force-pushed the chore/fix-let-unit-test branch 2 times, most recently from 36b6b3f to 36e6a98 Compare December 3, 2024 13:18
@scottgerring
Copy link
Contributor Author

scottgerring commented Dec 3, 2024

Hey @flip1995 thanks for the review! I rebased and addressed the resulting dogfooding lints and your own comments, so there's a bit of a delta on top of what you reviewed. Should be good to go, though, I reckon.

I am assuming you squash onto master, but if not, I can clean my commit history up in future 🤣

Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

Thanks! We don't squash on merge. So, yes, please clean up the commit history :)

}

// Emit appropriate diagnostic based on whether there are usages of the let binding
match suggestions.len().cmp(&1) {
Copy link
Member

@flip1995 flip1995 Dec 3, 2024

Choose a reason for hiding this comment

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

That's a bit of overkill 😅 I would suggest to change this to:

if !suggestions.is_empty() {
    let message = if suggestions.len() == 1 {
        "omit the `let` binding"
    } else {
        "omit the `let` binding and replace variable usages with `()`"
    };
    diag.multipart_suggestion(...);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, that's way less awful. Let me clean it up 👍

@scottgerring scottgerring force-pushed the chore/fix-let-unit-test branch from db9276a to a29525a Compare December 3, 2024 14:14
@scottgerring scottgerring force-pushed the chore/fix-let-unit-test branch from a29525a to ec24388 Compare December 3, 2024 14:15
@scottgerring
Copy link
Contributor Author

@flip1995 that should be it! 🙏

@scottgerring
Copy link
Contributor Author

Hey @flip1995 , do you have a chance to have a quick look at this? We're very close to finishing the whole issue!

@flip1995
Copy link
Member

Sorry for not replying. I won't get to review any Clippy PRs until around christmas... I'll reassign

r? clippy

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.

5 participants