twilight-rs / twilight

Powerful, flexible, and scalable ecosystem of Rust libraries for the Discord API.
https://discord.gg/twilight-rs
ISC License
687 stars 131 forks source link

Update lints used in Twilight #2350

Open laralove143 opened 5 months ago

laralove143 commented 5 months ago

There are many lints in Rustc and Clippy that fall in line with our contribution guides that we are not making use of. Our way of setting lints could also be improved.

References for new lints

Rustc lints

A list of opt-in Rustc lints can be found here. It is best to only opt out of default lints on a statement-basis, rather than a workspace/crate basis.

Clippy Lints

These lint groups are opt-in and most lints in them are applicable for our use-case:

Lints in the group of Restriction should not be enabled as a whole but there are some lints that we might find useful:

Some of these lints might be noisy, some of them might require a significant number of changes to apply, some may be unnecessary for our purposes, and some may actually not follow our current code-style. They are listed here as a reference for further discussion before a PR.

Some lints that should be here could be missing out of my mistake. The lints are ordered alphabetically (as they appear on the Clippy lints website) and comments to add missing lints are welcome.

New Way of Setting Lints

Currently, we are setting lints in each crate's respective lib.rs/main.rs file, which can cause discrepancies and leads to duplicate code across each crate. We were doing this because there was no other way to set lints. We can now set lints in Cargo.toml files (documentation, tracking issue). A few questions remain on whether this approach is viable though:

I was unable to find the answers to these questions but we can find out by simply trying.