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 ?

Oh I found an issue that seems to be related on github: RA fails to recognize platform-specific features · Issue #15233 · rust-lang/rust-analyzer · GitHub

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.