about summary refs log tree commit diff
diff options
context:
space:
mode:
authorcsmoe <csmoe@msn.com>2020-05-06 16:49:30 +0800
committercsmoe <csmoe@msn.com>2020-05-06 17:03:15 +0800
commitd2e5a8e2e966df119021e3db6f6d4c2e189865cd (patch)
tree2f1401ea421e5d8956e1593914470bfb54477fdb
parent382a963c17122470918e1491a733b81fb545330d (diff)
downloadrust-d2e5a8e2e966df119021e3db6f6d4c2e189865cd.tar.gz
rust-d2e5a8e2e966df119021e3db6f6d4c2e189865cd.zip
bless issue-70818 test case
-rw-r--r--src/librustc_trait_selection/traits/error_reporting/suggestions.rs17
-rw-r--r--src/test/ui/async-await/issue-70818.rs8
-rw-r--r--src/test/ui/async-await/issue-70818.stderr23
3 files changed, 35 insertions, 13 deletions
diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
index d2d9c303ea1..35f3f5b0bba 100644
--- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
+++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
@@ -1168,7 +1168,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
         };
         let mut generator = None;
         let mut outer_generator = None;
-        let mut generator_substs = None;
         let mut next_code = Some(&obligation.cause.code);
         while let Some(code) = next_code {
             debug!("maybe_note_obligation_cause_for_async_await: code={:?}", code);
@@ -1184,9 +1183,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                     );
 
                     match ty.kind {
-                        ty::Generator(did, substs, ..) => {
+                        ty::Generator(did, ..) => {
                             generator = generator.or(Some(did));
-                            generator_substs = generator_substs.or(Some(substs));
                             outer_generator = Some(did);
                         }
                         ty::GeneratorWitness(..) => {}
@@ -1209,13 +1207,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                 target_ty={:?}",
             generator, trait_ref, target_ty
         );
-        let (generator_did, _generator_substs, trait_ref, target_ty) =
-            match (generator, generator_substs, trait_ref, target_ty) {
-                (Some(generator_did), Some(generator_substs), Some(trait_ref), Some(target_ty)) => {
-                    (generator_did, generator_substs, trait_ref, target_ty)
-                }
-                _ => return false,
-            };
+        let (generator_did, trait_ref, target_ty) = match (generator, trait_ref, target_ty) {
+            (Some(generator_did), Some(trait_ref), Some(target_ty)) => {
+                (generator_did, trait_ref, target_ty)
+            }
+            _ => return false,
+        };
 
         let span = self.tcx.def_span(generator_did);
 
diff --git a/src/test/ui/async-await/issue-70818.rs b/src/test/ui/async-await/issue-70818.rs
index 9bbaacd2f11..0609e4fc081 100644
--- a/src/test/ui/async-await/issue-70818.rs
+++ b/src/test/ui/async-await/issue-70818.rs
@@ -1,7 +1,9 @@
-// edition 2018
+// edition:2018
 
-fn foo<T: Sized>(ty: T) -> impl std::future::Future<Output = T> + Send { //~ Error `T` cannot be sent between threads safely
-    async { ty }
+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..97f5bde69b0
--- /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 outer 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
+