-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix clippy warnings #347
Fix clippy warnings #347
Conversation
cat src/lib.rs|perl -pe's/\b(\w+): \1\b/$1/g'|sponge src/lib.rs
619 of the warnings in steven_gl: brendanzab/gl-rs#523
reduced test case: fn f(a: usize, b: usize, c: bool) -> Option<usize> {
Some(a + (b << 1) | (if c { 0 } else { 1 }))
}
fn main() {
println!("{:?}", f(1, 2, true));
} clippy suggests changing: -Some(a + (b << 1) | (if c { 0 } else { 1 }))
+Some(a + (b << 1)) | (if c { 0 } else { 1 }) but this can't compile of course, error[E0369]: no implementation for update: it actually means parenthesize with Some, this fixes the warning: Some((a + (b << 1)) | (if c { 0 } else { 1 })) |
Next up, there are 133 warnings in steven_blocks, all the same, but in macro-generated code:
|
Working on steven_protocol, down to two warnings:
https://doc.rust-lang.org/std/str/trait.FromStr.html would be more appropriate here. It would solve the
need to access the iterator mutably, to write |
Zero clippy lints on steven_protocol (as well as steven_blocks) now. None already on steven_shared, or std_or_web, but steven_shared has a few.
|
Fixing more warnings, but not all lints may be appropriate for this project.
|
src/render/mod.rs TextureManager, this triggers a warning: version: {
let ver = res.read().unwrap().version();
ver
}, but is it really unnecessary?
it can't be returned directly, trips up the borrow checker:
|
Chipping away at the lints, down to 58 excluding steven_gl:
|
…nged from the last value assigned, not compare two different floating point values; downgrade not_unsafe_ptr_arg_deref to warning
Continuing to make progress, but have a few left to resolve. Down to 25 warnings total:
|
…inter argument (not_unsafe_ptr_arg_deref); fix typo
…enum_variant) warning: large size difference between variants --> src/world/mod.rs:54:5 | 54 | / UpdateSignText( 55 | | Position, 56 | | format::Component, 57 | | format::Component, 58 | | format::Component, 59 | | format::Component, 60 | | ), | |_____^ this variant is 268 bytes | = note: `#[warn(clippy::large_enum_variant)]` on by default note: and the second-largest variant is 12 bytes: --> src/world/mod.rs:53:5 | 53 | Remove(Position), | ^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum --> src/world/mod.rs:54:5 | 54 | / UpdateSignText( 55 | | Position, 56 | | format::Component, 57 | | format::Component, 58 | | format::Component, 59 | | format::Component, 60 | | ), | |_____^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
…always be 16, and this value is not from block_types, blocks_meta, blocks_add, but must be consistent with all variables and is part of the wire protocol
…, tick(), and it is faster on Intel according to https://rust-lang.github.io/rust-clippy/master/index.html#verbose_bit_mask
If all clippy lints were fixed, then #346 Azure Pipelines could enable build failures for new clippy warnings/errors