about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-04-09 05:29:38 +0200
committerGitHub <noreply@github.com>2020-04-09 05:29:38 +0200
commitba50bc588e36a06a7b42970366534946beea5ce9 (patch)
tree302aa53464e05e34c56cb335a0b69bfc70becace /src/test
parente89cb0733a33906f2097ed3511f6766a95432a3b (diff)
parent563152d8830737b65d39d280214b1a64aa006f98 (diff)
downloadrust-ba50bc588e36a06a7b42970366534946beea5ce9.tar.gz
rust-ba50bc588e36a06a7b42970366534946beea5ce9.zip
Rollup merge of #70367 - nikomatsakis:issue-69307, r=Aaron1011
save/restore `pessimistic_yield` when entering bodies

This flag is used to make the execution order around `+=` operators
pessimistic. Failure to save/restore the flag was causing independent
async blocks to effect one another, leading to strange ICEs and failed
assumptions.

Fixes #69307

r? @Zoxc
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/async-await/issues/issue-69307-nested.rs30
-rw-r--r--src/test/ui/async-await/issues/issue-69307.rs23
2 files changed, 53 insertions, 0 deletions
diff --git a/src/test/ui/async-await/issues/issue-69307-nested.rs b/src/test/ui/async-await/issues/issue-69307-nested.rs
new file mode 100644
index 00000000000..b7cdf3987f1
--- /dev/null
+++ b/src/test/ui/async-await/issues/issue-69307-nested.rs
@@ -0,0 +1,30 @@
+// Regression test for #69307
+//
+// Having a `async { .. foo.await .. }` block appear inside of a `+=`
+// expression was causing an ICE due to a failure to save/restore
+// state in the AST numbering pass when entering a nested body.
+//
+// check-pass
+// edition:2018
+
+fn block_on<F>(_: F) -> usize {
+    0
+}
+
+fn main() {}
+
+async fn bar() {
+    let mut sum = 0;
+    sum += {
+        block_on(async {
+            baz().await;
+            let mut inner = 1;
+            inner += block_on(async {
+                baz().await;
+                0
+            })
+        })
+    };
+}
+
+async fn baz() {}
diff --git a/src/test/ui/async-await/issues/issue-69307.rs b/src/test/ui/async-await/issues/issue-69307.rs
new file mode 100644
index 00000000000..4dae96ec8a6
--- /dev/null
+++ b/src/test/ui/async-await/issues/issue-69307.rs
@@ -0,0 +1,23 @@
+// Regression test for #69307
+//
+// Having a `async { .. foo.await .. }` block appear inside of a `+=`
+// expression was causing an ICE due to a failure to save/restore
+// state in the AST numbering pass when entering a nested body.
+//
+// check-pass
+// edition:2018
+
+fn block_on<F>(_: F) -> usize {
+    0
+}
+
+fn main() {}
+
+async fn bar() {
+    let mut sum = 0;
+    sum += block_on(async {
+        baz().await;
+    });
+}
+
+async fn baz() {}