Skip to content

Commit

Permalink
fix(adding_lints): usage of early vs late lint pass (rust-lang#13955)
Browse files Browse the repository at this point in the history
changelog: none

This PR fixes explaining the difference in usage between early and late
lint passes in the book.
  • Loading branch information
flip1995 authored Jan 13, 2025
2 parents dc99034 + 16ee014 commit 0db6411
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,11 @@ This is good, because it makes writing this particular lint less complicated.
We have to make this decision with every new Clippy lint. It boils down to using
either [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass].

In short, the `EarlyLintPass` runs before type checking and
[HIR](https://rustc-dev-guide.rust-lang.org/hir.html) lowering and the `LateLintPass`
has access to type information. Consider using the `LateLintPass` unless you need
something specific from the `EarlyLintPass`.
`EarlyLintPass` runs before type checking and
[HIR](https://rustc-dev-guide.rust-lang.org/hir.html) lowering, while `LateLintPass`
runs after these stages, providing access to type information. The `cargo dev new_lint` command
defaults to the recommended `LateLintPass`, but you can specify `--pass=early` if your lint
only needs AST level analysis.

Since we don't need type information for checking the function name, we used
`--pass=early` when running the new lint automation and all the imports were
Expand Down

0 comments on commit 0db6411

Please sign in to comment.