You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
similar to #2728 however, the value was not a constant in my original code, instead I protected against negative values with an assert().
clippy 0.0.212
#[cfg_attr(feature = "cargo-clippy", warn(cast_sign_loss))]fnmain(){let x = get_some_number();assert!(x > 0);let y = "hi".to_string().repeat(x asusize);println!("{}", y);}pubfnget_some_number() -> i32{5}
warning: casting i32 to usize may lose the sign of the value
--> src/main.rs:6:37
|
6 | let y = "hi".to_string().repeat(x as usize);
| ^^^^^^^^^^
|
note: lint level defined here
--> src/main.rs:1:43
|
1 | #[cfg_attr(feature = "cargo-clippy", warn(cast_sign_loss))]
| ^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#cast_sign_loss
The text was updated successfully, but these errors were encountered:
similar to #2728 however, the value was not a constant in my original code, instead I protected against negative values with an
assert()
.clippy 0.0.212
The text was updated successfully, but these errors were encountered: