rust-lang / rust-lang/rust-analyzer

"Find All References" doesn't work with "use X as Y" aliases

Open
#16,850 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

rust-analyzer version: rust-analyzer version: 0.0.0 (b3b9b53df 2024-02-29)

rustc version: rustc 1.78.0-nightly (42825768b 2024-03-08)

relevant settings: N/A, although I interact with rust-analyzer through VSCode if that's relevant. The extension version I'm using is 0.3.1418.

repository link (if public, optional): N/A

code snippet to reproduce:

struct Foo;
use Foo as FooRenamed;

struct Bar(FooRenamed);

Expected behaviour when invoking Find All References on FooRenamed is that the usage in Bar shows up. The actual behaviour is that direct usages of "Foo" are searched for, which does not include the usage in Bar.

In fact, the reference in Bar can't be found at all using Find All References, as searching for usages of Foo doesn't reveal it either.

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

Reproduce the Rust snippet and begin at rust-analyzer’s Find All References request path, then trace how use Foo as FooRenamed is represented during reference lookup. Add a regression test for the alias and verify that Find All References on FooRenamed includes the usage in Bar.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.