@@ -16,6 +16,7 @@ because that's clearly a non-descriptive name.
1616 - [ Edition 2018 tests] ( #edition-2018-tests )
1717 - [ Testing manually] ( #testing-manually )
1818 - [ Lint declaration] ( #lint-declaration )
19+ - [ Lint registration] ( #lint-registration )
1920 - [ Lint passes] ( #lint-passes )
2021 - [ Emitting a lint] ( #emitting-a-lint )
2122 - [ Adding the lint logic] ( #adding-the-lint-logic )
@@ -43,9 +44,9 @@ take a look at our [lint naming guidelines][lint_naming]. To get started on this
4344lint you can run `cargo dev new_lint --name=foo_functions --pass=early
4445--category=pedantic` (category will default to nursery if not provided). This
4546command will create two files: ` tests/ui/foo_functions.rs ` and
46- ` clippy_lints/src/foo_functions.rs ` , as well as run ` cargo dev update_lints ` to
47- register the new lint. For cargo lints, two project hierarchies (fail/pass) will
48- be created by default under ` tests/ui-cargo ` .
47+ ` clippy_lints/src/foo_functions.rs ` , as well as
48+ [ registering the lint] ( #lint-registration ) . For cargo lints, two project
49+ hierarchies (fail/pass) will be created by default under ` tests/ui-cargo ` .
4950
5051Next, we'll open up these files and add our lint!
5152
@@ -220,32 +221,34 @@ declare_lint_pass!(FooFunctions => [FOO_FUNCTIONS]);
220221impl EarlyLintPass for FooFunctions {}
221222```
222223
223- Normally after declaring the lint, we have to run ` cargo dev update_lints ` ,
224- which updates some files, so Clippy knows about the new lint. Since we used
225- ` cargo dev new_lint ... ` to generate the lint declaration, this was done
226- automatically. While ` update_lints ` automates most of the things, it doesn't
227- automate everything. We will have to register our lint pass manually in the
228- ` register_plugins ` function in ` clippy_lints/src/lib.rs ` :
224+ [ declare_clippy_lint ] : https://github.com/rust-lang/rust-clippy/blob/557f6848bd5b7183f55c1e1522a326e9e1df6030/clippy_lints/src/lib.rs#L60
225+ [ example_lint_page ] : https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
226+ [ lint_naming ] : https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
227+ [ category_level_mapping ] : https://github.com/rust-lang/rust-clippy/blob/557f6848bd5b7183f55c1e1522a326e9e1df6030/clippy_lints/src/lib.rs#L110
228+
229+ ## Lint registration
230+
231+ When using ` cargo dev new_lint ` , the lint is automatically registered and
232+ nothing more has to be done.
233+
234+ When declaring a new lint by hand and ` cargo dev update_lints ` is used, the lint
235+ pass may have to be registered manually in the ` register_plugins ` function in
236+ ` clippy_lints/src/lib.rs ` :
229237
230238``` rust
231- store . register_early_pass (|| box foo_functions :: FooFunctions );
239+ store . register_early_pass (|| Box :: new ( foo_functions :: FooFunctions ) );
232240```
233241
234242As one may expect, there is a corresponding ` register_late_pass ` method
235243available as well. Without a call to one of ` register_early_pass ` or
236244` register_late_pass ` , the lint pass in question will not be run.
237245
238- One reason that ` cargo dev ` does not automate this step is that multiple lints
239- can use the same lint pass, so registering the lint pass may already be done
240- when adding a new lint. Another reason that this step is not automated is that
241- the order that the passes are registered determines the order the passes
242- actually run, which in turn affects the order that any emitted lints are output
243- in.
244-
245- [ declare_clippy_lint ] : https://github.com/rust-lang/rust-clippy/blob/557f6848bd5b7183f55c1e1522a326e9e1df6030/clippy_lints/src/lib.rs#L60
246- [ example_lint_page ] : https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
247- [ lint_naming ] : https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
248- [ category_level_mapping ] : https://github.com/rust-lang/rust-clippy/blob/557f6848bd5b7183f55c1e1522a326e9e1df6030/clippy_lints/src/lib.rs#L110
246+ One reason that ` cargo dev update_lints ` does not automate this step is that
247+ multiple lints can use the same lint pass, so registering the lint pass may
248+ already be done when adding a new lint. Another reason that this step is not
249+ automated is that the order that the passes are registered determines the order
250+ the passes actually run, which in turn affects the order that any emitted lints
251+ are output in.
249252
250253## Lint passes
251254
0 commit comments