]> git.lizzy.rs Git - rust.git/blob - src/test/ui/async-await/issues/issue-59972.rs
Rollup merge of #71627 - ldm0:autoderefarg, r=Dylan-DPC
[rust.git] / src / test / ui / async-await / issues / issue-59972.rs
1 // Incorrect handling of uninhabited types could cause us to mark generator
2 // types as entirely uninhabited, when they were in fact constructible. This
3 // caused us to hit "unreachable" code (illegal instruction on x86).
4
5 // run-pass
6
7 // compile-flags: --edition=2018 -Aunused
8
9 pub enum Uninhabited { }
10
11 fn uninhabited_async() -> Uninhabited {
12     unreachable!()
13 }
14
15 async fn noop() { }
16
17 async fn contains_never() {
18     let error = uninhabited_async();
19     noop().await;
20     let error2 = error;
21 }
22
23 async fn overlap_never() {
24     let error1 = uninhabited_async();
25     noop().await;
26     let error2 = uninhabited_async();
27     drop(error1);
28     noop().await;
29     drop(error2);
30 }
31
32 #[allow(unused_must_use)]
33 fn main() {
34 }