Move Clippy configuration to the workspace level (#8891)

This PR moves the Clippy configuration up to the workspace level.

We're using the [`lints`
table](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-lints-table)
to configure the Clippy ruleset in the workspace's `Cargo.toml`.

Each crate in the workspace now has the following in their own
`Cargo.toml` to inherit the lints from the workspace:

```toml
[lints]
workspace = true
```

This allows for configuring rust-analyzer to show Clippy lints in the
editor by using the following configuration in your Zed `settings.json`:

```json
{
  "lsp": {
    "rust-analyzer": {
      "initialization_options": {
        "check": {
          "command": "clippy"
        }
      }
    }
  }
```

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-03-05 12:01:17 -05:00 committed by GitHub
parent 52f750b216
commit 22fe03913c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
98 changed files with 328 additions and 56 deletions

2
Cargo.lock generated
View file

@ -3927,7 +3927,7 @@ dependencies = [
[[package]]
name = "fsevent"
version = "2.0.2"
version = "0.1.0"
dependencies = [
"bitflags 2.4.2",
"fsevent-sys 3.1.0",

View file

@ -322,8 +322,6 @@ features = [
"Win32_System_Ole",
]
[patch.crates-io]
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "e4a23971ec3071a09c1e84816954c98f96e98e52" }
# Workaround for a broken nightly build of gpui: See #7644 and revisit once 0.5.3 is released.
@ -350,5 +348,46 @@ debug = "limited"
lto = "thin"
codegen-units = 1
[workspace.lints.clippy]
dbg_macro = "deny"
todo = "deny"
# These are all of the rules that currently have violations in the Zed
# codebase.
#
# We'll want to drive this list down by either:
# 1. fixing violations of the rule and begin enforcing it
# 2. deciding we want to allow the rule permanently, at which point
# we should codify that separately above.
#
# This list shouldn't be added to; it should only get shorter.
# =============================================================================
# There are a bunch of rules currently failing in the `style` group, so
# allow all of those, for now.
style = "allow"
# Individual rules that have violations in the codebase:
almost_complete_range = "allow"
arc_with_non_send_sync = "allow"
await_holding_lock = "allow"
borrow_deref_ref = "allow"
borrowed_box = "allow"
cast_abs_to_unsigned = "allow"
cmp_owned = "allow"
derive_ord_xor_partial_ord = "allow"
eq_op = "allow"
implied_bounds_in_impls = "allow"
let_underscore_future = "allow"
map_entry = "allow"
never_loop = "allow"
non_canonical_clone_impl = "allow"
non_canonical_partial_ord_impl = "allow"
reversed_empty_ranges = "allow"
single_range_in_vec_init = "allow"
suspicious_to_owned = "allow"
type_complexity = "allow"
unnecessary_to_owned = "allow"
[workspace.metadata.cargo-machete]
ignored = ["bindgen", "cbindgen", "prost_build", "serde"]

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/activity_indicator.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/ai.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
anyhow.workspace = true
gpui.workspace = true

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/assistant.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/audio.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/auto_update.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/breadcrumbs.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/call.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/channel.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/cli.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/client.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/clock.rs"
doctest = false

View file

@ -7,6 +7,9 @@ version = "0.44.0"
publish = false
license = "AGPL-3.0-or-later"
[lints]
workspace = true
[[bin]]
name = "collab"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/collab_ui.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/collections.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[features]
default = []

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/command_palette.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/command_palette_hooks.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/copilot.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/copilot_ui.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/db.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/diagnostics.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/editor.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/extension_store.rs"

View file

@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/extension_api.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/extensions_ui.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/feature_flags.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/feedback.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/file_finder.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/fs.rs"

View file

@ -1,10 +1,12 @@
[package]
name = "fsevent"
version = "2.0.2"
license = "MIT"
version = "0.1.0"
edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/fsevent.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/fuzzy.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/git.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/go_to_line.rs"
doctest = false

View file

@ -7,6 +7,9 @@ description = "Zed's GPU-accelerated UI framework"
publish = false
license = "Apache-2.0"
[lints]
workspace = true
[features]
test-support = [
"backtrace",

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/gpui_macros.rs"
proc-macro = true

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/install_cli.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/journal.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/language.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/language_selector.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/language_tools.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
anyhow.workspace = true
async-compression.workspace = true

View file

@ -6,6 +6,9 @@ description = "Bindings to LiveKit Swift client SDK"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/live_kit_client.rs"
doctest = false

View file

@ -6,6 +6,9 @@ description = "SDK for the LiveKit server API"
publish = false
license = "AGPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/live_kit_server.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/lsp.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/markdown_preview.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/media.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/menu.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/multi_buffer.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/node_runtime.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/notification_store.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/outline.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/picker.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/prettier.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/project.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
test-support = [

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/project_panel.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/project_symbols.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/quick_action_bar.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/recent_projects.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/refineable.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/derive_refineable.rs"
proc-macro = true

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
gpui.workspace = true
once_cell = "1.19.0"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/rich_text.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/rope.rs"

View file

@ -6,6 +6,9 @@ version = "0.1.0"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/rpc.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/search.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/semantic_index.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/settings.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/snippet.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
anyhow.workspace = true
collections.workspace = true

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/sqlez_macros.rs"
proc-macro = true

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
gpui.workspace = true
itertools = { package = "itertools", version = "0.10" }

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[[bin]]
name = "storybook"
path = "src/storybook.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/sum_tree.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
anyhow.workspace = true
collections.workspace = true

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
anyhow.workspace = true
editor.workspace = true

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/telemetry_events.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/terminal.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/terminal_view.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/text.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[features]
default = []
stories = ["dep:story"]

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
anyhow.workspace = true
clap = { workspace = true, features = ["derive"] }

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/theme_selector.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/time_format.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
name = "ui"
path = "src/ui.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/util.rs"
doctest = true

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
anyhow.workspace = true
fs.workspace = true

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/vim.rs"
doctest = false

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/welcome.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/workspace.rs"
doctest = false

View file

@ -6,6 +6,9 @@ version = "0.126.0"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
name = "zed"
path = "src/zed.rs"

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
gpui.workspace = true
serde.workspace = true

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "Apache-2.0"
[lints]
workspace = true
[dependencies]
zed_extension_api = { path = "../../crates/extension_api" }

View file

@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
anyhow.workspace = true
clap = { workspace = true, features = ["derive"] }

View file

@ -63,57 +63,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> {
#[cfg(not(target_os = "windows"))]
clippy_command.args(["--deny", "warnings"]);
/// These are all of the rules that currently have violations in the Zed
/// codebase.
///
/// We'll want to drive this list down by either:
/// 1. fixing violations of the rule and begin enforcing it
/// 2. deciding we want to allow the rule permanently, at which point
/// we should codify that separately in this task.
///
/// This list shouldn't be added to; it should only get shorter.
const MIGRATORY_RULES_TO_ALLOW: &[&str] = &[
// There are a bunch of rules currently failing in the `style` group, so
// allow all of those, for now.
"clippy::style",
// Individual rules that have violations in the codebase:
"clippy::almost_complete_range",
"clippy::arc_with_non_send_sync",
"clippy::await_holding_lock",
"clippy::borrow_deref_ref",
"clippy::borrowed_box",
"clippy::cast_abs_to_unsigned",
"clippy::cmp_owned",
"clippy::derive_ord_xor_partial_ord",
"clippy::eq_op",
"clippy::implied_bounds_in_impls",
"clippy::let_underscore_future",
"clippy::map_entry",
"clippy::never_loop",
"clippy::non_canonical_clone_impl",
"clippy::non_canonical_partial_ord_impl",
"clippy::reversed_empty_ranges",
"clippy::single_range_in_vec_init",
"clippy::suspicious_to_owned",
"clippy::type_complexity",
"clippy::unnecessary_to_owned",
];
// When fixing violations automatically for a single package we don't care
// about the rules we're already violating, since it may be possible to
// have them fixed automatically.
let ignore_suppressed_rules = args.fix && args.package.is_some();
if !ignore_suppressed_rules {
for rule in MIGRATORY_RULES_TO_ALLOW {
clippy_command.args(["--allow", rule]);
}
}
// Deny `dbg!` and `todo!`s.
clippy_command
.args(["--deny", "clippy::dbg_macro"])
.args(["--deny", "clippy::todo"]);
eprintln!(
"running: {cargo} {}",
clippy_command