rust-lang / rust-lang/rust-analyzer

`rust-analyzer lsif` generates non-unique monikers for nested functions

Open
#22,089 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lsif/scip
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

For the following source code:

fn func() {
    fn inner_func() {}
}

fn inner_func() {
}

The following LSIF is generated. Monikers are claimed to be scheme-unique, but test::inner_func is not unique.

$ rust-analyzer lsif . | grep vertex | grep moniker
{"id":20,"type":"vertex","label":"moniker","scheme":"rust-analyzer","identifier":"test::crate","unique":"scheme","kind":"export"}
{"id":31,"type":"vertex","label":"moniker","scheme":"rust-analyzer","identifier":"test::func","unique":"scheme","kind":"export"}
{"id":42,"type":"vertex","label":"moniker","scheme":"rust-analyzer","identifier":"test::inner_func","unique":"scheme","kind":"export"}
{"id":53,"type":"vertex","label":"moniker","scheme":"rust-analyzer","identifier":"test::inner_func","unique":"scheme","kind":"export"}

The following error message seems relevant.

026-04-19T13:20:22.033153037+09:00 ERROR Encountered enclosing definition with no name def=Module(Module { id: ModuleIdLt { [salsa id]: Id(13a4f) } })

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 at the rust-analyzer lsif . entry point and reproduce the nested-function example, checking the emitted moniker vertices. Trace how enclosing definitions are named, including the reported no-name Module error; done means nested and top-level functions receive distinct scheme-unique identifiers.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.