Skip to content

Commit d2e5a8e

Browse files
committed
bless issue-70818 test case
1 parent 382a963 commit d2e5a8e

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

src/librustc_trait_selection/traits/error_reporting/suggestions.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
11681168
};
11691169
let mut generator = None;
11701170
let mut outer_generator = None;
1171-
let mut generator_substs = None;
11721171
let mut next_code = Some(&obligation.cause.code);
11731172
while let Some(code) = next_code {
11741173
debug!("maybe_note_obligation_cause_for_async_await: code={:?}", code);
@@ -1184,9 +1183,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
11841183
);
11851184

11861185
match ty.kind {
1187-
ty::Generator(did, substs, ..) => {
1186+
ty::Generator(did, ..) => {
11881187
generator = generator.or(Some(did));
1189-
generator_substs = generator_substs.or(Some(substs));
11901188
outer_generator = Some(did);
11911189
}
11921190
ty::GeneratorWitness(..) => {}
@@ -1209,13 +1207,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
12091207
target_ty={:?}",
12101208
generator, trait_ref, target_ty
12111209
);
1212-
let (generator_did, _generator_substs, trait_ref, target_ty) =
1213-
match (generator, generator_substs, trait_ref, target_ty) {
1214-
(Some(generator_did), Some(generator_substs), Some(trait_ref), Some(target_ty)) => {
1215-
(generator_did, generator_substs, trait_ref, target_ty)
1216-
}
1217-
_ => return false,
1218-
};
1210+
let (generator_did, trait_ref, target_ty) = match (generator, trait_ref, target_ty) {
1211+
(Some(generator_did), Some(trait_ref), Some(target_ty)) => {
1212+
(generator_did, trait_ref, target_ty)
1213+
}
1214+
_ => return false,
1215+
};
12191216

12201217
let span = self.tcx.def_span(generator_did);
12211218

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
// edition 2018
1+
// edition:2018
22

3-
fn foo<T: Sized>(ty: T) -> impl std::future::Future<Output = T> + Send { //~ Error `T` cannot be sent between threads safely
4-
async { ty }
3+
use std::future::Future;
4+
fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
5+
//~^ Error future cannot be sent between threads safely
6+
async { (ty, ty1) }
57
}
68

79
fn main() {}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error: future cannot be sent between threads safely
2+
--> $DIR/issue-70818.rs:4:38
3+
|
4+
LL | fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send`
6+
LL |
7+
LL | async { (ty, ty1) }
8+
| ------------------- this returned value is of type `impl std::future::Future`
9+
|
10+
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `U`
11+
note: captured outer value is not `Send`
12+
--> $DIR/issue-70818.rs:6:18
13+
|
14+
LL | async { (ty, ty1) }
15+
| ^^^ has type `U` which is not `Send`
16+
= note: the return type of a function must have a statically known size
17+
help: consider restricting type parameter `U`
18+
|
19+
LL | fn foo<T: Send, U: std::marker::Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
20+
| ^^^^^^^^^^^^^^^^^^^
21+
22+
error: aborting due to previous error
23+

0 commit comments

Comments
 (0)