1
Fork 0

bless issue-70818 test case

This commit is contained in:
csmoe 2020-05-06 16:49:30 +08:00
commit d2e5a8e2e9
3 changed files with 35 additions and 13 deletions

View file

@ -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);

View file

@ -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() {}

View file

@ -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