rust-lang / rust-lang/rust-analyzer
RA fails to recognize platform-specific features
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
When different targets use different features of a create, RA considers all of them active at the same time.
Cargo.toml:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
poll-promise = { version = "0.2.0", features = ["tokio"] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = "0.4"
poll-promise = { version = "0.2.0", features = ["web"] }
main.rs:
fn main() {
let _ = poll_promise::Promise::spawn_async(async {
todo!()
}); // Expected 2 arguments, found 1
}
This is how arguments in spawn_async are defined:
pub fn spawn_async(
#[cfg(feature = "tokio")] future: impl std::future::Future<Output = T> + 'static + Send,
#[cfg(feature = "web")] future: impl std::future::Future<Output = T> + 'static,
) -> Self {
rust-analyzer version: 0.3.1575-standalone
rustc version: 1.70.0 (90c541806 2023-05-31)
relevant settings: None
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 diagnostic with the provided Cargo.toml and main.rs example, using the target-specific dependencies and features shown. Trace how rust-analyzer determines active Cargo features for different targets. Done means the example no longer reports both cfg-gated function arguments as active at once.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100