rust-lang / rust-lang/rust-analyzer
`include!`ing files without `.rs` suffix does not work
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I have a project (https://gitlab.com/subplot/subplot) which has a build.rs which writes a file out to be included into the build.
The file is written out to OUT_DIR (embedded_files.inc)
In my code I have:
static EMBEDDED_FILES: &[(&str, &[u8])] = include!(concat!(env!("OUT_DIR"), "/embedded_files.inc"));
In VSCode, I have that line have the following error shown:
failed to load file `/home/dsilvers/dev-git/subplot/target/debug/build/subplot-a90f1b6ad6ba44a6/out/embedded_files.inc`
rust-analyzer(macro-error)
However, that file very much does exist, so the error is spurious. Is there a way to get rust-analyzer to find this file and stop complaining?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic in VSCode using the build.rs-generated OUT_DIR/embedded_files.inc and the shown include! expression. Start by tracing rust-analyzer's handling of include! paths without an .rs suffix; done means an existing generated file no longer produces a spurious macro-error.
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
- 35/100