Skip to content

Commit

Permalink
Move Clippy configuration to the workspace level (zed-industries#8891)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
maxdeviant authored Mar 5, 2024
1 parent 52f750b commit 22fe039
Show file tree
Hide file tree
Showing 98 changed files with 328 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 41 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"]
3 changes: 3 additions & 0 deletions crates/activity_indicator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions crates/ai/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/ai.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/assets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
gpui.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/assistant/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/assistant.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/audio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/audio.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/auto_update/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions crates/breadcrumbs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/breadcrumbs.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/call/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/call.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/channel.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/cli.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/client.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/clock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/clock.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/collab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ version = "0.44.0"
publish = false
license = "AGPL-3.0-or-later"

[lints]
workspace = true

[[bin]]
name = "collab"

Expand Down
3 changes: 3 additions & 0 deletions crates/collab_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions crates/collections/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "Apache-2.0"

[lints]
workspace = true

[lib]
path = "src/collections.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/color/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[features]
default = []

Expand Down
3 changes: 3 additions & 0 deletions crates/command_palette/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions crates/command_palette_hooks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions crates/copilot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/copilot.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/copilot_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions crates/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/db.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/diagnostics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/diagnostics.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/editor.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/extension_store.rs"

Expand Down
3 changes: 3 additions & 0 deletions crates/extension_api/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 = "Apache-2.0"

[lints]
workspace = true

[lib]
path = "src/extension_api.rs"

Expand Down
3 changes: 3 additions & 0 deletions crates/extensions_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/extensions_ui.rs"

Expand Down
3 changes: 3 additions & 0 deletions crates/feature_flags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/feature_flags.rs"

Expand Down
3 changes: 3 additions & 0 deletions crates/feedback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/feedback.rs"

Expand Down
3 changes: 3 additions & 0 deletions crates/file_finder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions crates/fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/fs.rs"

Expand Down
6 changes: 4 additions & 2 deletions crates/fsevent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 3 additions & 0 deletions crates/fuzzy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/fuzzy.rs"
doctest = false
Expand Down
3 changes: 3 additions & 0 deletions crates/git/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
publish = false
license = "GPL-3.0-or-later"

[lints]
workspace = true

[lib]
path = "src/git.rs"

Expand Down
Loading

0 comments on commit 22fe039

Please sign in to comment.