-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying typesType: Probably requires verifiying types
Description
This code
#![warn(clippy)]
#![warn(clippy_pedantic)]
fn it_works() {
enum Foo { Bar = 300 }
let x = 300i32 as u8;
let y = Foo::Bar as u8;
}
hits a warning on x
but not on y
, even though both are truncated. Probably one of the cast_*
lints should trigger whenever a repr(rust) enum is as-casted (or if e.g. a repr(i32) is casted to a u8), optionally checking to see if the enum actually has numeric variants that would cause problems.
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying typesType: Probably requires verifiying types