Sha256: d346945889b7a28e774d6a19ce62d839c1213103b13b7cf9d62fbb03005713cd

Contents?: true

Size: 800 Bytes

Versions: 4

Compression:

Stored size: 800 Bytes

Contents

use futures::executor::block_on;
use futures::future::{self, Future};
use std::task::Poll;

/// This tests verifies (through miri) that self-referencing
/// futures are not invalidated when joining them.
#[test]
fn futures_join_macro_self_referential() {
    block_on(async { futures::join!(yield_now(), trouble()) });
}

async fn trouble() {
    let lucky_number = 42;
    let problematic_variable = &lucky_number;

    yield_now().await;

    // problematic dereference
    let _ = { *problematic_variable };
}

fn yield_now() -> impl Future<Output = ()> {
    let mut yielded = false;
    future::poll_fn(move |cx| {
        if core::mem::replace(&mut yielded, true) {
            Poll::Ready(())
        } else {
            cx.waker().wake_by_ref();
            Poll::Pending
        }
    })
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/futures-0.3.31/tests/future_join.rs
wasmtime-28.0.0 ./ext/cargo-vendor/futures-0.3.31/tests/future_join.rs
wasmtime-27.0.0 ./ext/cargo-vendor/futures-0.3.31/tests/future_join.rs
wasmtime-26.0.0 ./ext/cargo-vendor/futures-0.3.31/tests/future_join.rs