-
Notifications
You must be signed in to change notification settings - Fork 99
Clippy errros with "casting usize to u8 may truncate the value #747
Copy link
Copy link
Closed
Description
I used parity-scale-codec version 3.7.5 then get an issue clippy
19:48 $ cat src/main.rs
use scale::{
Decode,
Encode,
};
pub type GroupId = u32;
#[derive(Debug, Clone, PartialEq,Encode, Decode, Default)]
pub enum PostVisibility {
#[default]
Public,
Supporter,
Group(GroupId),
#[derive(Encode, Decode)]
pub enum Foo {
Bar,
}
fn main() {
println!("Hello, world!");
}
cargo +1.87.0 clippy -- -Dclippy::cast_possible_truncation
Checking my_project v0.1.0 (/Users/thientd/github/my_project)
error: casting `usize` to `u8` may truncate the value
--> src/main.rs:12:5
|
12 | Group(GroupId), // Visible to a specific group
| ^^^^^
|
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation
= note: requested on the command line with `-D clippy::cast-possible-truncation`
help: ... or use `try_from` and handle the error accordingly
|
12 | Group::try_from(Encode)(GroupId), // Visible to a specific group
| ++++++++++++++++++
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels