lint-creator

Installation
SKILL.md

Adding a dylint to tooling/lints

Before writing anything

  1. Check whether clippy already covers the pattern (search https://rust-lang.github.io/rust-clippy/master/). If it does, stop and report that to the user instead of writing a redundant lint.

Layout

  • One module per lint: src/<lint_name>.rs, declared in src/lib.rs.
  • Register the lint in register_lints in src/lib.rs: add it to the lint_store.register_lints(&[...]) slice and add a register_late_pass call.
  • Use src/notify_in_render.rs as the template: rustc_session::declare_lint! with ### What it does / ### Why is this bad? doc sections, impl_lint_pass!, and a LateLintPass impl that bails early with let ... else / early returns.
  • Do NOT copy the diagnostics style of shared_string_from_str_literal in lib.rs — it predates the rules below (it emits a machine-applicable suggestion). The two lints living directly in lib.rs also predate the one-module-per-lint rule.
  • Reuse the helpers in src/render_helpers.rs (is_directly_in_render_method, is_gpui_context) for render/gpui checks.

Diagnostics rules

  • Flag only; never suggest how to fix, and never use Applicability::MachineApplicable.
  • Keep detection and reporting as simple as possible: prefer span_lint with a one-sentence message over span_lint_and_then with notes.
  • Skip macro-expanded code (expr.span.from_expansion()).
Installs
8
GitHub Stars
96.1K
First Seen
Jul 18, 2026