-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: master
Are you sure you want to change the base?
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 - Duration
unchecked_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.
☔ The latest upstream changes (possibly d28d234) made this pull request unmergeable. Please resolve the merge conflicts. |
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?
d0874f8
to
d141105
Compare
Renames InstantSubtraction to UncheckedTimeSubtraction
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 |
fixes #13734
This PR renames
unchecked_duration_subtraction
lint tounchecked_time_subtraction
and extends it to includeDuration - Duration
operations. Previously, it was onlyInstant - Duration
.Duration - Duration
is 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 aDuration
with aDuration