rust-lang / rust-lang/rust-analyzer

Add AST-based fallback path for symbols

Open
#12,340 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-ide C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Symbol search is functionality which allows you to enter query like Aex and get fuzzy search results for all symbols with matching name (like AstExpr). Originally, it was syntax based, but that was missing symbols declared by macros. In https://github.com/rust-lang/rust-analyzer/pull/10872 we rewrote the infra to be based on semantics. This generally works much better, but has one drawback: if we don't have semantic information for a file, we don't get symbols for it.

There are three cases where we lack semantics:

  • when file is not a part of the module tree
  • when the project model is broken (typo in Cargo.toml)
  • when we are just loading the project

For all three cases, it would be much better if we fell back on the older, syntax based infra.

I think the logic we want here is:

  • collect all semantic modules
  • collect all semantic symbols from modules
  • collect all files (which doesn't require semantic info)
  • key idea: for each file, which isn't a file of some module, collect syntactic symbols

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

Start by reading the semantic and syntax-based symbol-search infrastructure described in rust-analyzer#10872, then trace how semantic modules and files are collected. Implement the fallback for files that are not part of a semantic module, and verify that semantic symbols remain unchanged while those files contribute syntactic symbols.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools, search
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.