async-std icon indicating copy to clipboard operation
async-std copied to clipboard

Seems difficult to get a minimal set of features working

Open otavio opened this issue 4 years ago • 4 comments

I am trying to reduce the dependencies of our project and I tried to use the minimal set of features for it.

I get this error:

error[E0425]: cannot find function `block_on` in module `task`
  --> src/gstreamer.rs:18:15
   |
18 |         task::block_on(async move {
   |               ^^^^^^^^ not found in `task`

error[E0425]: cannot find function `sleep` in module `task`
  --> src/gstreamer.rs:79:11
   |
79 |     task::sleep(std::time::Duration::from_secs(1)).await;
   |           ^^^^^ not found in `task`
   |
help: possible candidate is found in another module, you can import it into scope
   |
6  | use std::thread::sleep;
   |

error[E0425]: cannot find function `spawn` in module `task`
  --> src/gstreamer.rs:93:11
   |
93 |     task::spawn(feed_pipeline(playbin.clone(), manifest));
   |           ^^^^^ not found in `task`
   |
help: possible candidate is found in another module, you can import it into scope
   |
6  | use std::thread::spawn;
   |

error[E0425]: cannot find function `block_on` in module `async_std::task`
  --> src/main.rs:52:1
   |
52 | #[async_std::main]
   | ^^^^^^^^^^^^^^^^^^ not found in `async_std::task`
   |
   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

and I am setting it as:

# Cargo.toml
async-std = { version = "1.5.0", default-features = false, features = ["std", "attributes", "unstable"] }

otavio avatar Apr 29 '20 05:04 otavio

@otavio Hello. ¿Do you found a solution?

TonyMendizabal avatar Jun 20 '21 04:06 TonyMendizabal

I didn't. I'd love to learn what would be the minimal.

otavio avatar Jun 20 '21 19:06 otavio

Same problem.

kekeimiku avatar Mar 29 '22 13:03 kekeimiku

The reason is using the cfg_default! macro, which conditionally compiles depending on whether the "default" feature is enabled, which is a very bad idea, since it makes it impossible to pick and choose single features. Each sub-module should really depend on the minimal subset of features that it needs, instead on a forced superset.

Right now disabling the default feature and enabling all the features contained in it doesn't work at all, and many modules like fs, path, net, and many task submodules doesn't get compiled.

# This doesn't work:
async-std = { version = "1.12.0", default-features = false, features = ["std", "async-global-executor", "async-io", "futures-lite", "kv-log-macro", "log", "pin-project-lite", "gloo-timers"] }
# But it should compile everything the same as:
# async-std = { version = "1.12.0", default-features = false, features = ["default"] }

joseluis avatar Jul 04 '23 11:07 joseluis