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/
Fixes #12741 changelog: none
### Summary The `clippy::assigning_clones` diagnostic suggests calling `clone_from` on an uninitialized variable. ### Lint Name clippy::assigning_clones ### Reproducer I tried this code: ```rust pub fn test() -> (String, String) {...
https://github.com/rust-lang/rust/pull/45527 gives us `std::ptr::dangling` which allows replacing `1 as _` with `std::ptr::dangling()`. Once that is stable, it should be a warn lint. Until then an allow lint is ok. Should...
### Summary I had several versions of Rust installed (via rustup) and was surprised that Clippy would sometimes give errors like this: ``` error[E0514]: found crate `paste` compiled by an...
### Summary Originally submitted for Rocket, as i thought it was the macro. ### Lint Name clippy::significant-drop-tightening ### Reproducer I tried this code: ```rust /// Library "hipster": use rocket_sync_db_pools::{database, diesel};...
### Summary unnecessary_cast should catch unnecessary pointer casts like `&u32` to `*const u32` when this would already be done implicitly edge case to consider: it is not always converted implicitly,...
### Summary The `redundant_async_block` lint fails to trigger on uses of `async { EXPRESSION.await }` for seemingly any `EXPRESSION` other than a single variable. ### Lint Name redundant_async_block ### Reproducer...
### Summary Using `{integer}::from_str_radix(string, 10)` (Using `const_int_from_str` feature) in const contexts causes Clippy to suggest using `string.parse::()`, which is not possible in const contexts. ### Lint Name from_str_radix_10 ### Reproducer...
A fix for https://github.com/rust-lang/rust-clippy/issues/9361 suppresses `clippy::needless_return` if there are any attributes on the `return` statement. This leads to some unexpected behavior, as described in https://github.com/rust-lang/rust-clippy/issues/12998, where adding `#[expect(clippy::needless_return)]` suppresses the...
Fix partially https://github.com/rust-lang/rust-clippy/issues/7486#issuecomment-1843248881. Fix #9613. changelog: [`cast_possible_truncation`]: fix some false-positive on % operator, valid constants, and size_of