-
Notifications
You must be signed in to change notification settings - Fork 1.8k
rename unchecked_duration_subtraction to unchecked_time_subtraction and check for Duration - Duration
#13800
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
rename unchecked_duration_subtraction to unchecked_time_subtraction and check for Duration - Duration
#13800
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dswij (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
|
@sharksforarms |
722aad6 to
59a03d7
Compare
|
@alex-semenyuk ah! thanks. forgot to rerun uibless. I rebased. |
This comment has been minimized.
This comment has been minimized.
5e59cee to
500c35e
Compare
b615b2d to
5a8f778
Compare
4396486 to
12a7f21
Compare
unchecked_duration_subtraction to check for Duration - Durationunchecked_duration_subtraction to unchecked_time_subtraction and check for Duration - Duration
|
@rustbot ready |
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.
Did the lint get renamed using cargo dev rename_lint? I don't see the expected changes in clippy_lints/src/deprecated_lints.rs and tests/ui/rename.rs.
Also, duration - duration - duration still crashes in tests. Something should be done about it.
This comment has been minimized.
This comment has been minimized.
cfbe1be to
d0874f8
Compare
| error: unchecked subtraction between 'Duration' values | ||
| --> tests/ui/unchecked_time_subtraction_unfixable.rs:12:13 | ||
| | | ||
| LL | let _ = dur1 - dur2 - dur3; | ||
| | ^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: `-D clippy::unchecked-time-subtraction` implied by `-D warnings` | ||
| = help: to override `-D warnings` add `#[allow(clippy::unchecked_time_subtraction)]` | ||
|
|
||
| error: unchecked subtraction between 'Duration' values | ||
| --> tests/ui/unchecked_time_subtraction_unfixable.rs:12:13 | ||
| | | ||
| LL | let _ = dur1 - dur2 - dur3; | ||
| | ^^^^^^^^^^^ help: try: `dur1.checked_sub(dur2).unwrap()` | ||
|
|
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.
made this an "unfixable", not sure if this is the right approach. It's nice to not have a suggestion for the dur - dur - dur, but have some sort of suggestion come after for the nested? is there a precedent for handling this sort of thing?
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.
It's fine to not give a suggestion, but ideally the whole thing would get a single suggestion.
d141105 to
2960444
Compare
|
@rustbot ready |
|
hi reviewers, it's been a while since I touched this. I decided to restart, given the tip on |
|
r? clippy I think @dswij has been busy. |
2960444 to
ed4e369
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Lintcheck changes for f296de4
This comment will be updated if you push new changes |
ed4e369 to
9a6d3e1
Compare
Renames InstantSubtraction to UncheckedTimeSubtraction
9a6d3e1 to
f296de4
Compare
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.
Thank you.
fixes #13734
This PR renames
unchecked_duration_subtractionlint tounchecked_time_subtractionand extends it to includeDuration - Durationoperations. Previously, it was onlyInstant - Duration.Duration - Durationis a common operation which may panic in the same way.Note: This is my first clippy PR, feedback is appreciated.
changelog: [
unchecked_time_subtraction]: renamed fromunchecked_duration_subtraction, extend lint to include subtraction of aDurationwith aDuration