Skip to content

Commit

Permalink
Auto merge of #9541 - Alexendoo:declare-proc-macro, r=flip1995
Browse files Browse the repository at this point in the history
Generate lint categories and explanations with `declare_clippy_lint`

This means contributors will no longer have to run `cargo dev update_lints` after changing a lints documentation or its category, which may also mean fewer merge conflicts in general

It works by swapping `declare_clippy_lint` out for a `proc_macro` of the same name. The proc macro emits a `LintInfo` alongside the generated `Lint` which are gathered into `declared_lint::LINTS`. The categories/explanations are then read from `declared_lint::LINTS` at runtime

The removal of `src/docs` is split into a separate commit to be more easily ignored

It is slightly slower though, adding a bit under a second to build time. Less noticeable in full builds or with a slower linker (benchmark uses mold)

```bash
hyperfine --warmup 2 \
    --parameter-list commit "declare-proc-macro,master" \
    --command-name "{commit}" \
    --setup "git checkout {commit}" \
    --prepare "touch clippy_lints/src/lib.rs" \
    "cargo build"
```
```
Benchmark 1: declare-proc-macro
  Time (mean ± σ):     10.731 s ±  0.154 s    [User: 7.739 s, System: 1.791 s]
  Range (min … max):   10.598 s … 11.125 s    10 runs

Benchmark 2: master
  Time (mean ± σ):      9.422 s ±  0.094 s    [User: 7.183 s, System: 1.732 s]
  Range (min … max):    9.287 s …  9.624 s    10 runs

Summary
  'master' ran
    1.14 ± 0.02 times faster than 'declare-proc-macro'
```

r? `@flip1995`
cc `@llogiq` for `--explain`

changelog: none
  • Loading branch information
bors committed Oct 23, 2022
2 parents 191c983 + 8134566 commit 5b09d4e
Show file tree
Hide file tree
Showing 603 changed files with 958 additions and 15,907 deletions.
253 changes: 30 additions & 223 deletions clippy_dev/src/update_lints.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ edition = "2021"
[dependencies]
cargo_metadata = "0.14"
clippy_utils = { path = "../clippy_utils" }
declare_clippy_lint = { path = "../declare_clippy_lint" }
if_chain = "1.0"
itertools = "0.10.1"
pulldown-cmark = { version = "0.9", default-features = false }
Expand Down
620 changes: 620 additions & 0 deletions clippy_lints/src/declared_lints.rs

Large diffs are not rendered by default.

370 changes: 0 additions & 370 deletions clippy_lints/src/lib.register_all.rs

This file was deleted.

11 changes: 0 additions & 11 deletions clippy_lints/src/lib.register_cargo.rs

This file was deleted.

111 changes: 0 additions & 111 deletions clippy_lints/src/lib.register_complexity.rs

This file was deleted.

78 changes: 0 additions & 78 deletions clippy_lints/src/lib.register_correctness.rs

This file was deleted.

22 changes: 0 additions & 22 deletions clippy_lints/src/lib.register_internal.rs

This file was deleted.

Loading

0 comments on commit 5b09d4e

Please sign in to comment.