Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clippy_lints/src/casts/cast_precision_loss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca
let from_nbits_str = if arch_dependent {
"64".to_owned()
} else if is_isize_or_usize(cast_from) {
// FIXME: handle 16 bits `usize` type
"32 or 64".to_owned()
"16, 32, or 64".to_owned()
} else {
from_nbits.to_string()
};
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/cast_size.32bit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LL - 1isize as i8;
LL + i8::try_from(1isize);
|

error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
error: casting `isize` to `f32` causes a loss of precision (`isize` is 16, 32, or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast_size.rs:24:5
|
LL | x0 as f32;
Expand All @@ -22,7 +22,7 @@ LL | x0 as f32;
= note: `-D clippy::cast-precision-loss` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`

error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
error: casting `usize` to `f32` causes a loss of precision (`usize` is 16, 32, or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast_size.rs:26:5
|
LL | x1 as f32;
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/cast_size.64bit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LL - 1isize as i8;
LL + i8::try_from(1isize);
|

error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
error: casting `isize` to `f32` causes a loss of precision (`isize` is 16, 32, or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast_size.rs:24:5
|
LL | x0 as f32;
Expand All @@ -22,7 +22,7 @@ LL | x0 as f32;
= note: `-D clippy::cast-precision-loss` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`

error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
error: casting `usize` to `f32` causes a loss of precision (`usize` is 16, 32, or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
--> tests/ui/cast_size.rs:26:5
|
LL | x1 as f32;
Expand Down