Skip to content

Commit 06b9e4b

Browse files
committed
fix: remove (redundant) semicolon in lint suggestion
1 parent 98669c5 commit 06b9e4b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

clippy_lints/src/instant_subtraction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn print_unchecked_duration_subtraction_sugg(
174174
expr.span,
175175
"unchecked subtraction of a 'Duration' from an 'Instant'",
176176
"try",
177-
format!("{left_expr}.checked_sub({right_expr}).unwrap();"),
177+
format!("{left_expr}.checked_sub({right_expr}).unwrap()"),
178178
applicability,
179179
);
180180
}

tests/ui/unchecked_duration_subtraction.fixed

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ fn main() {
77
let _first = Instant::now();
88
let second = Duration::from_secs(3);
99

10-
let _ = _first.checked_sub(second).unwrap();;
10+
let _ = _first.checked_sub(second).unwrap();
1111

12-
let _ = Instant::now().checked_sub(Duration::from_secs(5)).unwrap();;
12+
let _ = Instant::now().checked_sub(Duration::from_secs(5)).unwrap();
1313

14-
let _ = _first.checked_sub(Duration::from_secs(5)).unwrap();;
14+
let _ = _first.checked_sub(Duration::from_secs(5)).unwrap();
1515

16-
let _ = Instant::now().checked_sub(second).unwrap();;
16+
let _ = Instant::now().checked_sub(second).unwrap();
1717
}

tests/ui/unchecked_duration_subtraction.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ error: unchecked subtraction of a 'Duration' from an 'Instant'
22
--> $DIR/unchecked_duration_subtraction.rs:10:13
33
|
44
LL | let _ = _first - second;
5-
| ^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(second).unwrap();`
5+
| ^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(second).unwrap()`
66
|
77
= note: `-D clippy::unchecked-duration-subtraction` implied by `-D warnings`
88

99
error: unchecked subtraction of a 'Duration' from an 'Instant'
1010
--> $DIR/unchecked_duration_subtraction.rs:12:13
1111
|
1212
LL | let _ = Instant::now() - Duration::from_secs(5);
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(Duration::from_secs(5)).unwrap();`
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(Duration::from_secs(5)).unwrap()`
1414

1515
error: unchecked subtraction of a 'Duration' from an 'Instant'
1616
--> $DIR/unchecked_duration_subtraction.rs:14:13
1717
|
1818
LL | let _ = _first - Duration::from_secs(5);
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(Duration::from_secs(5)).unwrap();`
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(Duration::from_secs(5)).unwrap()`
2020

2121
error: unchecked subtraction of a 'Duration' from an 'Instant'
2222
--> $DIR/unchecked_duration_subtraction.rs:16:13
2323
|
2424
LL | let _ = Instant::now() - second;
25-
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(second).unwrap();`
25+
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(second).unwrap()`
2626

2727
error: aborting due to 4 previous errors
2828

0 commit comments

Comments
 (0)