Use ::core qualified imports instead of ::std inside tokio::test macro #5973
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
At work, we have a crate in our monorepo which is
#![no_std]
for build size reasons. However, we usetokio
to test that its async functionality is functional in CI for simplicity and leave the other executor for the "real" usage of the library.In a recent
tokio
update, we started to see this error when compiling its tests:I was not immediately able to find which commit caused this, but you can observe the cause here:
tokio/tokio-macros/src/entry.rs
Lines 402 to 406 in fd7d0ad
You can reproduce the issue with this project:
Solution
Given that that
std::future
andstd::pin
are re-exports of theircore
equivalents, I propose to qualify these imports inside thetokio::test
macro with::core
instead of::std
for better compatibility. AFAIK this should not have any negative impacts for other users.By making this change, a
#![no_std]
crate can continue to smoothly usetokio
as a dev-dependency without any workarounds needed in the rest of the crate.