-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
clippy::cast_possible_truncation fails to warn when casting u32 to usize even though truncation is possible on platforms where usize is narrower than 32 bits (e.g., 16-bit pointer-width targets).
Lint Name
cast_possible_truncation
Reproducer
I tried this code:
#[deny(clippy::cast_possible_truncation)]
pub fn as_usize(x: u32) -> usize {
x as usize
}I expected to see this happen:
error: casting `u32` to `usize` may truncate the value on targets with 16-bit wide pointers
Instead, this happened:
lint did not fire
Version
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't