rust-lang / rust-lang/rust-analyzer

Autofix detection and potential ghost crate issue in unlinked_file

Open
#19,403 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description:
While addressing a FIXME related to autofix detection in unlinked_file, I noticed that some files are incorrectly marked as unlinked due to what seems to be a ghost crate detection issue. This occurs when a file appears to belong to a crate but isn’t properly linked to a valid root (main.rs or lib.rs).

Key Observations:

  • is_in_crate = true, is_crate_root = false, but is_unlinked = false, yet autofix suggestions still appear.
  • Some files seem to be falsely classified as part of a crate even if they lack a proper root.
  • Modifying crate detection logic affects multiple tests, suggesting intentional behavior (e.g., for VS Code extension).

Current Status & Next Steps:

Logs & Test Output:
(See PR for details)

Would appreciate any insights on how best to resolve this while maintaining expected behavior. Thanks !

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 with the unlinked_file logic and the crate-root cases involving main.rs and lib.rs. Read PR #19398 and its reported test regressions, then inspect the affected existing tests to determine which behavior is intentional. Done means the crate and autofix classifications are agreed on and the full affected test set passes without regressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.