-
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
New lint against let $pat: _ = $expr;
#10463
Comments
@rustbot claim |
Interesting.. |
Here's one. Unboxed futures are undoubtedly good for performance compared to boxed futures; but they can have gigantic names when they are generated with combinators rather than async/await notation. You'd think that that isn't a problem because you don't have to look at the name, just await it immediately, use the compiler and/or rust-analyzer to identify the Output type and work from there. Unfortunately, sometimes a Future's definition is lengthy enough and its use-site complicated enough, that it becomes best for the Future itself to be named-out into a rust-analyzer has a helpful feature where it will place an inlay on any unhinted Without an underscore hint: Versus with it: I was very surprised to discover that there are people who actually write |
What it does
Generalizing from #10441 -- a new lint for this would supersede that issue, which was originally reported as a false negative against the existing let_underscore_untyped lint.
In this GitHub search (not sure how stable the URL is -- it's a search for
/let [a-zA-Z0-9_]+: _ =( |$)/ language:rust
) I noticed a surprisingly large amount of code doing:There are 610 search results. From skimming about a dozen of them, I couldn't identify any reason that the code would need to be written in this way. It is universally equivalent to:
and it would be helpful for Clippy to guide newbies in this preferred direction.
Lint Name
let_with_type_underscore
Category
complexity
Advantage
Reduced line noise.
: _
provides zero clarity or utility.Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: