You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a crate specifies a platform specific dependency, like so:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1.0", default-features = false, features = ["net", "time"] }
This would enable the features net and time for tokio, if another crate depends on tokio in the same workspace, compilation with --target wasm32-unknown-unknown would fail, as the features net and time are erroneously enabled for the target.
Steps
Create a workspace with two crates, mylib1 and mylib2.
$ cat mylib1/Cargo.toml
[package]
name = "mylib1"version = "0.1.0"edition = "2021"
[dependencies]
tokio = { version = "1.0", default-features = false, features = [ "sync" ] }
# mylib2 = { path = "../mylib2" } <- doesn't seem to matter
$ cat mylib2/Cargo.toml
[package]
name = "mylib2"version = "0.1.0"edition = "2021"
[target.'cfg(not(target_arch="wasm32"))'.dependencies]
tokio = { version = "1.0", default-features = false, features = ["net", "time"] }
Then run cargo check --target wasm32-unknown-unknown, it would fail to compile mio, which is enabled by tokio/net.
Possible Solution(s)
do not enable features for dependencies that are platform dependent
Problem
When a crate specifies a platform specific dependency, like so:
This would enable the features
net
andtime
fortokio
, if another crate depends ontokio
in the same workspace, compilation with--target wasm32-unknown-unknown
would fail, as the featuresnet
andtime
are erroneously enabled for the target.Steps
Create a workspace with two crates,
mylib1
andmylib2
.Then run
cargo check --target wasm32-unknown-unknown
, it would fail to compilemio
, which is enabled bytokio/net
.Possible Solution(s)
do not enable features for dependencies that are platform dependent
Notes
Related: #9863
This occurs when using
reqwest
andtokio
in a workspace.Version
The text was updated successfully, but these errors were encountered: