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

Tokio's test-util feature depends on rt, sync, and time #4035

Closed
asomers opened this issue Aug 11, 2021 · 0 comments · Fixed by #4036
Closed

Tokio's test-util feature depends on rt, sync, and time #4035

asomers opened this issue Aug 11, 2021 · 0 comments · Fixed by #4036
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug.

Comments

@asomers
Copy link
Contributor

asomers commented Aug 11, 2021

Version
List the versions of all tokio crates you are using. The easiest way to get
this information is using cargo tree subcommand:

tokio v1.9.0 (/usr/home/somers/src/rust/tokio/tokio)
├── tokio-stream v0.1.7 (/usr/home/somers/src/rust/tokio/tokio-stream)
│   └── tokio v1.9.0 (/usr/home/somers/src/rust/tokio/tokio) (*)
└── tokio-test v0.4.2 (/usr/home/somers/src/rust/tokio/tokio-test)
    ├── tokio v1.9.0 (/usr/home/somers/src/rust/tokio/tokio) (*)
    └── tokio-stream v0.1.7 (/usr/home/somers/src/rust/tokio/tokio-stream) (*)

Platform
FreeBSD 14.0-CURRENT amd64

Description
Tokio's test-util feature implicitly depends on rt, sync, and time. Attempting to compile a crate that uses test-util will fail if those other features are not included.

I tried this code:

Build an empty crate with this Cargo.toml:

[package]
name = "powersettest"
version = "0.1.0"
edition = "2018"

[dependencies]
tokio = { version = "1.9.0", default-features = false, features = ["test-util", "time"], path = "../" }

[workspace]

I expected to see this happen: It should've built

Instead, this happened:

> cargo check 
   Compiling tokio v1.9.0 (/usr/home/somers/src/rust/tokio/tokio)
error[E0425]: cannot find function `yield_now` in module `crate::task`
   --> /usr/home/somers/src/rust/tokio/tokio/src/time/clock.rs:133:22
    |
133 |         crate::task::yield_now().await;
    |                      ^^^^^^^^^ not found in `crate::task`
    |
help: consider importing one of these items
    |
31  |     use crate::loom::thread::yield_now;
    |
31  |     use std::thread::yield_now;
    |

For more information about this error, try `rustc --explain E0425`.
error: could not compile `tokio` due to previous error

Note that this bug cannot be reproduced simply by using cargo check within tokio itself due to rust-lang/cargo#4866 . Instead, you must create a separate crate. I discovered this bug by doing cargo hack check --feature-powerset --no-dev-deps.

@asomers asomers added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels Aug 11, 2021
asomers added a commit to asomers/tokio that referenced this issue Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant