diff options
| author | bors <bors@rust-lang.org> | 2022-10-23 22:18:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-10-23 22:18:04 +0000 |
| commit | 5b09d4e1f7082aff024faf27263f78e7fc7190a2 (patch) | |
| tree | 782371e9ebdc91ab07d606175e4fa5e5517220b4 /tests | |
| parent | 191c9839f0bad1c2bfec17d55bacb94d2e83f1a1 (diff) | |
| parent | 81345669887b53c63d0d6a50721e640197d90c66 (diff) | |
| download | rust-5b09d4e1f7082aff024faf27263f78e7fc7190a2.tar.gz rust-5b09d4e1f7082aff024faf27263f78e7fc7190a2.zip | |
Auto merge of #9541 - Alexendoo:declare-proc-macro, r=flip1995
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
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/versioncheck.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/versioncheck.rs b/tests/versioncheck.rs index a6d8d0307ce..7a85386a3df 100644 --- a/tests/versioncheck.rs +++ b/tests/versioncheck.rs @@ -6,7 +6,7 @@ use rustc_tools_util::VersionInfo; use std::fs; #[test] -fn check_that_clippy_lints_and_clippy_utils_have_the_same_version_as_clippy() { +fn consistent_clippy_crate_versions() { fn read_version(path: &str) -> String { let contents = fs::read_to_string(path).unwrap_or_else(|e| panic!("error reading `{path}`: {e:?}")); contents @@ -24,11 +24,16 @@ fn check_that_clippy_lints_and_clippy_utils_have_the_same_version_as_clippy() { } let clippy_version = read_version("Cargo.toml"); - let clippy_lints_version = read_version("clippy_lints/Cargo.toml"); - let clippy_utils_version = read_version("clippy_utils/Cargo.toml"); - assert_eq!(clippy_version, clippy_lints_version); - assert_eq!(clippy_version, clippy_utils_version); + let paths = [ + "declare_clippy_lint/Cargo.toml", + "clippy_lints/Cargo.toml", + "clippy_utils/Cargo.toml", + ]; + + for path in paths { + assert_eq!(clippy_version, read_version(path), "{path} version differs"); + } } #[test] |
