Problem
I have project in a workspace that has something like the following Cargo.toml:
[package]
name = "bug"
version = "0.1.0"
edition = "2021"
[dependencies]
[target.'cfg(target_arch = "wasm32")'.dependencies]
tokio = { version = "1", features = ["sync"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = ["net"] }
When I was running cargo build --target wasm32-unknown-unknown then Tokio's net feature got enabled too and I was getting compilation errors because of mio crate.
This is an issue only if the project is in a workspace.
Steps
git clone https://github.com/oblique/cargo-features-bug
cargo build --target wasm32-unknown-unknown
Possible Solution(s)
No response
Notes
I created a minimal example: https://github.com/oblique/cargo-features-bug
Version
cargo 1.71.0 (cfd3bbd8f 2023-06-08)
release: 1.71.0
commit-hash: cfd3bbd8fe4fd92074dfad04b7eb9a923646839f
commit-date: 2023-06-08
host: x86_64-unknown-linux-gnu
libgit2: 1.6.4 (sys:0.17.1 vendored)
libcurl: 8.0.1-DEV (sys:0.4.61+curl-8.0.1 vendored ssl:OpenSSL/1.1.1t)
ssl: OpenSSL 1.1.1t 7 Feb 2023
os: Arch Linux Rolling Release [64-bit]