summaryrefslogtreecommitdiffstats
path: root/src/test/ui/async-await/issues/issue-59972.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/async-await/issues/issue-59972.rs')
-rw-r--r--src/test/ui/async-await/issues/issue-59972.rs34
1 files changed, 34 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
new file mode 100644
index 000000000..c2e24a96b
--- /dev/null
+++ b/src/test/ui/async-await/issues/issue-59972.rs
@@ -0,0 +1,34 @@
+// 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 -Aunused
+
+pub enum Uninhabited { }
+
+fn uninhabited_async() -> Uninhabited {
+ unreachable!()
+}
+
+async fn noop() { }
+
+async fn contains_never() {
+ let error = uninhabited_async();
+ noop().await;
+ let error2 = error;
+}
+
+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() {
+}