Skip to content

Commit def561a

Browse files
committed
rename unchecked_duration_subtraction -> unchecked_time_subtraction
# Conflicts: # tests/ui/unchecked_time_subtraction.stderr
1 parent 03f4973 commit def561a

File tree

10 files changed

+37
-37
lines changed

10 files changed

+37
-37
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ Released 2023-04-20
994994

995995
* Moved [`uninlined_format_args`] to `pedantic` (Now allow-by-default)
996996
[#10265](https://github.com/rust-lang/rust-clippy/pull/10265)
997-
* Moved [`unchecked_duration_subtraction`] to `pedantic` (Now allow-by-default)
997+
* Moved [`unchecked_time_subtraction`] to `pedantic` (Now allow-by-default)
998998
[#10194](https://github.com/rust-lang/rust-clippy/pull/10194)
999999

10001000
### Enhancements
@@ -1245,7 +1245,7 @@ Released 2023-01-26
12451245
[#9506](https://github.com/rust-lang/rust-clippy/pull/9506)
12461246
* [`unnecessary_safety_doc`]
12471247
[#9822](https://github.com/rust-lang/rust-clippy/pull/9822)
1248-
* [`unchecked_duration_subtraction`]
1248+
* [`unchecked_time_subtraction`]
12491249
[#9570](https://github.com/rust-lang/rust-clippy/pull/9570)
12501250
* [`manual_is_ascii_check`]
12511251
[#9765](https://github.com/rust-lang/rust-clippy/pull/9765)

book/src/lint_configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
804804
* [`transmute_ptr_to_ref`](https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref)
805805
* [`tuple_array_conversions`](https://rust-lang.github.io/rust-clippy/master/index.html#tuple_array_conversions)
806806
* [`type_repetition_in_bounds`](https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds)
807-
* [`unchecked_duration_subtraction`](https://rust-lang.github.io/rust-clippy/master/index.html#unchecked_duration_subtraction)
807+
* [`unchecked_time_subtraction`](https://rust-lang.github.io/rust-clippy/master/index.html#unchecked_time_subtraction)
808808
* [`uninlined_format_args`](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args)
809809
* [`unnecessary_lazy_evaluations`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations)
810810
* [`unnested_or_patterns`](https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns)

clippy_config/src/conf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ define_Conf! {
659659
transmute_ptr_to_ref,
660660
tuple_array_conversions,
661661
type_repetition_in_bounds,
662-
unchecked_duration_subtraction,
662+
unchecked_time_subtraction,
663663
uninlined_format_args,
664664
unnecessary_lazy_evaluations,
665665
unnested_or_patterns,

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
243243
crate::init_numbered_fields::INIT_NUMBERED_FIELDS_INFO,
244244
crate::inline_fn_without_body::INLINE_FN_WITHOUT_BODY_INFO,
245245
crate::instant_subtraction::MANUAL_INSTANT_ELAPSED_INFO,
246-
crate::instant_subtraction::UNCHECKED_DURATION_SUBTRACTION_INFO,
246+
crate::instant_subtraction::UNCHECKED_TIME_SUBTRACTION_INFO,
247247
crate::int_plus_one::INT_PLUS_ONE_INFO,
248248
crate::integer_division_remainder_used::INTEGER_DIVISION_REMAINDER_USED_INFO,
249249
crate::invalid_upcast_comparisons::INVALID_UPCAST_COMPARISONS_INFO,

clippy_lints/src/instant_subtraction.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ declare_clippy_lint! {
6161
/// let time_delta = Duration::from_secs(1).checked_sub(Duration::from_secs(5));
6262
/// ```
6363
#[clippy::version = "1.67.0"]
64-
pub UNCHECKED_DURATION_SUBTRACTION,
64+
pub UNCHECKED_TIME_SUBTRACTION,
6565
pedantic,
6666
"finds unchecked subtraction of a 'Duration' from an 'Instant' or 'Duration'"
6767
}
@@ -78,7 +78,7 @@ impl InstantSubtraction {
7878
}
7979
}
8080

81-
impl_lint_pass!(InstantSubtraction => [MANUAL_INSTANT_ELAPSED, UNCHECKED_DURATION_SUBTRACTION]);
81+
impl_lint_pass!(InstantSubtraction => [MANUAL_INSTANT_ELAPSED, UNCHECKED_TIME_SUBTRACTION]);
8282

8383
impl LateLintPass<'_> for InstantSubtraction {
8484
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) {
@@ -104,7 +104,7 @@ impl LateLintPass<'_> for InstantSubtraction {
104104
&& !expr.span.from_expansion()
105105
&& self.msrv.meets(msrvs::TRY_FROM)
106106
{
107-
print_unchecked_duration_subtraction_sugg(cx, lhs, rhs, expr);
107+
print_unchecked_time_subtraction_sugg(cx, lhs, rhs, expr);
108108
}
109109
}
110110
}
@@ -135,7 +135,7 @@ fn print_manual_instant_elapsed_sugg(cx: &LateContext<'_>, expr: &Expr<'_>, sugg
135135
);
136136
}
137137

138-
fn print_unchecked_duration_subtraction_sugg(
138+
fn print_unchecked_time_subtraction_sugg(
139139
cx: &LateContext<'_>,
140140
left_expr: &Expr<'_>,
141141
right_expr: &Expr<'_>,
@@ -156,7 +156,7 @@ fn print_unchecked_duration_subtraction_sugg(
156156

157157
span_lint_and_sugg(
158158
cx,
159-
UNCHECKED_DURATION_SUBTRACTION,
159+
UNCHECKED_TIME_SUBTRACTION,
160160
expr.span,
161161
format!("unchecked subtraction of 'Duration' from '{left_ty}'"),
162162
"try",

tests/ui/manual_instant_elapsed.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![warn(clippy::manual_instant_elapsed)]
22
#![allow(clippy::unnecessary_operation)]
3-
#![allow(clippy::unchecked_duration_subtraction)]
3+
#![allow(clippy::unchecked_time_subtraction)]
44
#![allow(unused_variables)]
55
#![allow(unused_must_use)]
66

tests/ui/manual_instant_elapsed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![warn(clippy::manual_instant_elapsed)]
22
#![allow(clippy::unnecessary_operation)]
3-
#![allow(clippy::unchecked_duration_subtraction)]
3+
#![allow(clippy::unchecked_time_subtraction)]
44
#![allow(unused_variables)]
55
#![allow(unused_must_use)]
66

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::unchecked_duration_subtraction)]
1+
#![warn(clippy::unchecked_time_subtraction)]
22

33
use std::time::{Duration, Instant};
44

@@ -8,23 +8,23 @@ fn main() {
88
let duration2 = Duration::from_secs(1);
99

1010
let _ = instant.checked_sub(duration).unwrap();
11-
//~^ unchecked_duration_subtraction
11+
//~^ unchecked_time_subtraction
1212

1313
let _ = Instant::now().checked_sub(Duration::from_secs(5)).unwrap();
14-
//~^ unchecked_duration_subtraction
14+
//~^ unchecked_time_subtraction
1515

1616
let _ = instant.checked_sub(Duration::from_secs(5)).unwrap();
17-
//~^ unchecked_duration_subtraction
17+
//~^ unchecked_time_subtraction
1818

1919
let _ = Instant::now().checked_sub(duration).unwrap();
20-
//~^ unchecked_duration_subtraction
20+
//~^ unchecked_time_subtraction
2121

2222
let _ = Duration::from_secs(1).checked_sub(duration).unwrap();
23-
//~^ unchecked_duration_subtraction
23+
//~^ unchecked_time_subtraction
2424

2525
let _ = duration2.checked_sub(duration).unwrap();
26-
//~^ unchecked_duration_subtraction
26+
//~^ unchecked_time_subtraction
2727

2828
let _ = Instant::now().elapsed().checked_sub(duration).unwrap();
29-
//~^ unchecked_duration_subtraction
29+
//~^ unchecked_time_subtraction
3030
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::unchecked_duration_subtraction)]
1+
#![warn(clippy::unchecked_time_subtraction)]
22

33
use std::time::{Duration, Instant};
44

@@ -8,23 +8,23 @@ fn main() {
88
let duration2 = Duration::from_secs(1);
99

1010
let _ = instant - duration;
11-
//~^ unchecked_duration_subtraction
11+
//~^ unchecked_time_subtraction
1212

1313
let _ = Instant::now() - Duration::from_secs(5);
14-
//~^ unchecked_duration_subtraction
14+
//~^ unchecked_time_subtraction
1515

1616
let _ = instant - Duration::from_secs(5);
17-
//~^ unchecked_duration_subtraction
17+
//~^ unchecked_time_subtraction
1818

1919
let _ = Instant::now() - duration;
20-
//~^ unchecked_duration_subtraction
20+
//~^ unchecked_time_subtraction
2121

2222
let _ = Duration::from_secs(1) - duration;
23-
//~^ unchecked_duration_subtraction
23+
//~^ unchecked_time_subtraction
2424

2525
let _ = duration2 - duration;
26-
//~^ unchecked_duration_subtraction
26+
//~^ unchecked_time_subtraction
2727

2828
let _ = Instant::now().elapsed() - duration;
29-
//~^ unchecked_duration_subtraction
29+
//~^ unchecked_time_subtraction
3030
}

tests/ui/unchecked_time_subtraction.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
error: unchecked subtraction of 'Duration' from 'Instant'
2-
--> tests/ui/unchecked_duration_subtraction.rs:10:13
2+
--> tests/ui/unchecked_time_subtraction.rs:10:13
33
|
44
LL | let _ = instant - duration;
55
| ^^^^^^^^^^^^^^^^^^ help: try: `instant.checked_sub(duration).unwrap()`
66
|
7-
= note: `-D clippy::unchecked-duration-subtraction` implied by `-D warnings`
8-
= help: to override `-D warnings` add `#[allow(clippy::unchecked_duration_subtraction)]`
7+
= note: `-D clippy::unchecked-time-subtraction` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::unchecked_time_subtraction)]`
99

1010
error: unchecked subtraction of 'Duration' from 'Instant'
11-
--> tests/ui/unchecked_duration_subtraction.rs:13:13
11+
--> tests/ui/unchecked_time_subtraction.rs:13:13
1212
|
1313
LL | let _ = Instant::now() - Duration::from_secs(5);
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(Duration::from_secs(5)).unwrap()`
1515

1616
error: unchecked subtraction of 'Duration' from 'Instant'
17-
--> tests/ui/unchecked_duration_subtraction.rs:16:13
17+
--> tests/ui/unchecked_time_subtraction.rs:16:13
1818
|
1919
LL | let _ = instant - Duration::from_secs(5);
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `instant.checked_sub(Duration::from_secs(5)).unwrap()`
2121

2222
error: unchecked subtraction of 'Duration' from 'Instant'
23-
--> tests/ui/unchecked_duration_subtraction.rs:19:13
23+
--> tests/ui/unchecked_time_subtraction.rs:19:13
2424
|
2525
LL | let _ = Instant::now() - duration;
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(duration).unwrap()`
2727

2828
error: unchecked subtraction of 'Duration' from 'Duration'
29-
--> tests/ui/unchecked_duration_subtraction.rs:22:13
29+
--> tests/ui/unchecked_time_subtraction.rs:22:13
3030
|
3131
LL | let _ = Duration::from_secs(1) - duration;
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Duration::from_secs(1).checked_sub(duration).unwrap()`
3333

3434
error: unchecked subtraction of 'Duration' from 'Duration'
35-
--> tests/ui/unchecked_duration_subtraction.rs:25:13
35+
--> tests/ui/unchecked_time_subtraction.rs:25:13
3636
|
3737
LL | let _ = duration2 - duration;
3838
| ^^^^^^^^^^^^^^^^^^^^ help: try: `duration2.checked_sub(duration).unwrap()`
3939

4040
error: unchecked subtraction of 'Duration' from 'Duration'
41-
--> tests/ui/unchecked_duration_subtraction.rs:28:13
41+
--> tests/ui/unchecked_time_subtraction.rs:28:13
4242
|
4343
LL | let _ = Instant::now().elapsed() - duration;
4444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().elapsed().checked_sub(duration).unwrap()`

0 commit comments

Comments
 (0)