rust-lang / rust-lang/rust-analyzer
Learn `cfg`s enabled in `build.rs`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Wasmtime enables cfg(compiler) when one of its compilers (Cranelift or, soon, Winch) is available and therefore JIT compilation is available. This cfg is enabled in build.rs when the cargo features for the underlying compilers are enabled. This is much easier and more future proof than writing out cfg(any(feature = "cranelift", feature = "winch")) all over the place, which is why things are done this way.
However, rust-analyzer does not treat code blocks guarded by #[cfg(compiler)] as enabled, and fails to do autocomplete/jump-to-def/etc within these regions, even though changing the cfg to the wordier cfg(any(...)) does work.
It would be nice if rust-analyzer looked at the cfgs defined by build.rs and enabled them for the project.
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 examining the referenced crates/wasmtime/build.rs, especially how it enables cfg(compiler) from compiler features, and reproduce the rust-analyzer behavior inside those guarded regions. Compare this with cfg(any(feature = "cranelift", feature = "winch")) and determine how support should be validated. Done means rust-analyzer recognizes build.rs-defined cfgs for autocomplete and jump-to-definition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100