-
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
Move if_then_panic
to pedantic
#7718
Comments
Here is another example of the semantic difference between assert and if-panic. If I understand this code, it's checking if the setting requires panicking and then panicking. I don't think assert is appropriate here.
Below are the warning counts I got from testing around 1000 popular crates on crates.io. Just to make precise what I mean by "firing a lot". Warning counts
|
Thanks for the data and the example. I can definitely see how
That is a good and typical use case for |
I ran this lint on a bunch of crates and it's firing a lot.
For readability, it's debatable whether it's recommendations are actually improvements. Especially where there are a lot of args or the condition is complicated.
I also think there is a semantic difference between an assert and if-panic. I see asserts as checking "my code". I'd never use asserts to check user input. I'd like to know if other people share this view.
(There are also bugs in the recommendations but that's not relevant to this issue. I'll log a separate issue for those later.)
The text was updated successfully, but these errors were encountered: