about summary refs log tree commit diff
path: root/tests/ui/async-await/async-drop/dependency-dropped.rs
blob: d7f415e19aadfddbef39eac4e7b1450f33f16f5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//@ run-pass
//@ check-run-results
//@ revisions: with_feature without_feature
//@ aux-build:async-drop-dep.rs
//@ edition:2021

#![cfg_attr(with_feature, feature(async_drop))]
//[without_feature]~^ WARN found async drop types in dependency `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped`

#![allow(incomplete_features)]

extern crate async_drop_dep;

use async_drop_dep::MongoDrop;
use std::pin::pin;
use std::task::{Context, Poll, Waker};
use std::future::Future;

async fn asyncdrop() {
    let _ = MongoDrop::new().await;
}

pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
    let mut fut = pin!(fut);
    let ctx = &mut Context::from_waker(Waker::noop());

    loop {
        match fut.as_mut().poll(ctx) {
            Poll::Pending => {}
            Poll::Ready(t) => break t,
        }
    }
}

fn main() {
    let _ = block_on(asyncdrop());
}