rust-lang / rust-lang/rust-analyzer

`include!` macro silently gives empty string if destination file is outside of the crate

Open
#17,040 8 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: 0.3.1916-standalone (7a8374c16 2024-04-08)

rustc version: rustc 1.77.2 (25ef9e3d8 2024-04-09)

editor or extension: VSCode, rust-analyzer v0.3.1916

relevant settings: N/A?

repository link (if public, optional): https://github.com/saschanaz/rust-include-repro

code snippet to reproduce: (Please refer to the repo to see the exact file tree)

include!("in-src.rs");
include!("../in-crate.rs");
include!("../../in-workspace.rs");

fn main() {
    in_src();
    in_crate();
    in_workspace();
}

The issue is threefold:

  1. The function name of in_workspace does not autocomplete in main()
  2. Hovering over in_workspace(); shows nothing
  3. Clicking "Inline macro" feature from light bulb menu for include!("../../in-workspace.rs") just deletes the line

The build result works as expected, so this should be rust-analyzer specific.

See also: https://bugzilla.mozilla.org/show_bug.cgi?id=1890431

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

Begin with the linked minimal reproduction and trace include!(...) handling for in-src.rs, ../in-crate.rs, and ../../in-workspace.rs. Compare autocomplete, hover, and Inline macro behavior; done means the workspace-outside destination is analyzed consistently without deleting the macro line.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.