Extreme Clippy (for a new crate)

Rust

Rust Clippy is the standard linter for Rust. It is a very good tool to make your code better, but it is also a very good educational tool. In this video you'll see how to take it to the extreme. Turn on every lint and then disable the ones you don't like while learning a lot about Rust.

examples/extreme-clippy/Cargo.toml

[package]
name = "extreme-clippy"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[lints.clippy]
cargo        = { priority = -1, level = "deny" }
complexity   = { priority = -1, level = "deny" }
correctness  = { priority = -1, level = "deny" }
nursery      = { priority = -1, level = "deny" }
pedantic     = { priority = -1, level = "deny" }
perf         = { priority = -1, level = "deny" }
restriction  = { priority = -1, level = "deny" }
style        = { priority = -1, level = "deny" }
suspicious   = { priority = -1, level = "deny" }


cargo_common_metadata = "allow"
missing_docs_in_private_items = "allow"
blanket_clippy_restriction_lints = "allow" # I like Extreme clippy
implicit_return = "allow" # This is the more common way in rust
dbg_macro = "allow"

examples/extreme-clippy/src/main.rs

#[allow(clippy::print_stdout)]
fn main() {
    println!("Hello, world!");
}

fn echo(text: &str) -> String {
    dbg!(text);
    text.to_owned()
}

Related Pages

Extreme Clippy for existing Crate

Author

Gabor Szabo (szabgab)

Gabor Szabo, the author of the Rust Maven web site maintains several Open source projects in Rust and while he still feels he has tons of new things to learn about Rust he already offers training courses in Rust and still teaches Python, Perl, git, GitHub, GitLab, CI, and testing.

Gabor Szabo