@@ -18,12 +18,13 @@ because that's clearly a non-descriptive name.
1818 - [ Cargo lints] ( #cargo-lints )
1919 - [ Rustfix tests] ( #rustfix-tests )
2020 - [ Testing manually] ( #testing-manually )
21+ - [ Running directly] ( #running-directly )
2122 - [ Lint declaration] ( #lint-declaration )
2223 - [ Lint registration] ( #lint-registration )
2324 - [ Lint passes] ( #lint-passes )
2425 - [ Emitting a lint] ( #emitting-a-lint )
2526 - [ Adding the lint logic] ( #adding-the-lint-logic )
26- - [ Specifying the lint's minimum supported Rust version (MSRV)] ( #specifying-the-lints-minimum-supported-rust-version-msrv )
27+ - [ Specifying the lint's minimum supported Rust version (MSRV)] ( #specifying-the-lints-minimum-supported-rust-version-- msrv- )
2728 - [ Author lint] ( #author-lint )
2829 - [ Print HIR lint] ( #print-hir-lint )
2930 - [ Documentation] ( #documentation )
@@ -186,6 +187,15 @@ cargo dev lint input.rs
186187from the working copy root. With tests in place, let's have a look at
187188implementing our lint now.
188189
190+ ## Running directly
191+
192+ While it's easier to just use ` cargo dev lint ` , it might be desirable to get
193+ ` target/release/cargo-clippy ` and ` target/release/clippy-driver ` to work as well in some cases.
194+ By default, they don't work because clippy dynamically links rustc. To help them find rustc,
195+ add the path printed by` rustc --print target-libdir ` (ran inside this workspace so that the rustc version matches)
196+ to your library search path.
197+ On linux, this can be done by setting the ` LD_LIBRARY_PATH ` environment variable to that path.
198+
189199## Lint declaration
190200
191201Let's start by opening the new file created in the ` clippy_lints ` crate at
@@ -265,7 +275,7 @@ When declaring a new lint by hand and `cargo dev update_lints` is used, the lint
265275pass may have to be registered manually in the ` register_plugins ` function in
266276` clippy_lints/src/lib.rs ` :
267277
268- ``` rust
278+ ``` rust,ignore
269279store.register_early_pass(|| Box::new(foo_functions::FooFunctions));
270280```
271281
@@ -291,7 +301,7 @@ either [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass].
291301
292302In short, the ` LateLintPass ` has access to type information while the
293303` EarlyLintPass ` doesn't. If you don't need access to type information, use the
294- ` EarlyLintPass ` . The ` EarlyLintPass ` is also faster. However linting speed
304+ ` EarlyLintPass ` . The ` EarlyLintPass ` is also faster. However, linting speed
295305hasn't really been a concern with Clippy so far.
296306
297307Since we don't need type information for checking the function name, we used
@@ -308,7 +318,7 @@ implementation of the lint logic.
308318
309319Let's start by implementing the ` EarlyLintPass ` for our ` FooFunctions ` :
310320
311- ``` rust
321+ ``` rust,ignore
312322impl EarlyLintPass for FooFunctions {
313323 fn check_fn(&mut self, cx: &EarlyContext<'_>, fn_kind: FnKind<'_>, span: Span, _: NodeId) {
314324 // TODO: Emit lint here
@@ -327,10 +337,10 @@ variety of lint emission functions. They can all be found in
327337[ ` clippy_utils/src/diagnostics.rs ` ] [ diagnostics ] .
328338
329339` span_lint_and_help ` seems most appropriate in this case. It allows us to
330- provide an extra help message and we can't really suggest a better name
340+ provide an extra help message, and we can't really suggest a better name
331341automatically. This is how it looks:
332342
333- ``` rust
343+ ``` rust,ignore
334344impl EarlyLintPass for FooFunctions {
335345 fn check_fn(&mut self, cx: &EarlyContext<'_>, fn_kind: FnKind<'_>, span: Span, _: NodeId) {
336346 span_lint_and_help(
@@ -469,7 +479,7 @@ the value from `clippy.toml`. This can be accounted for using the
469479` extract_msrv_attr!(LintContext) ` macro and passing
470480` LateContext ` /` EarlyContext ` .
471481
472- ``` rust
482+ ``` rust,ignore
473483impl<'tcx> LateLintPass<'tcx> for ManualStrip {
474484 fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
475485 ...
@@ -483,7 +493,7 @@ the lint's test file, `tests/ui/manual_strip.rs` in this example. It should
483493have a case for the version below the MSRV and one with the same contents but
484494for the MSRV version itself.
485495
486- ``` rust
496+ ``` rust,ignore
487497...
488498
489499#[clippy::msrv = "1.44"]
@@ -514,7 +524,7 @@ define_Conf! {
514524
515525If you have trouble implementing your lint, there is also the internal ` author `
516526lint to generate Clippy code that detects the offending pattern. It does not
517- work for all of the Rust syntax, but can give a good starting point.
527+ work for all the Rust syntax, but can give a good starting point.
518528
519529The quickest way to use it, is the [ Rust playground:
520530play.rust-lang.org] [ author_example ] . Put the code you want to lint into the
@@ -607,7 +617,7 @@ output in the `stdout` part.
607617
608618## PR Checklist
609619
610- Before submitting your PR make sure you followed all of the basic requirements:
620+ Before submitting your PR make sure you followed all the basic requirements:
611621
612622<!-- Sync this with `.github/PULL_REQUEST_TEMPLATE` -->
613623
@@ -627,7 +637,7 @@ for some users. Adding a configuration is done in the following steps:
627637
6286381 . Adding a new configuration entry to [ ` clippy_lints::utils::conf ` ] like this:
629639
630- ``` rust
640+ ``` rust,ignore
631641 /// Lint: LINT_NAME.
632642 ///
633643 /// <The configuration field doc comment>
@@ -680,7 +690,7 @@ for some users. Adding a configuration is done in the following steps:
680690 configuration value is now cloned or copied into a local value that is then
681691 passed to the impl struct like this :
682692
683- ```rust
693+ ```rust , ignore
684694 // Default generated registration:
685695 store . register_* _pass (|| box module :: StructName );
686696
0 commit comments