]> git.lizzy.rs Git - rust.git/blob - tests/ui/mir/issue-105809.rs
Rollup merge of #106707 - ehuss:remove-dupe-sha-1, r=Mark-Simulacrum
[rust.git] / tests / ui / mir / issue-105809.rs
1 // Non-regression test ICE from issue #105809 and duplicates.
2
3 // build-pass: the ICE is during codegen
4 // compile-flags: --edition 2018 -Zmir-opt-level=1
5
6 use std::{future::Future, pin::Pin};
7
8 // Create a `T` without affecting analysis like `loop {}`.
9 fn create<T>() -> T {
10     loop {}
11 }
12
13 async fn trivial_future() {}
14
15 struct Connection<H> {
16     _h: H,
17 }
18
19 async fn complex_future<H>(conn: &Connection<H>) {
20     let small_fut = async move {
21         let _ = conn;
22         trivial_future().await;
23     };
24
25     let mut tuple = (small_fut,);
26     let (small_fut_again,) = &mut tuple;
27     let _ = small_fut_again;
28 }
29
30 fn main() {
31     let mut fut = complex_future(&Connection { _h: () });
32
33     let mut cx = create();
34     let future = unsafe { Pin::new_unchecked(&mut fut) };
35     let _ = future.poll(&mut cx);
36 }