Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable<I:
) -> Result<(ty::Binder<I, AsyncCallableRelevantTypes<I>>, Vec<I::Predicate>), NoSolution> {
match self_ty.kind() {
ty::CoroutineClosure(def_id, args) => {
if !cx.coroutine_is_async(cx.coroutine_for_closure(def_id)) {
return Err(NoSolution);
}

let args = args.as_coroutine_closure();
let kind_ty = args.kind_ty();
let sig = args.coroutine_closure_sig().skip_binder();
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/iterators/generator_capture_2.current.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0382]: use of moved value: `f`
--> $DIR/generator_capture_2.rs:27:17
--> $DIR/generator_capture_2.rs:26:17
|
LL | let f = {
| - move occurs because `f` has type `{gen closure@$DIR/generator_capture_2.rs:16:17: 16:24}`, which does not implement the `Copy` trait
| - move occurs because `f` has type `{gen closure@$DIR/generator_capture_2.rs:15:17: 15:24}`, which does not implement the `Copy` trait
...
LL | let mut i = f();
| --- `f` moved due to this call
Expand All @@ -11,7 +11,7 @@ LL | let mut i = f();
| ^ value used here after move
|
note: this value implements `FnOnce`, which causes it to be moved when called
--> $DIR/generator_capture_2.rs:22:17
--> $DIR/generator_capture_2.rs:21:17
|
LL | let mut i = f();
| ^
Expand Down
25 changes: 25 additions & 0 deletions tests/ui/iterators/generator_capture_2.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error[E0382]: use of moved value: `f`
--> $DIR/generator_capture_2.rs:26:17
|
LL | let f = {
| - move occurs because `f` has type `{gen closure@$DIR/generator_capture_2.rs:15:17: 15:24}`, which does not implement the `Copy` trait
...
LL | let mut i = f();
| --- `f` moved due to this call
...
LL | let mut i = f();
| ^ value used here after move
|
note: this value implements `FnOnce`, which causes it to be moved when called
--> $DIR/generator_capture_2.rs:21:17
|
LL | let mut i = f();
| ^
help: consider cloning the value if the performance cost is acceptable
|
LL | let mut i = f.clone()();
| ++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.
5 changes: 2 additions & 3 deletions tests/ui/iterators/generator_capture_2.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@[next] known-bug: trait-system-refactor-initiative#302
//@[next] check-pass
//@check-fail

// This test exercises lending behavior for iterator closures which is not yet supported.

Expand All @@ -24,7 +23,7 @@ fn main() {
assert_eq!(i.next(), Some('o'));
assert_eq!(i.next(), Some('o'));
assert_eq!(i.next(), None);
let mut i = f(); //[current]~ ERROR use of moved value: `f`
let mut i = f(); //~ ERROR use of moved value: `f`
assert_eq!(i.next(), Some('f'));
assert_eq!(i.next(), Some('o'));
assert_eq!(i.next(), Some('o'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure-simplified.rs:31:21
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure-simplified.rs:30:21
|
LL | call_async_once(f);
| --------------- ^ unsatisfied trait bound
| |
| required by a bound introduced by this call
|
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:25:21: 25:28}`
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}`
note: required by a bound in `call_async_once`
--> $DIR/iter-macro-not-async-closure-simplified.rs:22:28
--> $DIR/iter-macro-not-async-closure-simplified.rs:21:28
|
LL | ...pl AsyncFnOnce()) {}
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure-simplified.rs:30:21
|
LL | call_async_once(f);
| --------------- ^ unsatisfied trait bound
| |
| required by a bound introduced by this call
|
= help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}`
note: required by a bound in `call_async_once`
--> $DIR/iter-macro-not-async-closure-simplified.rs:21:28
|
LL | fn call_async_once(_: impl AsyncFnOnce()) {}
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
5 changes: 2 additions & 3 deletions tests/ui/iterators/iter-macro-not-async-closure-simplified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
//@[narrow] compile-flags: --diagnostic-width=20
//@[wide] compile-flags: --diagnostic-width=300
//@[next] compile-flags: -Znext-solver
//@[next] known-bug: trait-system-refactor-initiative#302
//@[next] check-pass
//@check-fail

#![feature(yield_expr, iter_macro)]

Expand All @@ -29,5 +28,5 @@ fn main() {
}};

call_async_once(f);
//[narrow,wide]~^ ERROR AsyncFnOnce()` is not satisfied
//~^ ERROR AsyncFnOnce()` is not satisfied
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure-simplified.rs:31:21
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure-simplified.rs:30:21
|
LL | call_async_once(f);
| --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:25:21: 25:28}`
| --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}`
| |
| required by a bound introduced by this call
|
note: required by a bound in `call_async_once`
--> $DIR/iter-macro-not-async-closure-simplified.rs:22:28
--> $DIR/iter-macro-not-async-closure-simplified.rs:21:28
|
LL | fn call_async_once(_: impl AsyncFnOnce()) {}
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/iterators/iter-macro-not-async-closure.current.stderr
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure.rs:31:34
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure.rs:30:34
|
LL | let x = pin!(call_async_once(f));
| --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}`
| --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}`
| |
| required by a bound introduced by this call
|
note: required by a bound in `call_async_once`
--> $DIR/iter-macro-not-async-closure.rs:20:34
--> $DIR/iter-macro-not-async-closure.rs:19:34
|
LL | async fn call_async_once(f: impl AsyncFnOnce()) {
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`

error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure.rs:31:13
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure.rs:30:13
|
LL | let x = pin!(call_async_once(f));
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}`
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}`
|
note: required by a bound in `call_async_once`
--> $DIR/iter-macro-not-async-closure.rs:20:34
--> $DIR/iter-macro-not-async-closure.rs:19:34
|
LL | async fn call_async_once(f: impl AsyncFnOnce()) {
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`

error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure.rs:34:5
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure.rs:32:5
|
LL | x.poll(&mut Context::from_waker(Waker::noop()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}`
|
note: required by a bound in `call_async_once`
--> $DIR/iter-macro-not-async-closure.rs:20:34
--> $DIR/iter-macro-not-async-closure.rs:19:34
|
LL | async fn call_async_once(f: impl AsyncFnOnce()) {
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`
Expand Down
41 changes: 41 additions & 0 deletions tests/ui/iterators/iter-macro-not-async-closure.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure.rs:30:34
|
LL | let x = pin!(call_async_once(f));
| --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}`
| |
| required by a bound introduced by this call
|
note: required by a bound in `call_async_once`
--> $DIR/iter-macro-not-async-closure.rs:19:34
|
LL | async fn call_async_once(f: impl AsyncFnOnce()) {
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`

error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure.rs:30:13
|
LL | let x = pin!(call_async_once(f));
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}`
|
note: required by a bound in `call_async_once`
--> $DIR/iter-macro-not-async-closure.rs:19:34
|
LL | async fn call_async_once(f: impl AsyncFnOnce()) {
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`

error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied
--> $DIR/iter-macro-not-async-closure.rs:32:5
|
LL | x.poll(&mut Context::from_waker(Waker::noop()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}`
|
note: required by a bound in `call_async_once`
--> $DIR/iter-macro-not-async-closure.rs:19:34
|
LL | async fn call_async_once(f: impl AsyncFnOnce()) {
| ^^^^^^^^^^^^^ required by this bound in `call_async_once`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0277`.
11 changes: 4 additions & 7 deletions tests/ui/iterators/iter-macro-not-async-closure.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@[next] known-bug: trait-system-refactor-initiative#302
//@[next] check-pass
//@check-fail

// This test ensures iterators created with the `iter!` macro are not
// accidentally async closures.
Expand All @@ -28,9 +27,7 @@ fn main() {
}
}};

let x = pin!(call_async_once(f));
//[current]~^ ERROR AsyncFnOnce()` is not satisfied
//[current]~| ERROR AsyncFnOnce()` is not satisfied
x.poll(&mut Context::from_waker(Waker::noop()));
//[current]~^ ERROR AsyncFnOnce()` is not satisfied
let x = pin!(call_async_once(f)); //~ ERROR AsyncFnOnce()` is not satisfied
//~| ERROR AsyncFnOnce()` is not satisfied
x.poll(&mut Context::from_waker(Waker::noop())); //~ ERROR AsyncFnOnce()` is not satisfied
}
Loading