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/
### Description #13098 introduced `@no-rustfix` annotations, that can be removed by changing the suggestion to a multipart suggestion: ```rust //@no-rustfix: need to change the suggestion to a multipart suggestion ```...
### Summary `cast_possible_truncation` can be overly zealous about casting floating point values to integers when said values have just been explicitly "rounded" in the code, so that their values would...
I tried this code: ```rust // in main.rs #![warn(clippy::all, clippy::pedantic)] mod foo; fn main() { foo::foo(); } //in foo.rs #![allow(clippy::single_component_path_imports)] pub fn foo() { usable!(); } macro_rules! usable { ()...
One of the subtle aspects of `*ptr = val` where `ptr` is a raw pointer is that this will drop the old contents stored behind that pointer. On the one...
changelog: [`use_self`] Skip if inside macro expansions of a `impl Self` block Fixes #13092. r? Alexendoo
### What it does Detect `assert!(a == b)` and `assert!(a != b)` and suggest using `assert_eq!` or `assert_ne!` respectively. Should probably apply to `debug_assert!` as well. ### Advantage - The...
close https://github.com/rust-lang/rust-clippy/issues/13242 This PR fixes the issue where errors from map_unwrap_or were only partially displayed. When the error spans multiple lines, it needs to be shown in a block format....
### Summary In stable (1.79.0), `unnecessary_lazy_evaluations` does not trigger when the value of the closure is a constant error variant in an enum that derives `thiserror::Error`. - This was emitting...
### Summary Here is a playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=e4fad507e221cf2e8540575031233165 The suggestion leads to broken code which does not compile: ``` error[E0594]: cannot assign to `a.a`, which is behind a `&` reference...
### Summary For `unsafe {}` blocks it matters when they're executed, even if they're cheap. ### Lint Name unnecessary_lazy_evaluations ### Reproducer I tried this code: ```rust is_safe_to_access.then_some(|| unsafe { &a_union.field...