about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-05-20 09:28:25 +0000
committerbors <bors@rust-lang.org>2020-05-20 09:28:25 +0000
commitf182c4af8a22df906f6e901cb11a1a804f29f32c (patch)
treee85bd6034a7fa0d14658ea28e74ea1ccf9d6a804 /src/test
parent64ad709ad4d2863b7995d8b9e90a1bedb7d0ccf1 (diff)
parentc9e146515ba391410069a6fe3e55a4a1935bc5ae (diff)
Auto merge of #71923 - csmoe:issue-70818, r=tmandry
Check non-Send/Sync upvars captured by generator

Closes #70818
r? @tmandry
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/async-await/issue-70818.rs9
-rw-r--r--src/test/ui/async-await/issue-70818.stderr23
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/async-await/issue-70818.rs b/src/test/ui/async-await/issue-70818.rs
new file mode 100644
index 00000000000..0609e4fc081
--- /dev/null
+++ b/src/test/ui/async-await/issue-70818.rs
@@ -0,0 +1,9 @@
+// edition:2018
+
+use std::future::Future;
+fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
+//~^ Error future cannot be sent between threads safely
+    async { (ty, ty1) }
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/issue-70818.stderr b/src/test/ui/async-await/issue-70818.stderr
new file mode 100644
index 00000000000..5fb772fa10a
--- /dev/null
+++ b/src/test/ui/async-await/issue-70818.stderr
@@ -0,0 +1,23 @@
+error: future cannot be sent between threads safely
+  --> $DIR/issue-70818.rs:4:38
+   |
+LL | fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
+   |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send`
+LL |
+LL |     async { (ty, ty1) }
+   |     ------------------- this returned value is of type `impl std::future::Future`
+   |
+   = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `U`
+note: captured value is not `Send`
+  --> $DIR/issue-70818.rs:6:18
+   |
+LL |     async { (ty, ty1) }
+   |                  ^^^ has type `U` which is not `Send`
+   = note: the return type of a function must have a statically known size
+help: consider restricting type parameter `U`
+   |
+LL | fn foo<T: Send, U: std::marker::Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
+   |                  ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+