]> git.lizzy.rs Git - rust.git/blobdiff - doc/adding_lints.md
Auto merge of #5156 - flip1995:dev_add_internal, r=phansch
[rust.git] / doc / adding_lints.md
index e1f4ce016c5c0cd81de6878d9d01a20b95b1fc75..7e1263ebf22fc6d91e4dbcbfef94a34cbf10c8c2 100644 (file)
@@ -167,12 +167,12 @@ declare_clippy_lint! {
 ```
 
 * The section of lines prefixed with `///` constitutes the lint documentation
-section. This is the default documentation style and will be displayed at
-https://rust-lang.github.io/rust-clippy/master/index.html.
+  section. This is the default documentation style and will be displayed at
+  https://rust-lang.github.io/rust-clippy/master/index.html.
 * `FOO_FUNCTIONS` is the name of our lint. Be sure to follow the [lint naming
-guidelines][lint_naming] here when naming your lint. In short, the name should
-state the thing that is being checked for and read well when used with
-`allow`/`warn`/`deny`.
+  guidelines][lint_naming] here when naming your lint. In short, the name should
+  state the thing that is being checked for and read well when used with
+  `allow`/`warn`/`deny`.
 * `pedantic` sets the lint level to `Allow`.
   The exact mapping can be found [here][category_level_mapping]
 * The last part should be a text that explains what exactly is wrong with the
@@ -191,15 +191,15 @@ declare_lint_pass!(FooFunctions => [FOO_FUNCTIONS]);
 impl EarlyLintPass for FooFunctions {}
 ```
 
-Don't worry about the `name` method here. As long as it includes the name of the
-lint pass it should be fine.
-
-The new lint automation runs `update_lints`, which automates some things, but it
-doesn't automate everything. We will have to register our lint pass manually in
-the `register_plugins` function in `clippy_lints/src/lib.rs`:
+Normally after declaring the lint, we have to run `cargo dev update_lints`,
+which updates some files, so Clippy knows about the new lint. Since we used
+`cargo dev new_lint ...` to generate the lint declaration, this was done
+automatically. While `update_lints` automates most of the things, it doesn't
+automate everything. We will have to register our lint pass manually in the
+`register_plugins` function in `clippy_lints/src/lib.rs`:
 
 ```rust
-reg.register_early_lint_pass(box foo_functions::FooFunctions);
+store.register_early_pass(box foo_functions::FooFunctions);
 ```
 
 This should fix the `unknown clippy lint: clippy::foo_functions` error that we
@@ -443,7 +443,6 @@ don't hesitate to ask on Discord, IRC or in the issue/PR.
 [lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
 [category_level_mapping]: https://github.com/rust-lang/rust-clippy/blob/bd23cb89ec0ea63403a17d3fc5e50c88e38dd54f/clippy_lints/src/lib.rs#L43
 [declare_clippy_lint]: https://github.com/rust-lang/rust-clippy/blob/a71acac1da7eaf667ab90a1d65d10e5cc4b80191/clippy_lints/src/lib.rs#L39
-[compilation_stages]: https://rust-lang.github.io/rustc-guide/high-level-overview.html#the-main-stages-of-compilation
 [check_fn]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/lint/trait.EarlyLintPass.html#method.check_fn
 [early_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/lint/trait.EarlyLintPass.html
 [late_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/lint/trait.LateLintPass.html