about summary refs log tree commit diff
path: root/src/docs/disallowed_methods.txt
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-23 22:18:04 +0000
committerbors <bors@rust-lang.org>2022-10-23 22:18:04 +0000
commit5b09d4e1f7082aff024faf27263f78e7fc7190a2 (patch)
tree782371e9ebdc91ab07d606175e4fa5e5517220b4 /src/docs/disallowed_methods.txt
parent191c9839f0bad1c2bfec17d55bacb94d2e83f1a1 (diff)
parent81345669887b53c63d0d6a50721e640197d90c66 (diff)
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 'src/docs/disallowed_methods.txt')
-rw-r--r--src/docs/disallowed_methods.txt41
1 files changed, 0 insertions, 41 deletions
diff --git a/src/docs/disallowed_methods.txt b/src/docs/disallowed_methods.txt
deleted file mode 100644
index d8ad5b6a667..00000000000
--- a/src/docs/disallowed_methods.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-### What it does
-Denies the configured methods and functions in clippy.toml
-
-Note: Even though this lint is warn-by-default, it will only trigger if
-methods are defined in the clippy.toml file.
-
-### Why is this bad?
-Some methods are undesirable in certain contexts, and it's beneficial to
-lint for them as needed.
-
-### Example
-An example clippy.toml configuration:
-```
-disallowed-methods = [
-    # Can use a string as the path of the disallowed method.
-    "std::boxed::Box::new",
-    # Can also use an inline table with a `path` key.
-    { path = "std::time::Instant::now" },
-    # When using an inline table, can add a `reason` for why the method
-    # is disallowed.
-    { path = "std::vec::Vec::leak", reason = "no leaking memory" },
-]
-```
-
-```
-// Example code where clippy issues a warning
-let xs = vec![1, 2, 3, 4];
-xs.leak(); // Vec::leak is disallowed in the config.
-// The diagnostic contains the message "no leaking memory".
-
-let _now = Instant::now(); // Instant::now is disallowed in the config.
-
-let _box = Box::new(3); // Box::new is disallowed in the config.
-```
-
-Use instead:
-```
-// Example code which does not raise clippy warning
-let mut xs = Vec::new(); // Vec::new is _not_ disallowed in the config.
-xs.push(123); // Vec::push is _not_ disallowed in the config.
-```
\ No newline at end of file