rust-lang / rust-lang/rust-analyzer

if a package becomes a lib+bin package mid-edit, ra requires a restart to notice

Open
#19,849 0 comments 0 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 1.86.0 (05f9846 2025-03-31)

rustc version: rustc 1.86.0 (05f9846f8 2025-03-31)

editor or extension: emacs eglot

relevant settings: eglot-ensure in rust-mode-hook

reproduction steps

  1. cargo init --lib
  2. open the newly created src/lib.rs in editor
  3. open (nonexistent) src/main.rs in editor, add fn main() {}, save file
  4. you will still be getting an unlined-file error and all LSP features will not work except highlighting error/warning lines

workaround: restart rust-analyzer (in emacs this can be done with M-x eglot)

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 issue with cargo init --lib, then create and save src/main.rs while src/lib.rs is open. Start by tracing how rust-analyzer discovers package targets after workspace changes; done means the new binary target is recognized without restarting and LSP features work in src/main.rs.

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
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.