rust-lang / rust-lang/rust-analyzer

Unlinked file error on main.rs with both lib.rs and main.rs if project is inside of another project

Open
#13,844 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

I have a cargo project that is both a library and binary, and when I try to edit main.rs, rust-anazlyer says that it is not included in the module tree, only getting rid of the error and analyzing the file if I add main.rs to lib.rs with mod main. Both cargo clippy --bins and cargo clippy --lib return no errors.

edit: Forgot to mention that the project is inside of an existing project, and it works fine if the project is opened by itself

Cargo.toml:

[package]
name = "ak-server"
version = "0.1.0"
edition = "2021"

File tree:

main/
  main.rs
  Cargo.toml
  ak-server/
    src/
      lib.rs
      main.rs
    Cargo.toml

Versions

rustc 1.67.0-nightly (e75aab045 2022-11-09)
rust-analyzer version: 0.3.1325-standalone (9ed1829f1 2022-12-17)

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 nested project layout using the shown Cargo.toml files and src/lib.rs and src/main.rs, then compare it with opening ak-server by itself. Start by tracing how rust-analyzer discovers the nested Cargo project; done means main.rs is analyzed without adding mod main to lib.rs, while cargo clippy --bins and --lib remain clean.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.