Skip to content

Commit

Permalink
Fix to pass additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roxelo committed Sep 27, 2020
1 parent 029280d commit 37a73d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let ty = self.infcx.shallow_resolve(substs.as_closure().tupled_upvars_ty());
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
//self.constituent_types_for_ty(ty)
Vec::new()
vec![ty]
} else {
substs.as_closure().upvar_tys().collect()
}
Expand All @@ -1752,7 +1752,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
// Not yet resolved.
//self.constituent_types_for_ty(ty)
Vec::new()
vec![ty]
} else {
let witness = substs.as_generator().witness();
substs.as_generator().upvar_tys().chain(iter::once(witness)).collect()
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issue-70818.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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
//~^ Error 4:38: 4:73: `U` cannot be sent between threads safely [E0277]
async { (ty, ty1) }
}

Expand Down
17 changes: 11 additions & 6 deletions src/test/ui/async-await/issue-70818.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
error: future cannot be sent between threads safely
error[E0277]: `U` 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`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `U` cannot be sent between threads safely
LL |
LL | async { (ty, ty1) }
| ------------------- this returned value is of type `impl Future`
|
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
|
note: captured value is not `Send`
--> $DIR/issue-70818.rs:6:18
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- within this `impl Future`
|
LL | async { (ty, ty1) }
| ^^^ has type `U` which is not `Send`
= note: required because it appears within the type `(T, U)`
= note: required because it appears within the type `[static generator@$DIR/issue-70818.rs:6:11: 6:24 ty:T, ty1:U _]`
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-70818.rs:6:11: 6:24 ty:T, ty1:U _]>`
= note: required because it appears within the type `impl Future`
= note: the return type of a function must have a statically known size
help: consider restricting type parameter `U`
|
Expand All @@ -20,3 +24,4 @@ LL | fn foo<T: Send, U: Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + S

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.

0 comments on commit 37a73d8

Please sign in to comment.