summaryrefslogtreecommitdiffstats
path: root/tests/run-make/panic-abort-eh_frame/foo.rs
blob: e2274d469e73cb244c21a869132f28a4eb144232 (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
#![no_std]

use core::future::Future;

pub struct NeedsDrop;

impl Drop for NeedsDrop {
    fn drop(&mut self) {}
}

#[panic_handler]
fn handler(_: &core::panic::PanicInfo<'_>) -> ! {
    loop {}
}

pub unsafe fn oops(x: *const u32) -> u32 {
    *x
}

pub async fn foo(_: NeedsDrop) {
    async fn bar() {}
    bar().await;
}

pub fn poll_foo(x: &mut core::task::Context<'_>) {
    let _g = NeedsDrop;
    let mut p = core::pin::pin!(foo(NeedsDrop));
    let _ = p.as_mut().poll(x);
    let _ = p.as_mut().poll(x);
}

pub fn drop_foo() {
    drop(foo(NeedsDrop));
}