rust-lang / rust-lang/rust-analyzer

Use EarlyPassLints from rustc (and clippy)

Open
#10,971 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics C-Architecture C-feature E-hard fun S-unactionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Some lints in rustc work via implementing the EarlyPassLint trait. This trait only needs ast level data and not types or hir level data, so it should be easy to port it, I think.

If this kind of lint implementation (each lint provides some functions, for example check_expr, check_block, check_ident, ... function, that RA should call it for each changed expression, block, ...) is ok performance-wise for ide usage (I think a small change leads to small expressions become invalidated, but I'm not sure), reusing them from rustc and clippy would save some effort and bring some consistency between rustc and RA diagnostics. With future unification of RA and rustc, we can think about porting other lints as well.

  • list of rustc lints that implements EarlyPassLint: link
  • list of clippy lints that implements EarlyPassLint: link (Some of these lints are already implemented in RA, like redundant field name, we may want to select a few others)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with rustc_lint::passes::EarlyLintPass and its check_expr, check_block, and check_ident entry points, then compare the linked rustc and Clippy implementors with RA’s existing redundant-field-name lint. Before implementation, establish whether this invalidation model is viable for IDE use and select a concrete subset; the issue does not define a target lint, files, tests, or completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.