diff options
| author | Nadir Fejzic <nadirfejzo@gmail.com> | 2022-11-08 15:04:32 +0100 |
|---|---|---|
| committer | Nadir Fejzic <nadirfejzo@gmail.com> | 2022-11-10 15:47:12 +0100 |
| commit | 862ac29192bd4e2c9db04e9763dfd1a35a00a9cb (patch) | |
| tree | 9cc6cc5b9882ec0d1cd1327aaa26205f64eaf0d0 | |
| parent | 62ab4fb9c265b9e25d61c99511cd26de0260f435 (diff) | |
| download | rust-862ac29192bd4e2c9db04e9763dfd1a35a00a9cb.tar.gz rust-862ac29192bd4e2c9db04e9763dfd1a35a00a9cb.zip | |
fix: remove (redundant) semicolon in lint suggestion
| -rw-r--r-- | clippy_lints/src/instant_subtraction.rs | 2 | ||||
| -rw-r--r-- | tests/ui/unchecked_duration_subtraction.fixed | 8 | ||||
| -rw-r--r-- | tests/ui/unchecked_duration_subtraction.stderr | 8 |
3 files changed, 9 insertions, 9 deletions
diff --git a/clippy_lints/src/instant_subtraction.rs b/clippy_lints/src/instant_subtraction.rs index c039f1b5c6a..d83beb622cf 100644 --- a/clippy_lints/src/instant_subtraction.rs +++ b/clippy_lints/src/instant_subtraction.rs @@ -174,7 +174,7 @@ fn print_unchecked_duration_subtraction_sugg( expr.span, "unchecked subtraction of a 'Duration' from an 'Instant'", "try", - format!("{left_expr}.checked_sub({right_expr}).unwrap();"), + format!("{left_expr}.checked_sub({right_expr}).unwrap()"), applicability, ); } diff --git a/tests/ui/unchecked_duration_subtraction.fixed b/tests/ui/unchecked_duration_subtraction.fixed index bcc231d93b1..a0e49a8beb1 100644 --- a/tests/ui/unchecked_duration_subtraction.fixed +++ b/tests/ui/unchecked_duration_subtraction.fixed @@ -7,11 +7,11 @@ fn main() { let _first = Instant::now(); let second = Duration::from_secs(3); - let _ = _first.checked_sub(second).unwrap();; + let _ = _first.checked_sub(second).unwrap(); - let _ = Instant::now().checked_sub(Duration::from_secs(5)).unwrap();; + let _ = Instant::now().checked_sub(Duration::from_secs(5)).unwrap(); - let _ = _first.checked_sub(Duration::from_secs(5)).unwrap();; + let _ = _first.checked_sub(Duration::from_secs(5)).unwrap(); - let _ = Instant::now().checked_sub(second).unwrap();; + let _ = Instant::now().checked_sub(second).unwrap(); } diff --git a/tests/ui/unchecked_duration_subtraction.stderr b/tests/ui/unchecked_duration_subtraction.stderr index b949dbf701a..a2e0aa1d7c0 100644 --- a/tests/ui/unchecked_duration_subtraction.stderr +++ b/tests/ui/unchecked_duration_subtraction.stderr @@ -2,7 +2,7 @@ error: unchecked subtraction of a 'Duration' from an 'Instant' --> $DIR/unchecked_duration_subtraction.rs:10:13 | LL | let _ = _first - second; - | ^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(second).unwrap();` + | ^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(second).unwrap()` | = note: `-D clippy::unchecked-duration-subtraction` implied by `-D warnings` @@ -10,19 +10,19 @@ error: unchecked subtraction of a 'Duration' from an 'Instant' --> $DIR/unchecked_duration_subtraction.rs:12:13 | LL | let _ = Instant::now() - Duration::from_secs(5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(Duration::from_secs(5)).unwrap();` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(Duration::from_secs(5)).unwrap()` error: unchecked subtraction of a 'Duration' from an 'Instant' --> $DIR/unchecked_duration_subtraction.rs:14:13 | LL | let _ = _first - Duration::from_secs(5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(Duration::from_secs(5)).unwrap();` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(Duration::from_secs(5)).unwrap()` error: unchecked subtraction of a 'Duration' from an 'Instant' --> $DIR/unchecked_duration_subtraction.rs:16:13 | LL | let _ = Instant::now() - second; - | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(second).unwrap();` + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(second).unwrap()` error: aborting due to 4 previous errors |
