Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move clippy args to [workspace.lints.clippy] #5715

Merged
merged 6 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,43 @@ default-members = [
]
resolver = "2"

#
# Tree-wide lint configuration.
# https://doc.rust-lang.org/stable/cargo/reference/manifest.html#the-lints-section
#
# For a list of Clippy lints, see
# https://rust-lang.github.io/rust-clippy/master.
#
[workspace.lints.clippy]
# Clippy's style nits are useful, but not worth keeping in CI.
style = { level = "allow", priority = -1 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does priority = -1 do? i assume it allows this to be overridden, but why do we only need to set it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until [lints], all methods for modifying lint levels had inherent ordering; either command line flags, or attributes in code. TOML tables are explicitly unordered, so Rust had to do something different here. Per the RFC any sorting beyond user-defined priorities is undefined (more detail); style has to come first because otherwise it would re-allow the style lints that happen to come before it once sorted.

The default priority for any key in this table is 0, so setting this to -1 means it is ordered before the rest of the keys.

# But continue to warn on anything in the "disallowed_" namespace.
disallowed_macros = "warn"
disallowed_methods = "warn"
disallowed_names = "warn"
disallowed_script_idents = "warn"
disallowed_types = "warn"
# Warn on some more style lints that are relatively stable and make sense.
iter_cloned_collect = "warn"
iter_next_slice = "warn"
iter_nth = "warn"
iter_nth_zero = "warn"
iter_skip_next = "warn"
len_zero = "warn"
redundant_field_names = "warn"
# `declare_interior_mutable_const` is classified as a style lint, but it can
# identify real bugs (e.g., declarying a `const Atomic` and using it like
# a `static Atomic`). However, it is also subject to false positives (e.g.,
# idiomatically declaring a static array of atomics uses `const Atomic`). We
# warn on this to catch the former, and expect any uses of the latter to allow
# this locally.
Comment on lines +191 to +194
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take it or leave it: maybe worth also mentioning http::HeaderName explicitly, since that's probably one of the most common false positives we'll hit in omicron? it would be nice if someone who adds a const HeaderName in the future to immediately see "no, just allow that lint" written down here.

declare_interior_mutable_const = "warn"
# Also warn on casts, preferring explicit conversions instead.
#
# We'd like to warn on lossy casts in the future, but lossless casts are the
# easiest ones to convert over.
cast_lossless = "warn"

[workspace.dependencies]
anyhow = "1.0"
anstyle = "1.0.6"
Expand Down
3 changes: 3 additions & 0 deletions api_identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ license = "MPL-2.0"
[lib]
proc-macro = true

[lints]
workspace = true

[dependencies]
proc-macro2.workspace = true
quote.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions bootstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ license = "MPL-2.0"
[build-dependencies]
omicron-rpaths.workspace = true

[lints]
workspace = true

[dependencies]
bytes.workspace = true
camino.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions caboose-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
hubtools.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions certificates/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
display-error-chain.workspace = true
foreign-types.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/bootstrap-agent-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
omicron-common.workspace = true
progenitor.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/ddm-admin-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
either.workspace = true
progenitor-client.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/dns-service-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
chrono.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/dpd-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
futures.workspace = true
progenitor-client.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/gateway-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
base64.workspace = true
chrono.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/installinator-artifact-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
installinator-common.workspace = true
progenitor.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/nexus-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
chrono.workspace = true
futures.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/oxide-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
base64.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/oximeter-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
chrono.workspace = true
futures.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/sled-agent-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
async-trait.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions clients/wicketd-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
chrono.workspace = true
installinator-common.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

# NOTE:
#
# This crate is depended on by several other workspaces! Be careful of adding
Expand Down
3 changes: 3 additions & 0 deletions dev-tools/crdb-seed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
license = "MPL-2.0"
readme = "README.md"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
dropshot.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions dev-tools/omdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[build-dependencies]
omicron-rpaths.workspace = true

Expand Down
3 changes: 3 additions & 0 deletions dev-tools/omicron-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[build-dependencies]
omicron-rpaths.workspace = true

Expand Down
3 changes: 3 additions & 0 deletions dev-tools/oxlog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
camino.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions dev-tools/reconfigurator-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[build-dependencies]
omicron-rpaths.workspace = true

Expand Down
3 changes: 3 additions & 0 deletions dev-tools/xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
camino.workspace = true
Expand Down
49 changes: 1 addition & 48 deletions dev-tools/xtask/src/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,54 +34,7 @@ pub fn run_cmd(args: ClippyArgs) -> Result<()> {
//
// We disallow warnings by default.
.arg("--deny")
.arg("warnings")
// Clippy's style nits are useful, but not worth keeping in CI. This
// override belongs in src/lib.rs, and it is there, but that doesn't
// reliably work due to rust-lang/rust-clippy#6610.
.arg("--allow")
.arg("clippy::style")
// But continue to warn on anything in the "disallowed_" namespace.
// (These will be turned into errors by `--deny warnings` above.)
.arg("--warn")
.arg("clippy::disallowed_macros")
.arg("--warn")
.arg("clippy::disallowed_methods")
.arg("--warn")
.arg("clippy::disallowed_names")
.arg("--warn")
.arg("clippy::disallowed_script_idents")
.arg("--warn")
.arg("clippy::disallowed_types")
// Warn on some more style lints that are relatively stable and make
// sense.
.arg("--warn")
.arg("clippy::iter_cloned_collect")
.arg("--warn")
.arg("clippy::iter_next_slice")
.arg("--warn")
.arg("clippy::iter_nth")
.arg("--warn")
.arg("clippy::iter_nth_zero")
.arg("--warn")
.arg("clippy::iter_skip_next")
.arg("--warn")
.arg("clippy::len_zero")
.arg("--warn")
.arg("clippy::redundant_field_names")
// `declare_interior_mutable_const` is classified as a style lint, but
// it can identify real bugs (e.g., declarying a `const Atomic` and
// using it like a `static Atomic`). However, it is also subject to
// false positives (e.g., idiomatically declaring a static array of
// atomics uses `const Atomic`). We warn on this to catch the former,
// and expect any uses of the latter to allow this locally.
.arg("--warn")
.arg("clippy::declare_interior_mutable_const")
// Also warn on casts, preferring explicit conversions instead.
//
// We'd like to warn on lossy casts in the future, but lossless casts
// are the easiest ones to convert over.
.arg("--warn")
.arg("clippy::cast_lossless");
.arg("warnings");

eprintln!(
"running: {:?} {}",
Expand Down
3 changes: 3 additions & 0 deletions dns-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
camino.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions end-to-end-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow = { workspace = true, features = ["backtrace"] }
async-trait.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions gateway-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
clap.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions gateway-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
camino.workspace = true
dropshot.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
base64.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions illumos-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
async-trait.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions installinator-artifactd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
async-trait.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions installinator-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
camino.workspace = true
Expand Down
Loading
Loading