File: ex-ice-132103.rs

package info (click to toggle)
rustc 1.88.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 934,128 kB
  • sloc: xml: 158,127; python: 36,062; javascript: 19,855; sh: 19,700; cpp: 18,947; ansic: 12,993; asm: 4,792; makefile: 690; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (27 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (7)
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
//@ run-pass
//! This test used to ICE: rust-lang/rust#132103
//! Fixed when re-work async drop to shim drop glue coroutine scheme.
//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes
//@ edition: 2018
#![feature(async_drop)]
#![allow(incomplete_features)]

use core::future::{async_drop_in_place, Future};
use core::mem::{self};
use core::pin::pin;
use core::task::{Context, Waker};

async fn test_async_drop<T>(x: T) {
    let mut x = mem::MaybeUninit::new(x);
    pin!(unsafe { async_drop_in_place(x.as_mut_ptr()) });
}

fn main() {
    let waker = Waker::noop();
    let mut cx = Context::from_waker(&waker);

    let fut = pin!(async {
        test_async_drop(test_async_drop(0)).await;
    });
    let _ = fut.poll(&mut cx);
}