Background
This issue tracks which Rust and Clippy lints we currently use as default for all of our internal and external crates. We have a common base of lints that we configure the same everywhere that is more opinionated than the Rust and Clippy defaults and geared towards how we prefer to (currently) write & maintain Rust code.
Individual crates are able to, and often do override some of these defaults, either on a crate level, or for specific modules or functions. But we still find it helpful to have a standard across everything to keep the code high quality and generally working the same way.
Lint configuration
We currently have two ways to enable our configured lints:
- Through copy'n'pasting https://github.com/EmbarkStudios/rust-ecosystem/blob/main/lints.rs into every crate
- Through a
.cargo/config.toml section: https://github.com/EmbarkStudios/rust-ecosystem/blob/main/lints.toml
Traditionally we've used option 1, but are testing and converting more to option 2 as it is much easier to just have a single configuration file with everything.
We hope to later in 2021 have proper first-class support for a lints.toml or [lints] section in Cargo and switch to that, but progress for it has been slow. Tracked in:
Lints of interests
Testing / being discussed
- Add:
clippy::needless_pass_by_value - helped us catch a lot of unnecessary : Vec<T> arguments and replace them with : &[T], saving a lot of calls to .clone() (very common trap for rust beginners to fall into). quite intrusive change for lots of crates though so safer to do separtely
- Add:
rustdoc::missing_crate_level_docs
Blocked
List of Clippy lints we are interested in using, but that have issues or are not mature / specific enough yet for inclusion.
Background
This issue tracks which Rust and Clippy lints we currently use as default for all of our internal and external crates. We have a common base of lints that we configure the same everywhere that is more opinionated than the Rust and Clippy defaults and geared towards how we prefer to (currently) write & maintain Rust code.
Individual crates are able to, and often do override some of these defaults, either on a crate level, or for specific modules or functions. But we still find it helpful to have a standard across everything to keep the code high quality and generally working the same way.
Lint configuration
We currently have two ways to enable our configured lints:
.cargo/config.tomlsection: https://github.com/EmbarkStudios/rust-ecosystem/blob/main/lints.tomlTraditionally we've used option 1, but are testing and converting more to option 2 as it is much easier to just have a single configuration file with everything.
We hope to later in 2021 have proper first-class support for a
lints.tomlor[lints]section in Cargo and switch to that, but progress for it has been slow. Tracked in:Lints of interests
Testing / being discussed
clippy::needless_pass_by_value- helped us catch a lot of unnecessary: Vec<T>arguments and replace them with: &[T], saving a lot of calls to.clone()(very common trap for rust beginners to fall into). quite intrusive change for lots of crates though so safer to do separtelyrustdoc::missing_crate_level_docsBlocked
List of Clippy lints we are interested in using, but that have issues or are not mature / specific enough yet for inclusion.
clippy::use_self- blocked onclippy::use_selfhas too many false positives #53clippy::unnecessary_wrapsclippy::option_if_let_else- blocked on:option_if_let_elsecauses a compilation errorerror[E0382]: Borrow of moved valuerust-lang/rust-clippy#6737clippy::wildcard_enum_match_arm- blocked on wildcard_enum_match_arm fail with non-exhaustive enums and OR patterns rust-lang/rust-clippy#6862clippy::print_stdout/clippy::print_stderr- ineffective due to EarlyLintPass::check_mac() is not called in non-toplevel modules rust-lang/rust-clippy#5721