Skip to content

RA fails to recognize platform-specific features #15233

@akarpovskii

Description

@akarpovskii

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargocargo related issuesS-blockedStatus: marked as blocked ❌ on something else such as an RFC or other implementation work.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions