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 ```rust use std::mem::forget; #[allow(dead_code)] fn test_generic_fn_forget(val: T) { forget(&val); forget(val); } ``` => ``` warning: this could be a `const fn` --> a.rs:5:2 | 5 | / fn...
### Summary . ### Reproducer I tried this code: ```rust #![recursion_limit = "10"] macro_rules! link { ($outer:ident, $inner:ident) => { struct $outer($inner); impl $outer { fn new() -> $outer {...
### Summary . ### Reproducer I tried this code: ```rust use std::cell::Cell; const NONE_CELL_STRING: Option = None; fn a() { // clippy suggests this to be const let _: &'static...
### Summary ```rust pub fn main() {} pub struct S24 { a: i8, b: i8, c: i8, } // CHECK: i24 @struct_24_bits(i24 #[no_mangle] pub extern "sysv64" fn struct_24_bits(a: S24) ->...
### Summary ```rust #![feature(type_alias_impl_trait)] type Foo4 = impl Debug; fn define4(_: Foo4) { let y: Foo4 = 42; } ``` => ``` warning: this could be a `const fn` -->...
### Summary ```rust #[no_mangle] const extern "C-unwind" fn unwind() { // clippy suggests: // const extern "C-unwind" fn unwind() { // but this requires the #![feature(const_extern_fn)] gate panic!(); } fn...
### Description slightly amused: ```rust #[derive(Eq, PartialEq)] pub struct Data([u8; 4]); const DATA: Data = Data([1, 2, 3, 4]); fn main() { match DATA { DATA => (), _ =>...
``` changelog: [`doc_markdown`]: correctly detect backslash-escaped `` ` `` ```
### Summary There is a pattern that does not work even though needless_return is enabled. [playground is here](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9f84d1d415ac46d0e0fdb123b4a46462). ### Lint Name needless_return ### Reproducer I tried this code: ```rust #![warn(clippy::needless_return)]...
Fixes #10070. It can serve as base if we want to add equivalent checks for other arithmetic operations. Also one important note: when writing this lint, I realized that I...