Commit 24b9349
authored
Add
`clippy::cast_possible_wrap` checks for casting an unsigned integer to a
signed integer of the same size. If the value is too large to fit in the
signed integer, it will wrap around to negative numbers. Such casts will
usually be used when doing some math, so scrutiny of the cast is
probably welcome. It's similar to the already-enabled
`clippy::cast_possible_truncation`.
See linebender/vello#1364 for an example where
the lint is useful.
The similar lint `clippy::cast_sign_loss` more or less does the
opposite, triggering for casts from signed to unsigned numeric types.
Floats are included in this lint, as they do a saturating cast, making
it more likely to have false positives: it triggers 65 times on
`vello_common` currently. Perhaps this one should not be added to the
canonical lint set (and I have not proposed adding it here).
For the interested reader,
rust-lang/rust-clippy#9231 has some further
discussion of these lints.clippy::cast_possible_wrap to the lint set (#135)1 parent 6dc433f commit 24b9349
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
0 commit comments