Skip to content

Commit

Permalink
More things compile
Browse files Browse the repository at this point in the history
  • Loading branch information
arora-aman committed Sep 28, 2020
1 parent 37a73d8 commit d4f1eaf
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
16 changes: 10 additions & 6 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1740,19 +1740,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::Closure(_, ref substs) => {
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)
// The inference variable will be replaced by a tuple once capture analysis
// completes. If the tuple meets a bound, so do all the elements within it.
vec![ty]
} else {
substs.as_closure().upvar_tys().collect()
}
}

ty::Generator(_, ref substs, _) => {
let ty = self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
// Not yet resolved.
//self.constituent_types_for_ty(ty)
vec![ty]
let upvar_tys_resolved =
self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
let witness_resolved = self.infcx.shallow_resolve(substs.as_generator().witness());

if let ty::Infer(ty::TyVar(_)) = upvar_tys_resolved.kind() {
// The inference variable will be replaced by a tuple once capture analysis
// completes, if the tuple meets a bound, so do all the elements within it.
vec![upvar_tys_resolved, witness_resolved]
} 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 4:38: 4:73: `U` cannot be sent between threads safely [E0277]
//~^ Error future cannot be sent between threads safely
async { (ty, ty1) }
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/closures/closure-move-sync.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LL | F: Send + 'static,
|
= help: the trait `Sync` is not implemented for `std::sync::mpsc::Receiver<()>`
= note: required because of the requirements on the impl of `Send` for `&std::sync::mpsc::Receiver<()>`
= note: required because it appears within the type `(&std::sync::mpsc::Receiver<()>,)`
= note: required because it appears within the type `[closure@$DIR/closure-move-sync.rs:6:27: 9:6 recv:&std::sync::mpsc::Receiver<()>]`

error[E0277]: `Sender<()>` cannot be shared between threads safely
Expand All @@ -26,6 +27,7 @@ LL | F: Send + 'static,
|
= help: the trait `Sync` is not implemented for `Sender<()>`
= note: required because of the requirements on the impl of `Send` for `&Sender<()>`
= note: required because it appears within the type `(&Sender<()>,)`
= note: required because it appears within the type `[closure@$DIR/closure-move-sync.rs:18:19: 18:42 tx:&Sender<()>]`

error: aborting due to 2 previous errors
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/generator/not-send-sync.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ LL | assert_send(|| {
|
= help: the trait `Sync` is not implemented for `Cell<i32>`
= note: required because of the requirements on the impl of `Send` for `&Cell<i32>`
= note: required because it appears within the type `(&Cell<i32>,)`
= note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:16:17: 20:6 a:&Cell<i32> _]`

error: generator cannot be shared between threads safely
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/interior-mutability/interior-mutability.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LL | pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
= help: within `Cell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>`
= note: required because it appears within the type `Cell<i32>`
= note: required because of the requirements on the impl of `UnwindSafe` for `&Cell<i32>`
= note: required because it appears within the type `(&Cell<i32>,)`
= note: required because it appears within the type `[closure@$DIR/interior-mutability.rs:5:18: 5:35 x:&Cell<i32>]`

error: aborting due to previous error
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/kindck/kindck-nonsendable-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ LL | bar(move|| foo(x));
| `Rc<usize>` cannot be sent between threads safely
|
= help: within `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:22 x:Rc<usize>]`, the trait `Send` is not implemented for `Rc<usize>`
= note: required because it appears within the type `(Rc<usize>,)`
= note: required because it appears within the type `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:22 x:Rc<usize>]`

error: aborting due to previous error
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/no-send-res-ports.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ LL | F: Send + 'static,
= help: within `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6 x:Foo]`, the trait `Send` is not implemented for `Rc<()>`
= note: required because it appears within the type `Port<()>`
= note: required because it appears within the type `Foo`
= note: required because it appears within the type `(Foo,)`
= note: required because it appears within the type `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6 x:Foo]`

error: aborting due to previous error
Expand Down

0 comments on commit d4f1eaf

Please sign in to comment.