-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #13542 - blyxyas:fix-implicit_saturating_sub, r=y21
[`implicit_saturating_sub`] Fix suggestion with a less volatile approach Related to #13533, such and obvious mistake got pass my watch, quite embarassing :/ Revert #13533 and implement a more robust solution. Revert "Fix span issue on `implicit_saturating_sub` This reverts commit 140a127. changelog: [`lint_name`]: Fix suggestion for `if {} else if {} else {}` cases r? `@y21`
- Loading branch information
Showing
6 changed files
with
92 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
error: manual arithmetic check found | ||
--> tests/ui/manual_arithmetic_check.rs:9:44 | ||
--> tests/ui/manual_arithmetic_check.rs:9:18 | ||
| | ||
LL | let result = if a > b { a - b } else { 0 }; | ||
| ^ help: replace it with: `a.saturating_sub(b)` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)` | ||
| | ||
= note: `-D clippy::implicit-saturating-sub` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::implicit_saturating_sub)]` | ||
|
||
error: manual arithmetic check found | ||
--> tests/ui/manual_arithmetic_check.rs:11:44 | ||
--> tests/ui/manual_arithmetic_check.rs:11:18 | ||
| | ||
LL | let result = if b < a { a - b } else { 0 }; | ||
| ^ help: replace it with: `a.saturating_sub(b)` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)` | ||
|
||
error: manual arithmetic check found | ||
--> tests/ui/manual_arithmetic_check.rs:14:29 | ||
--> tests/ui/manual_arithmetic_check.rs:14:18 | ||
| | ||
LL | let result = if a < b { 0 } else { a - b }; | ||
| ^ help: replace it with: `a.saturating_sub(b)` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)` | ||
|
||
error: manual arithmetic check found | ||
--> tests/ui/manual_arithmetic_check.rs:16:29 | ||
--> tests/ui/manual_arithmetic_check.rs:16:18 | ||
| | ||
LL | let result = if b > a { 0 } else { a - b }; | ||
| ^ help: replace it with: `a.saturating_sub(b)` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)` | ||
|
||
error: aborting due to 4 previous errors | ||
|