-
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
reversed_empty_ranges should suggest alternatives for desirably empty ranges #5628
Comments
Hey @djc, TBH I thought the use cases for actually wanting an empty slice would be rare and that it would be more often a developer error (the lint works with constants so it's not necessarily obvious at first sight). So in this case I think an Otherwise the lint could suggest using A third option would be not linting in this case, as it's the less problematic of all the possible problems that the lint tries to warn against. I would go for this if the use case happens to be more common that we thought. I will be glad to work on making the changes whatever the outcome is :) |
Yeah, I feel like the case of two identical literals should probably just be allowed. Adding the suggestion about casting using |
…or` loop. Reading the documentation for the lint, one could expect that the lint works in all cases that `X == Y`. This is false. While the lint was updated, the documentation wasn't. More information about the `N..N` problem in rust-lang#5689 and rust-lang#5628
[#10167] Clarify that the lint only works if x eq. y in a `for` loop. Reading the documentation for the lint, one could expect that the lint works in all cases that `X == Y`. This is false. While the lint was updated, the documentation wasn't. More information about the `N..N` problem in #5689 and #5628 --- Fixes #10167 changelog: [`reversed_empty_ranges`]: Update and clarify documentation
…or` loop. Reading the documentation for the lint, one could expect that the lint works in all cases that `X == Y`. This is false. While the lint was updated, the documentation wasn't. More information about the `N..N` problem in rust-lang#5689 and rust-lang#5628
With clippy 1.45.0-nightly (0aa6751 2020-05-20), I'm getting the following lint:
As ought to be obvious to the reader, these slices are empty on purpose. However, neither the lint itself nor the further information explains a good alternative for empty slices (and some googling also didn't turn up anything so far). In particular,
&[]
doesn't work.The text was updated successfully, but these errors were encountered: