rust-lang / rust-lang/rust-analyzer
goto-definition for `include*!(expr)`, where `expr` is not a string literal
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Related: #3767, #5871,#9149.
At the moment, rust-analyzer already supports goto-definition when including a file with a string literal. However the following case is not addressed:
// from https://docs.rs/phf_codegen/0.11.2/phf_codegen/#examples
include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
Not having support for this case is especially inconvenient because OUT_DIR may change for each build, and finding the correct file in target/$PROFILE/build/$CRATE_NAME-$HASH/out is not the easiest thing in the world.
Right now I deliberately keep an unused item in the generated file, so that rust-analyzer marks it as containing a warning, allowing me to find it quickly in the file tree. Obviously this is a terrible hack and won't work for non Rust source files.
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
Start by tracing rust-analyzer's existing goto-definition support for include! with string literals, then review related issues #3767, #5871, and #9149. The work is done when include!(concat!(env!("OUT_DIR"), "/codegen.rs")) can resolve to the generated file without requiring a string literal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100