bazelbuild / bazelbuild/rules_rust
rust-project.json doesn't interact well with cfg_aliases
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
Consider uses of [cfg_aliases](https://crates.io/crates/cfg_aliases) like in [nix](https://github.com/nix-rust/nix/blob/ea012bec465a6d9341d8e4bd8b7c16100393c2aa/build.rs#L4-L28). In these cases, the build script produces rustc config options: https://github.com/katharostech/cfg_aliases/blob/ebdc78e73109d59587e1d21d319f17cf61f84168/src/lib.rs#L370
The problem is that these build scripts don't run (and I'm not sure how they could...) when the rust_analyzer code runs, so these configs that should be applied to the crate aren't. This can mean features that will be enabled at compile time don't appear enabled to the editor.
A workaround is to figure out what cfg you want to manually enable and apply them as a crate annotation.
I don't really have a solution, or at least, I don't have any that are particularly appealing. Perhaps one possibility would be to find build scripts that import cfg_aliases, and then parse out that macro invocation in the rust_analyzer tool in this repo and try to emit the appropriate configs. I suppose another approach could be to try to literally build the build scripts and then pull the cfgs that way.
Contributor guide
Assessment
This issue has not been assessed yet.