rust-clippy
rust-clippy copied to clipboard
A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
### Summary I tried using the new clippy lint `allow_attributes` on one of my projects and found many warnings for structs deriving `bytemuck::Pod`. I am using [bytemuck](https://crates.io/crates/bytemuck) and checking the...
### Description Applying fix on this situation: ```rs fn f(v: Vec) { let mut i = 0; for e in &v { // consider using: `for (i, e) in v.iter().enumerate()`...
This is currently draft as built on-top of #13557. Closes #12290. This is implemented by inspecting rustc's `NeverToAny` type adjustments, meaning we do not have to solve the halting problem...
### What it does Suggest to replace `if xxx { Some(yyy) } else { None }` with `(xxx).then(|| yyy)`, it is simpler and cleaner. Bonus point if the condition is...
### What it does Consider the following code piece: ```rust ... #[test] fn test_with_silent_fail() { let result = ...; if result.is_err() { eprintln!("failed to do something"); } } ``` This...
### Summary It seems that `needless_match` can fire incorrectly with multiple `if let` blocks chained together. ### Lint Name clippy::needless_match ### Reproducer I tried this code: ```rust pub fn color_text_to_rgb_tuple(text:...
With this change we no longer require doc comments for `const _: ()` items as well as nested items in functions or other bodies. In both of those cases, rustdoc...
Fixes #13568 Follow up to #13359, I didn't catch that it swapped the `strip_prefix` out for a `trim` but they aren't interchangeable here changelog: none
Close #13106 Considered case was described [here](https://github.com/rust-lang/rust-clippy/pull/13114#issuecomment-2266629991) changelog [`const_is_empty`]: skip const_is_empty for inline const assertions