Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Rust analyzer seems to use resolver = "1"
Hello,
Today I encountered a weird behavior when trying to enable features based on a custom --cfg context="cond_a"
flag. When building with cargo build
the correct features gets enabled, but rust-analyzer in VSCode thinks all the features are enabled.
I made a project to reproduce the problem: GitHub - nponsard/rust-cfg-testing
When opening rust-analyzer-test/src/main.rs
, I can see that the lines that does not match the "context flags" are disabled, but rust analyzer complains about the function other_crate::test_print()
expecting 4 arguments.
This means that for rust-analyzer both features are enabled. These features should be enabled only when a certain "context" flag is set:
[dependencies]
other-crate = { path = "../other-crate" }
[target.'cfg(context = "cond_a")'.dependencies]
other-crate = { path = "../other-crate", features = ["a"] }
[target.'cfg(context = "cond_b")'.dependencies]
other-crate = { path = "../other-crate", features = ["b"] }
This sounds like cargo build
is using the resolver version 2 but rust-analyzer is using the resolver version 1.
Is this a bug or did I configure something wrong ?
2 posts - 1 participant
🏷️ Rust_feed