Auto merge of #8778 - sunfishcode:main, r=giraffate
Fix `cast_lossless` to avoid warning on `usize` to `f64` conversion. Previously, the `cast_lossless` lint would issue a warning on code that converted a `usize` value to `f64`, on 32-bit targets. `usize` to `f64` is a lossless cast on 32-bit targets, however there is no corresponding `f64::from` that takes a `usize`, so `cast_lossless`'s suggested replacement does not compile. This PR disables the lint in the case of casting from `usize` or `isize`. Fixes #3689. changelog: [`cast_lossless`] no longer gives wrong suggestion on usize,isize->f64
This commit is contained in:
commit
5dad51736c
2 changed files with 1 additions and 15 deletions
|
|
@ -93,7 +93,7 @@ fn should_lint(
|
|||
} else {
|
||||
64
|
||||
};
|
||||
from_nbits < to_nbits
|
||||
!is_isize_or_usize(cast_from) && from_nbits < to_nbits
|
||||
},
|
||||
(false, true) if matches!(cast_from.kind(), ty::Bool) && meets_msrv(msrv.as_ref(), &msrvs::FROM_BOOL) => true,
|
||||
(_, _) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue