Skip to content

Extend useless_asref lint on map(clone) #12105

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 7 commits into from
Jan 10, 2024

Conversation

GuillaumeGomez
Copy link
Member

If you have code like:

Some(String::new()).as_ref().map(Clone::clone)

the as_ref call is unneeded.

Interestingly enough, this lint and map_clone are starting to share a same "space" where both lints warn about different things for the same code. Not sure what's the policy about such cases though...

r? @llogiq

changelog: Extend useless_asref lint on map(clone)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 6, 2024
@GuillaumeGomez GuillaumeGomez force-pushed the useless-asf-extension branch 2 times, most recently from b26362a to f92809b Compare January 6, 2024 20:38
@GuillaumeGomez
Copy link
Member Author

And fixed dogfood failure. I forget this one every time...

@llogiq
Copy link
Contributor

llogiq commented Jan 6, 2024

Not sure what's the policy about such cases though...

As long as the lints work independently of each other and don't invalidate each other's diagnostics (and especially suggestions), they can easily coexist. Otherwise (if one lint rules out the other) we must decide which one is preferable and remove those cases from the other lint.

@GuillaumeGomez
Copy link
Member Author

Ok so in this case I'll limit the map_clone lint so it doesn't overlap in here.

@bors
Copy link
Contributor

bors commented Jan 7, 2024

☔ The latest upstream changes (presumably #12109) made this pull request unmergeable. Please resolve the merge conflicts.

@llogiq
Copy link
Contributor

llogiq commented Jan 10, 2024

Thank you. Stellar work, you're on a roll!

@bors r+

@bors
Copy link
Contributor

bors commented Jan 10, 2024

📌 Commit f7ef9a6 has been approved by llogiq

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 10, 2024

⌛ Testing commit f7ef9a6 with merge e899684...

@bors
Copy link
Contributor

bors commented Jan 10, 2024

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

@bors bors merged commit e899684 into rust-lang:master Jan 10, 2024
@GuillaumeGomez GuillaumeGomez deleted the useless-asf-extension branch January 10, 2024 09:35
@GuillaumeGomez
Copy link
Member Author

Thanks for the kind words and the blazing fast reviews! 😊

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.

4 participants