-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Extend unused_io_amount to cover async io. #8179
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @xFrednet (or someone else) soon. Please see the contribution instructions for more information. |
8cf50c3
to
d91559b
Compare
Welcome to Clippy @nmathewson, I've skimmed through your changes. The direction appears to be correct, so don't worry about that. I first want to address your questions before doing a full review. 🙃
I hope this answers some of your questions. Let me know if I can help you in the meantime 🙃 |
Thanks, @xFrednet ! I'll work on the tests, have a look at the Zulip discussion, and see where it goes?
The correct usage would indeed: be In the The story is similar for |
☔ The latest upstream changes (presumably #8196) made this pull request unmergeable. Please resolve the merge conflicts. |
d91559b
to
4f534dd
Compare
I've just pushed a rebased version of the branch, to:
This resolves the issues I'm aware of, but please let me know if there are more. :) |
Based on the discussion on Zulip it seems like I misunderstood how Clippy deals with lints for external crates, meaning that this is reasonable and okay to add to Clippy 👍
Thank you for the explanation, then it should be fine. I'll take a look at the code now 🙃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version looks good to me, I've just added two small comments 🙃. I think it would also be good to reference the async traits in the lint description, maybe by adding the following to the "Why is this bad?" section:
When working with tokio or futures-rs the
AsyncWriteExt
andAsyncReadExt
traits can be used to callwrite_all
,read_exact
respectively.
The PR is still marked as WIP based on the title, are you planning to add more to this @nmathewson? Otherwise, I think we can merge this soon 🙃.
One more thing, Clippy creates its changelogs based on the lint description could you include a changelog line like this:
changelog: [unused_io_amount
] now supports async read and write traits
Clippy helpfully warns about code like this, telling you that you probably meant "write_all": fn say_hi<W:Write>(w: &mut W) { w.write(b"hello").unwrap(); } This patch attempts to extend the lint so it also covers this case: async fn say_hi<W:AsyncWrite>(w: &mut W) { w.write(b"hello").await.unwrap(); } (I've run into this second case several times in my own programming, and so have my coworkers, so unless we're especially accident-prone in this area, it's probably worth addressing?) This patch covers the Async{Read,Write}Ext traits in futures-rs, and in tokio, since both are quite widely used. changelog: [`unused_io_amount`] now supports AsyncReadExt and AsyncWriteExt.
This improves the quality of the genrated output and makes it more in line with other lint messages. changelog: [`unused_io_amount`]: Improve help text
deae1d1
to
b6bcf0c
Compare
Thank you! I've made the requested changes and marked this PR as non-WIP. I'll keep an eye on CI to see if I break anything. |
Looks good to me, and the CI is also happy! 🎉 Thank you very much for the pull request, I hope you also had fun working on it. 🙃 btw: I edited the PR to include the changelog, now everything should merge without a problem 👍 @bors r+ |
📌 Commit b6bcf0c has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Clippy helpfully warns about code like this, telling you that you
probably meant "write_all":
This patch attempts to extend the lint so it also covers this
case:
(I've run into this second case several times in my own programming,
and so have my coworkers, so unless we're especially accident-prone
in this area, it's probably worth addressing?)
Since this is my first attempt at a clippy patch, I've probably
made all kinds of mistakes: please help me fix them? I'd like
to learn more here.
Open questions I have:
unused_async_io_amount? If so, how should I structure their
shared code?
the standard library? I see that "regex" also has lints,
and I figure that "futures" is probably okay too, since it's
an official rust-lang repository.
Thanks for your time!
changelog: [
unused_io_amount
] now supports async read and write traits