Skip to content

New files in tests/ give "This file is not included in any crates" #18279

Open
@9999years

Description

@9999years

When I open a new file in tests/ (e.g. tests/my_test.rs), rust-analyzer gives an unlinked file diagnostic:

This file is not included in any crates, so rust-analyzer can't offer IDE services.

If you're intentionally working on unowned files, you can silence this warning by adding "unlinked-file" to rust-analyzer.diagnostics.disabled in your settings. [unlinked-file]

Once I restart the rust-analyzer process, the file is loaded correctly. This may be related to #9910, but I only have this issue with files under the tests/ directory.

rust-analyzer version: rust-analyzer 2024-09-02

rustc version: rustc 1.81.0 (eeb90cda1 2024-09-04)

editor or extension: Neovim with native LSP

relevant settings: https://github.com/9999years/dotfiles/blob/205a5d1738c5520759512bf82454d04059b3b1b3/config/nvim/init.lua#L911-L949

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-project-modelproject model and workspace related issuesC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions