I want to pass
--cfg spec when checking my code. I found
cargo.features, but that appears to force the usage of "feature".
I think currently the only way to do this is to set it from a build script
does RA allow passing arbitrary rustflags?
RUSTFLAGS is passed through, but we ignore it
Unfortunate. It looks like it _was_ supported at some point? https://github.com/rust-analyzer/rust-analyzer/issues/1073
Oh, maybe that's literally also just features
Nothing was removed here, that issue was closed when basic support for handling
Should I open an issue for supporting additional
I did see that there's an option for
cfg when not using Cargo — https://rust-analyzer.github.io/manual.html#non-cargo-based-projects
Should be perhaps pares RUSTFLAGS?
@Jake Goulding what do you use to set this for cargo? RUSTFLAGS or something else?
You can use
rustc --print cfg $RUSTFLAGS to get the list of all enabled cfgs.
wow, that's nice, that means that the impl is trivial, as we are already running
Jake Goulding what do you use to set this for cargo? RUSTFLAGS or something else?
I am running:
CARGO_BUILD_PIPELINING=false cargo rustc -- --crate-type=bin --cfg=spec
(sorry for long delays; been in a lot of training :wink:)
Hm, that's tricky -- while
RUSFLAGS are global, config via
rustc I think applies only to one target. Yup:
The specified args will all be passed to the final compiler invocation, not any of the dependencies.
So the config we want here would be a map from (package, target) pairs to additional cfg. It shouldn't be that hard to implement, but would be quite annoing, especially because there's no clean way to identifiy a package/target pair (cargo identifies them implicitly, via --lib, --bin, etc args)
For my particular case, the cfg could go to every crate. It’s the exact same concept as cfg(test).
People would want it to effectively always be on in their editor if they were using this.