rust-lang / rust-lang/rust-analyzer
using a indirection via a generated include file path
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I recently wrote https://github.com/drahnr/expander to aid in debugging proc-macros during the development cycle - it essentially replaces the generated TokenStream with a include!(env!(OUT_DIR) "/foo-${hash}.rs" ) which in turn contains the generated token tree, which in turn allows for much easier debugging since the rustc errors point directly to issues in the generated TokenStream.
Now when I use this with a custom macro, that wraps tracing::{warn,info,debug,..} calls, it always shows them as errors, even if .dry(!cfg!("expand")) should evaluate to true.
As a consequence, rust-analyzer looks for the files to be included, that do not exist and I get a lot of red squiggles where there should be none.

The proc-macro in question using expander and exhibiting the issue:
https://github.com/paritytech/polkadot/blob/master/node/gum/proc-macro/Cargo.toml#L25-L29
One usage location (as seen in the screenshot):
rust-analyzer version: rust-analyzer version: b594f9c44 2022-03-21 stable
rustc version: (eg. output of rustc -V) rustc 1.59.0 (9d1b2106e 2022-02-23)
relevant settings: nothing special afaik
This all makes sense since I had ticked the --all-features, so this actually checks out.
But I do lack the ability to have something along the lines of "enable all features except for x on crate y"
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 reproducing the issue with the linked expander-based proc-macro and rust-analyzer's --all-features behavior. Read the feature-configuration handling relevant to the linked Polkadot Cargo.toml and usage location. Done should mean users can enable all features while excluding a feature for a specified crate, without diagnostics for intentionally absent generated include files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100