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 The following clippy message has an incorrect suggestion: ``` warning: called `map().unwrap_or(false)` on an `Option` value --> surfer\src/main.rs:1994:9 | 1994 | / self.waves 1995 | | .as_ref() 1996...
```rust struct Foo(usize); impl Foo { fn next(&mut self) -> Option { self.0 += 1; match self.0 { i if i > 3 => None, 3 => Some(Err(3)), i =>...
### Summary The `duplicated_attributes` lint yields false positives when using the [apistos](https://github.com/netwo-io/apistos) crate for OpenAPI documentation. ### Lint Name duplicated_attributes ### Reproducer I tried this code: ```rust #[derive(Debug, Serialize, JsonSchema,...
changelog: [`unused_async`]: - check after `pro_macro_attribute` - check inside async block fixes #13199 I've run the test, but failed with the error that I didn't understand. ```sh error: actual output...
### Summary `missing_panics_doc` does not trigger on indexing, which could panic. `.get(...).unwrap()` is equivalent and does get caught. ### Lint Name missing_panics_doc ### Reproducer I tried this code: ```rust #![warn(clippy::missing_panics_doc)]...
### Summary missing_panics_doc should not trigger on NonZero-type-family constructor whose value is known to be non-zero: * for `NonZeroNum`, integer literal whose value is not zero * for `Nonnull`, references...
Fixes a false positive that triggers tests_outside_test_module in integration tests. As per [The Rust Book](https://doc.rust-lang.org/book/ch11-03-test-organization.html#the-tests-module-and-cfgtest) the integration tests do not need neither `#[cfg(test)]` nor a separate module because they are...
### Summary The `print_` lint group, e.g. `print_stdout`, `print_literal`, fail to detect usage inside `async_trait` functions with a return type other than `()`. This occurs both in `impl` blocks for...
Lint name: [declare_interior_mutable_const](https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const) I tried this code: ```rust let _: [Cell; 7] = [Cell::new(true); 7]; ``` Since the array initialization syntax requires `T: Copy`, rustc errors and suggests this fix...
### Summary ```rust let (result_stream, threads) = { let query = query; // ERROR ringboard_sdk::search( if regex { Query::Regex(Regex::new(&query)?) } else if ignore_case { Query::PlainIgnoreCase(CaselessQuery::new(query).trim()) } else { Query::Plain(query.as_bytes()) },...