-
Notifications
You must be signed in to change notification settings - Fork 1.6k
unnecessary call to max function #11901
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
Comments
I would like to contribute in this issue if you don't mind. |
Yeah feel free to do so. |
I pushed the wrong button and I don’t know how to fix it. |
@rustbot claim |
@FelixMaetzler so you meant to say that when you run the lint on
it changes to
Am I going in the right direction? |
Or do you mean that when someone runs
should give an error/warning? |
It should probably warn on |
yes exactly that. like @y21 said, you could generalize that to In my opinion this should give a similar/same cargo clippy output like following: let b = 12 + 0;
dbg!(b); |
Gotcha! |
@rustbot claim |
Hi @lightlessdays, are you still working on this? Would you mind if I claim it? |
Hey, I am sorry, I got busy with my university exams. Well... You can claim it I suppose. Really sorry about ghosting this issue. @vohoanglong0107 |
Thanks @lightlessdays. Then I will start working on this @rustbot claim |
What it does
In todays AdventOfCode i caught myself using the below example.
The
max()
call of an unsigned number with 0 is unnecessary.It would be nice if clippy would say something about that.
the maximum between 0 and an unsigned number is always the number.
Please let me know if i did anything wrong.
Have a nice day.
Advantage
Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: