mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
macros: don't take ownership of futures in macros (#5087)
This commit is contained in:
@@ -136,6 +136,21 @@ macro_rules! cfg_not_wasi {
|
||||
}
|
||||
}
|
||||
|
||||
// Manualy re-implementation of `async_assert_fn` for `poll_fn`. The macro
|
||||
// doesn't work for this particular case because constructing the closure
|
||||
// is too complicated.
|
||||
const _: fn() = || {
|
||||
let pinned = std::marker::PhantomPinned;
|
||||
let f = tokio::macros::support::poll_fn(move |_| {
|
||||
// Use `pinned` to take ownership of it.
|
||||
let _ = &pinned;
|
||||
std::task::Poll::Pending::<()>
|
||||
});
|
||||
require_send(&f);
|
||||
require_sync(&f);
|
||||
AmbiguousIfUnpin::some_item(&f);
|
||||
};
|
||||
|
||||
cfg_not_wasi! {
|
||||
mod fs {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user