about summary refs log tree commit diff
path: root/src/test/ui/async-await/issues
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2019-07-26 19:36:26 -0700
committerTyler Mandry <tmandry@gmail.com>2019-07-29 12:17:49 -0700
commit6fae7f807146e400fa2bbd1c44768d9bcaa57c4c (patch)
tree83c3496735c01f5d7b0f4408b4c8d2f4e12761a3 /src/test/ui/async-await/issues
parentc43753f910aae000f8bcb0a502407ea332afc74b (diff)
downloadrust-6fae7f807146e400fa2bbd1c44768d9bcaa57c4c.tar.gz
rust-6fae7f807146e400fa2bbd1c44768d9bcaa57c4c.zip
Wrap promoted generator fields in MaybeUninit
This prevents uninhabited fields from "infecting" the abi and
largest_niche of the generator layout.

This fixes a latent bug, where an uninhabited field could be promoted to
the generator prefix and cause the entire generator to become
uninhabited.
Diffstat (limited to 'src/test/ui/async-await/issues')
-rw-r--r--src/test/ui/async-await/issues/issue-59972.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/ui/async-await/issues/issue-59972.rs b/src/test/ui/async-await/issues/issue-59972.rs
index 1b843720102..8f4254b10ce 100644
--- a/src/test/ui/async-await/issues/issue-59972.rs
+++ b/src/test/ui/async-await/issues/issue-59972.rs
@@ -1,3 +1,7 @@
+// Incorrect handling of uninhabited types could cause us to mark generator
+// types as entirely uninhabited, when they were in fact constructible. This
+// caused us to hit "unreachable" code (illegal instruction on x86).
+
 // run-pass
 
 // compile-flags: --edition=2018
@@ -19,7 +23,18 @@ async fn contains_never() {
     let error2 = error;
 }
 
+#[allow(unused)]
+async fn overlap_never() {
+    let error1 = uninhabited_async();
+    noop().await;
+    let error2 = uninhabited_async();
+    drop(error1);
+    noop().await;
+    drop(error2);
+}
+
 #[allow(unused_must_use)]
 fn main() {
     contains_never();
+    overlap_never();
 }