Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RA fails to recognize platform-specific features #15233

Open
akarpovskii opened this issue Jul 8, 2023 · 1 comment
Open

RA fails to recognize platform-specific features #15233

akarpovskii opened this issue Jul 8, 2023 · 1 comment
Labels
A-cargo cargo related issues S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work.

Comments

@akarpovskii
Copy link

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

@akarpovskii akarpovskii added the C-bug Category: bug label Jul 8, 2023
@lowr
Copy link
Contributor

lowr commented Jul 9, 2023

The core problem is that cargo metadata lists both features as enabled. This is an issue of cargo's old feature resolver as explained in the RFC 2957 and seems to be fixed by its new resolver. However, cargo metadata does not yet use the new resolver due to complexity. Not sure if we can do anything at our end for the time being unfortunately.

cc rust-lang/cargo#9863

@lowr lowr added the A-cargo cargo related issues label Jul 9, 2023
@Veykril Veykril added S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work. and removed C-bug Category: bug labels Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo cargo related issues S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work.
Projects
None yet
Development

No branches or pull requests

3 participants