clippy::pedantic and Workspace Lints


In my Discord today someone brought up how excited they were that Workspace Lint configuration was finally stable, which was new to me!

I Learned about clippy::pedantic and about turning on lints for an entire workspace!

Lets start there with Workspace Lints! They let you configure which Clippy Lints you opt into (or out of) for the entire workspace.

This requires defining the lints you want to use in the workspace Cargo.toml file like this

pedantic = "deny"

This for instance sets the pedantic group to deny so it will cause Clippy to error out for everything in the group.

Now for individual crates to opt into this grouping you need to add the following to their individual Cargo.toml files

workspace = true

I love Clippy, so when I learned about the clippy:pedantic group, which makes Clippy even MORE picky I knew I wanted to try it out! It adds a bunch of lints, and as it turns out turning them all on was a bit too much for me. A few conflicted with tools I am using, and some I just disagreed with. But overall it's really cool to be able to opt into a whole group of lints like this!

I opted to use the pedantic group and then allow the specific lints I didn't agree with. The workspace Cargo.toml for this site looks like this at the time this TIL was published!

pedantic = "deny"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
module_name_repetitions = "allow"
blocks_in_conditions = "allow"
must_use_candidate = "allow"
no-effect-underscore-binding = "allow"
items-after-statements = "allow"

You can see the PR where I added these Lints and fixed up the repo here:

coreyja weekly

My weekly newsletter tailored at developers who are eager to grow with me!
Every week will be unique, but expect topics focusing around Web Development and Rust