summaryrefslogtreecommitdiffstats
path: root/src/test/ui/async-await
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/async-await')
-rw-r--r--src/test/ui/async-await/async-block-control-flow-static-semantics.rs4
-rw-r--r--src/test/ui/async-await/async-block-control-flow-static-semantics.stderr14
-rw-r--r--src/test/ui/async-await/async-borrowck-escaping-block-error.stderr20
-rw-r--r--src/test/ui/async-await/auxiliary/issue-107036.rs12
-rw-r--r--src/test/ui/async-await/drop-track-bad-field-in-fru.rs10
-rw-r--r--src/test/ui/async-await/drop-track-bad-field-in-fru.stderr23
-rw-r--r--src/test/ui/async-await/drop-tracking-unresolved-typeck-results.rs106
-rw-r--r--src/test/ui/async-await/drop-tracking-unresolved-typeck-results.stderr62
-rw-r--r--src/test/ui/async-await/feature-self-return-type.rs28
-rw-r--r--src/test/ui/async-await/feature-self-return-type.stderr15
-rw-r--r--src/test/ui/async-await/generator-desc.stderr32
-rw-r--r--src/test/ui/async-await/generator-not-future.rs45
-rw-r--r--src/test/ui/async-await/generator-not-future.stderr81
-rw-r--r--src/test/ui/async-await/in-trait/async-associated-types.rs4
-rw-r--r--src/test/ui/async-await/in-trait/async-associated-types.stderr57
-rw-r--r--src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr8
-rw-r--r--src/test/ui/async-await/in-trait/async-generics.stderr8
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs3
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr23
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes.rs3
-rw-r--r--src/test/ui/async-await/in-trait/async-lifetimes.stderr23
-rw-r--r--src/test/ui/async-await/in-trait/early-bound-1.rs17
-rw-r--r--src/test/ui/async-await/in-trait/early-bound-2.rs15
-rw-r--r--src/test/ui/async-await/in-trait/implied-bounds.rs13
-rw-r--r--src/test/ui/async-await/in-trait/lifetime-mismatch.rs20
-rw-r--r--src/test/ui/async-await/in-trait/lifetime-mismatch.stderr21
-rw-r--r--src/test/ui/async-await/in-trait/nested-rpit.rs19
-rw-r--r--src/test/ui/async-await/in-trait/object-safety.rs13
-rw-r--r--src/test/ui/async-await/in-trait/object-safety.stderr27
-rw-r--r--src/test/ui/async-await/in-trait/return-type-suggestion.rs14
-rw-r--r--src/test/ui/async-await/in-trait/return-type-suggestion.stderr23
-rw-r--r--src/test/ui/async-await/issue-107036.rs14
-rw-r--r--src/test/ui/async-await/issue-61949-self-return-type.rs2
-rw-r--r--src/test/ui/async-await/issue-61949-self-return-type.stderr24
-rw-r--r--src/test/ui/async-await/issue-67252-unnamed-future.stderr2
-rw-r--r--src/test/ui/async-await/issue-68112.drop_tracking.stderr4
-rw-r--r--src/test/ui/async-await/issue-68112.no_drop_tracking.stderr4
-rw-r--r--src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr5
-rw-r--r--src/test/ui/async-await/issue-86507.stderr2
-rw-r--r--src/test/ui/async-await/issues/issue-65159.rs1
-rw-r--r--src/test/ui/async-await/issues/issue-65159.stderr16
-rw-r--r--src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr2
-rw-r--r--src/test/ui/async-await/issues/issue-78600.stderr7
-rw-r--r--src/test/ui/async-await/issues/issue-78938-async-block.stderr4
-rw-r--r--src/test/ui/async-await/large_moves.attribute.stderr8
-rw-r--r--src/test/ui/async-await/large_moves.option.stderr8
-rw-r--r--src/test/ui/async-await/large_moves.rs1
-rw-r--r--src/test/ui/async-await/track-caller/async-closure-gate.rs9
-rw-r--r--src/test/ui/async-await/track-caller/async-closure-gate.stderr12
-rw-r--r--src/test/ui/async-await/track-caller/issue-105134.rs11
-rw-r--r--src/test/ui/async-await/track-caller/panic-track-caller.nofeat.stderr29
-rw-r--r--src/test/ui/async-await/track-caller/panic-track-caller.rs100
-rw-r--r--src/test/ui/async-await/try-on-option-in-async.stderr3
53 files changed, 831 insertions, 200 deletions
diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs
index 446212ca7..bc9d12793 100644
--- a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs
+++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs
@@ -15,7 +15,7 @@ fn return_targets_async_block_not_fn() -> u8 {
return 0u8;
};
let _: &dyn Future<Output = ()> = &block;
- //~^ ERROR expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
+ //~^ ERROR to be a future that resolves to `()`, but it resolves to `u8`
}
async fn return_targets_async_block_not_async_fn() -> u8 {
@@ -24,7 +24,7 @@ async fn return_targets_async_block_not_async_fn() -> u8 {
return 0u8;
};
let _: &dyn Future<Output = ()> = &block;
- //~^ ERROR expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
+ //~^ ERROR to be a future that resolves to `()`, but it resolves to `u8`
}
fn no_break_in_async_block() {
diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr
index 2a08d5d6c..c4487eb84 100644
--- a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr
+++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr
@@ -1,8 +1,7 @@
error[E0267]: `break` inside of an `async` block
--> $DIR/async-block-control-flow-static-semantics.rs:32:9
|
-LL | async {
- | ___________-
+LL | / async {
LL | | break 0u8;
| | ^^^^^^^^^ cannot `break` inside of an `async` block
LL | | };
@@ -11,8 +10,7 @@ LL | | };
error[E0267]: `break` inside of an `async` block
--> $DIR/async-block-control-flow-static-semantics.rs:39:13
|
-LL | async {
- | _______________-
+LL | / async {
LL | | break 0u8;
| | ^^^^^^^^^ cannot `break` inside of an `async` block
LL | | };
@@ -31,13 +29,13 @@ LL | |
LL | | }
| |_^ expected `u8`, found `()`
-error[E0271]: expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
+error[E0271]: expected `[async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 25:6]` to be a future that resolves to `()`, but it resolves to `u8`
--> $DIR/async-block-control-flow-static-semantics.rs:26:39
|
LL | let _: &dyn Future<Output = ()> = &block;
| ^^^^^^ expected `()`, found `u8`
|
- = note: required for the cast from `impl Future<Output = u8>` to the object type `dyn Future<Output = ()>`
+ = note: required for the cast from `[async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 25:6]` to the object type `dyn Future<Output = ()>`
error[E0308]: mismatched types
--> $DIR/async-block-control-flow-static-semantics.rs:12:43
@@ -47,13 +45,13 @@ LL | fn return_targets_async_block_not_fn() -> u8 {
| |
| implicitly returns `()` as its body has no tail or `return` expression
-error[E0271]: expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
+error[E0271]: expected `[async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 16:6]` to be a future that resolves to `()`, but it resolves to `u8`
--> $DIR/async-block-control-flow-static-semantics.rs:17:39
|
LL | let _: &dyn Future<Output = ()> = &block;
| ^^^^^^ expected `()`, found `u8`
|
- = note: required for the cast from `impl Future<Output = u8>` to the object type `dyn Future<Output = ()>`
+ = note: required for the cast from `[async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 16:6]` to the object type `dyn Future<Output = ()>`
error[E0308]: mismatched types
--> $DIR/async-block-control-flow-static-semantics.rs:49:44
diff --git a/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr b/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr
index f21c81151..190c59e32 100644
--- a/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr
+++ b/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr
@@ -1,11 +1,11 @@
error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function
- --> $DIR/async-borrowck-escaping-block-error.rs:6:20
+ --> $DIR/async-borrowck-escaping-block-error.rs:6:14
|
LL | Box::new(async { x } )
- | ^^-^^
- | | |
- | | `x` is borrowed here
- | may outlive borrowed value `x`
+ | ^^^^^^^^-^^
+ | | |
+ | | `x` is borrowed here
+ | may outlive borrowed value `x`
|
note: async block is returned here
--> $DIR/async-borrowck-escaping-block-error.rs:6:5
@@ -18,13 +18,13 @@ LL | Box::new(async move { x } )
| ++++
error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function
- --> $DIR/async-borrowck-escaping-block-error.rs:11:11
+ --> $DIR/async-borrowck-escaping-block-error.rs:11:5
|
LL | async { *x }
- | ^^--^^
- | | |
- | | `x` is borrowed here
- | may outlive borrowed value `x`
+ | ^^^^^^^^--^^
+ | | |
+ | | `x` is borrowed here
+ | may outlive borrowed value `x`
|
note: async block is returned here
--> $DIR/async-borrowck-escaping-block-error.rs:11:5
diff --git a/src/test/ui/async-await/auxiliary/issue-107036.rs b/src/test/ui/async-await/auxiliary/issue-107036.rs
new file mode 100644
index 000000000..c3f6141b2
--- /dev/null
+++ b/src/test/ui/async-await/auxiliary/issue-107036.rs
@@ -0,0 +1,12 @@
+// edition:2021
+
+pub trait T {}
+impl T for () {}
+
+pub struct S {}
+
+impl S {
+ pub async fn f<'a>(&self) -> impl T + 'a {
+ ()
+ }
+}
diff --git a/src/test/ui/async-await/drop-track-bad-field-in-fru.rs b/src/test/ui/async-await/drop-track-bad-field-in-fru.rs
new file mode 100644
index 000000000..28ad77675
--- /dev/null
+++ b/src/test/ui/async-await/drop-track-bad-field-in-fru.rs
@@ -0,0 +1,10 @@
+// compile-flags: -Zdrop-tracking
+// edition: 2021
+
+fn main() {}
+
+async fn foo() {
+ None { value: (), ..Default::default() }.await;
+ //~^ ERROR `Option<_>` is not a future
+ //~| ERROR variant `Option<_>::None` has no field named `value`
+}
diff --git a/src/test/ui/async-await/drop-track-bad-field-in-fru.stderr b/src/test/ui/async-await/drop-track-bad-field-in-fru.stderr
new file mode 100644
index 000000000..819b64ad7
--- /dev/null
+++ b/src/test/ui/async-await/drop-track-bad-field-in-fru.stderr
@@ -0,0 +1,23 @@
+error[E0559]: variant `Option<_>::None` has no field named `value`
+ --> $DIR/drop-track-bad-field-in-fru.rs:7:12
+ |
+LL | None { value: (), ..Default::default() }.await;
+ | ^^^^^ `Option<_>::None` does not have this field
+
+error[E0277]: `Option<_>` is not a future
+ --> $DIR/drop-track-bad-field-in-fru.rs:7:45
+ |
+LL | None { value: (), ..Default::default() }.await;
+ | ^^^^^^
+ | |
+ | `Option<_>` is not a future
+ | help: remove the `.await`
+ |
+ = help: the trait `Future` is not implemented for `Option<_>`
+ = note: Option<_> must be a future or must implement `IntoFuture` to be awaited
+ = note: required for `Option<_>` to implement `IntoFuture`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0277, E0559.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.rs b/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.rs
new file mode 100644
index 000000000..7f7294295
--- /dev/null
+++ b/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.rs
@@ -0,0 +1,106 @@
+// compile-flags: -Zdrop-tracking
+// incremental
+// edition: 2021
+
+use std::future::*;
+use std::marker::PhantomData;
+use std::pin::Pin;
+use std::task::*;
+
+fn send<T: Send>(_: T) {}
+
+pub trait Stream {
+ type Item;
+
+ fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>;
+}
+
+struct Empty<T>(PhantomData<fn() -> T>);
+
+impl<T> Stream for Empty<T> {
+ type Item = T;
+
+ fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
+ todo!()
+ }
+}
+
+pub trait FnOnce1<A> {
+ type Output;
+ fn call_once(self, arg: A) -> Self::Output;
+}
+
+impl<T, A, R> FnOnce1<A> for T
+where
+ T: FnOnce(A) -> R,
+{
+ type Output = R;
+ fn call_once(self, arg: A) -> R {
+ self(arg)
+ }
+}
+
+pub trait FnMut1<A>: FnOnce1<A> {
+ fn call_mut(&mut self, arg: A) -> Self::Output;
+}
+
+impl<T, A, R> FnMut1<A> for T
+where
+ T: FnMut(A) -> R,
+{
+ fn call_mut(&mut self, arg: A) -> R {
+ self(arg)
+ }
+}
+
+struct Map<St, F>(St, F);
+
+impl<St, F> Stream for Map<St, F>
+where
+ St: Stream,
+ F: FnMut1<St::Item>,
+{
+ type Item = F::Output;
+
+ fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
+ todo!()
+ }
+}
+
+struct FuturesOrdered<T: Future>(PhantomData<fn() -> T::Output>);
+
+pub struct Buffered<St: Stream>(St, FuturesOrdered<St::Item>, usize)
+where
+ St::Item: Future;
+
+impl<St> Stream for Buffered<St>
+where
+ St: Stream,
+ St::Item: Future,
+{
+ type Item = <St::Item as Future>::Output;
+
+ fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
+ todo!()
+ }
+}
+
+struct Next<'a, T: ?Sized>(&'a T);
+
+impl<St: ?Sized + Stream + Unpin> Future for Next<'_, St> {
+ type Output = Option<St::Item>;
+
+ fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
+ todo!()
+ }
+}
+
+fn main() {
+ send(async {
+ //~^ ERROR implementation of `FnOnce` is not general enough
+ //~| ERROR implementation of `FnOnce` is not general enough
+ //~| ERROR implementation of `FnOnce` is not general enough
+ //~| ERROR implementation of `FnOnce` is not general enough
+ Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await
+ });
+}
diff --git a/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.stderr b/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.stderr
new file mode 100644
index 000000000..aa9a22e9e
--- /dev/null
+++ b/src/test/ui/async-await/drop-tracking-unresolved-typeck-results.stderr
@@ -0,0 +1,62 @@
+error: implementation of `FnOnce` is not general enough
+ --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5
+ |
+LL | / send(async {
+LL | |
+LL | |
+LL | |
+LL | |
+LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await
+LL | | });
+ | |______^ implementation of `FnOnce` is not general enough
+ |
+ = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
+ = note: ...but it actually implements `FnOnce<(&(),)>`
+
+error: implementation of `FnOnce` is not general enough
+ --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5
+ |
+LL | / send(async {
+LL | |
+LL | |
+LL | |
+LL | |
+LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await
+LL | | });
+ | |______^ implementation of `FnOnce` is not general enough
+ |
+ = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
+ = note: ...but it actually implements `FnOnce<(&(),)>`
+
+error: implementation of `FnOnce` is not general enough
+ --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5
+ |
+LL | / send(async {
+LL | |
+LL | |
+LL | |
+LL | |
+LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await
+LL | | });
+ | |______^ implementation of `FnOnce` is not general enough
+ |
+ = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
+ = note: ...but it actually implements `FnOnce<(&(),)>`
+
+error: implementation of `FnOnce` is not general enough
+ --> $DIR/drop-tracking-unresolved-typeck-results.rs:99:5
+ |
+LL | / send(async {
+LL | |
+LL | |
+LL | |
+LL | |
+LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await
+LL | | });
+ | |______^ implementation of `FnOnce` is not general enough
+ |
+ = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
+ = note: ...but it actually implements `FnOnce<(&(),)>`
+
+error: aborting due to 4 previous errors
+
diff --git a/src/test/ui/async-await/feature-self-return-type.rs b/src/test/ui/async-await/feature-self-return-type.rs
new file mode 100644
index 000000000..41f887430
--- /dev/null
+++ b/src/test/ui/async-await/feature-self-return-type.rs
@@ -0,0 +1,28 @@
+// edition:2018
+#![feature(impl_trait_projections)]
+
+// This test checks that we emit the correct borrowck error when `Self` is used as a return type.
+// See #61949 for context.
+
+pub struct Foo<'a> {
+ pub bar: &'a i32,
+}
+
+impl<'a> Foo<'a> {
+ pub async fn new(_bar: &'a i32) -> Self {
+ Foo {
+ bar: &22
+ }
+ }
+}
+
+pub async fn foo() {
+ let x = {
+ let bar = 22;
+ Foo::new(&bar).await
+ //~^ ERROR `bar` does not live long enough
+ };
+ drop(x);
+}
+
+fn main() { }
diff --git a/src/test/ui/async-await/feature-self-return-type.stderr b/src/test/ui/async-await/feature-self-return-type.stderr
new file mode 100644
index 000000000..892468368
--- /dev/null
+++ b/src/test/ui/async-await/feature-self-return-type.stderr
@@ -0,0 +1,15 @@
+error[E0597]: `bar` does not live long enough
+ --> $DIR/feature-self-return-type.rs:22:18
+ |
+LL | let x = {
+ | - borrow later stored here
+LL | let bar = 22;
+LL | Foo::new(&bar).await
+ | ^^^^ borrowed value does not live long enough
+LL |
+LL | };
+ | - `bar` dropped here while still borrowed
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/async-await/generator-desc.stderr b/src/test/ui/async-await/generator-desc.stderr
index 2494c3feb..1686153ac 100644
--- a/src/test/ui/async-await/generator-desc.stderr
+++ b/src/test/ui/async-await/generator-desc.stderr
@@ -1,20 +1,20 @@
error[E0308]: mismatched types
- --> $DIR/generator-desc.rs:10:25
+ --> $DIR/generator-desc.rs:10:19
|
LL | fun(async {}, async {});
- | -- ^^
- | | |
- | | expected `async` block, found a different `async` block
- | | arguments to this function are incorrect
- | the expected `async` block
+ | -------- ^^^^^^^^
+ | | |
+ | | expected `async` block, found a different `async` block
+ | | arguments to this function are incorrect
+ | the expected `async` block
|
- = note: expected `async` block `[static generator@$DIR/generator-desc.rs:10:15: 10:17]`
- found `async` block `[static generator@$DIR/generator-desc.rs:10:25: 10:27]`
+ = note: expected `async` block `[async block@$DIR/generator-desc.rs:10:9: 10:17]`
+ found `async` block `[async block@$DIR/generator-desc.rs:10:19: 10:27]`
note: function defined here
--> $SRC_DIR/core/src/future/mod.rs:LL:COL
|
-LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
- | ^^^^^^^^^^^^^^
+LL | pub const fn identity_future<O, Fut: Future<Output = O>>(f: Fut) -> Fut {
+ | ^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/generator-desc.rs:12:16
@@ -53,16 +53,8 @@ LL | fun((async || {})(), (async || {})());
| | the expected `async` closure body
| arguments to this function are incorrect
|
- ::: $SRC_DIR/core/src/future/mod.rs:LL:COL
- |
-LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
- | -------------------------------
- | |
- | the expected opaque type
- | the found opaque type
- |
- = note: expected opaque type `impl Future<Output = ()>` (`async` closure body)
- found opaque type `impl Future<Output = ()>` (`async` closure body)
+ = note: expected `async` closure body `[async closure body@$DIR/generator-desc.rs:14:19: 14:21]`
+ found `async` closure body `[async closure body@$DIR/generator-desc.rs:14:36: 14:38]`
note: function defined here
--> $DIR/generator-desc.rs:8:4
|
diff --git a/src/test/ui/async-await/generator-not-future.rs b/src/test/ui/async-await/generator-not-future.rs
new file mode 100644
index 000000000..37d7cfa6f
--- /dev/null
+++ b/src/test/ui/async-await/generator-not-future.rs
@@ -0,0 +1,45 @@
+// edition:2018
+#![feature(generators, generator_trait)]
+
+use std::future::Future;
+use std::ops::Generator;
+
+async fn async_fn() {}
+fn returns_async_block() -> impl Future<Output = ()> {
+ async {}
+}
+fn returns_generator() -> impl Generator<(), Yield = (), Return = ()> {
+ || {
+ let _: () = yield ();
+ }
+}
+
+fn takes_future(_f: impl Future<Output = ()>) {}
+fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {}
+
+fn main() {
+ // okay:
+ takes_future(async_fn());
+ takes_future(returns_async_block());
+ takes_future(async {});
+ takes_generator(returns_generator());
+ takes_generator(|| {
+ let _: () = yield ();
+ });
+
+ // async futures are not generators:
+ takes_generator(async_fn());
+ //~^ ERROR the trait bound
+ takes_generator(returns_async_block());
+ //~^ ERROR the trait bound
+ takes_generator(async {});
+ //~^ ERROR the trait bound
+
+ // generators are not futures:
+ takes_future(returns_generator());
+ //~^ ERROR is not a future
+ takes_future(|ctx| {
+ //~^ ERROR is not a future
+ ctx = yield ();
+ });
+}
diff --git a/src/test/ui/async-await/generator-not-future.stderr b/src/test/ui/async-await/generator-not-future.stderr
new file mode 100644
index 000000000..1b81b461f
--- /dev/null
+++ b/src/test/ui/async-await/generator-not-future.stderr
@@ -0,0 +1,81 @@
+error[E0277]: the trait bound `impl Future<Output = ()>: Generator<_>` is not satisfied
+ --> $DIR/generator-not-future.rs:31:21
+ |
+LL | takes_generator(async_fn());
+ | --------------- ^^^^^^^^^^ the trait `Generator<_>` is not implemented for `impl Future<Output = ()>`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `takes_generator`
+ --> $DIR/generator-not-future.rs:18:39
+ |
+LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator`
+
+error[E0277]: the trait bound `impl Future<Output = ()>: Generator<_>` is not satisfied
+ --> $DIR/generator-not-future.rs:33:21
+ |
+LL | takes_generator(returns_async_block());
+ | --------------- ^^^^^^^^^^^^^^^^^^^^^ the trait `Generator<_>` is not implemented for `impl Future<Output = ()>`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `takes_generator`
+ --> $DIR/generator-not-future.rs:18:39
+ |
+LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator`
+
+error[E0277]: the trait bound `[async block@$DIR/generator-not-future.rs:35:21: 35:29]: Generator<_>` is not satisfied
+ --> $DIR/generator-not-future.rs:35:21
+ |
+LL | takes_generator(async {});
+ | --------------- ^^^^^^^^ the trait `Generator<_>` is not implemented for `[async block@$DIR/generator-not-future.rs:35:21: 35:29]`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `takes_generator`
+ --> $DIR/generator-not-future.rs:18:39
+ |
+LL | fn takes_generator<ResumeTy>(_g: impl Generator<ResumeTy, Yield = (), Return = ()>) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_generator`
+
+error[E0277]: `impl Generator<Yield = (), Return = ()>` is not a future
+ --> $DIR/generator-not-future.rs:39:18
+ |
+LL | takes_future(returns_generator());
+ | ------------ ^^^^^^^^^^^^^^^^^^^ `impl Generator<Yield = (), Return = ()>` is not a future
+ | |
+ | required by a bound introduced by this call
+ |
+ = help: the trait `Future` is not implemented for `impl Generator<Yield = (), Return = ()>`
+ = note: impl Generator<Yield = (), Return = ()> must be a future or must implement `IntoFuture` to be awaited
+note: required by a bound in `takes_future`
+ --> $DIR/generator-not-future.rs:17:26
+ |
+LL | fn takes_future(_f: impl Future<Output = ()>) {}
+ | ^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_future`
+
+error[E0277]: `[generator@$DIR/generator-not-future.rs:41:18: 41:23]` is not a future
+ --> $DIR/generator-not-future.rs:41:18
+ |
+LL | takes_future(|ctx| {
+ | _____------------_^
+ | | |
+ | | required by a bound introduced by this call
+LL | |
+LL | | ctx = yield ();
+LL | | });
+ | |_____^ `[generator@$DIR/generator-not-future.rs:41:18: 41:23]` is not a future
+ |
+ = help: the trait `Future` is not implemented for `[generator@$DIR/generator-not-future.rs:41:18: 41:23]`
+ = note: [generator@$DIR/generator-not-future.rs:41:18: 41:23] must be a future or must implement `IntoFuture` to be awaited
+note: required by a bound in `takes_future`
+ --> $DIR/generator-not-future.rs:17:26
+ |
+LL | fn takes_future(_f: impl Future<Output = ()>) {}
+ | ^^^^^^^^^^^^^^^^^^^ required by this bound in `takes_future`
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/async-await/in-trait/async-associated-types.rs b/src/test/ui/async-await/in-trait/async-associated-types.rs
index a6f928f3b..974f5aaff 100644
--- a/src/test/ui/async-await/in-trait/async-associated-types.rs
+++ b/src/test/ui/async-await/in-trait/async-associated-types.rs
@@ -1,8 +1,8 @@
-// check-fail
-// known-bug: #102682
+// check-pass
// edition: 2021
#![feature(async_fn_in_trait)]
+#![feature(impl_trait_projections)]
#![allow(incomplete_features)]
use std::fmt::Debug;
diff --git a/src/test/ui/async-await/in-trait/async-associated-types.stderr b/src/test/ui/async-await/in-trait/async-associated-types.stderr
deleted file mode 100644
index 0985150ee..000000000
--- a/src/test/ui/async-await/in-trait/async-associated-types.stderr
+++ /dev/null
@@ -1,57 +0,0 @@
-error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
- --> $DIR/async-associated-types.rs:19:43
- |
-LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
- | ^^^^^^^^^^^^^^
- |
-note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
- --> $DIR/async-associated-types.rs:16:6
- |
-LL | impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
- | ^^
-note: ...so that the types are compatible
- --> $DIR/async-associated-types.rs:19:43
- |
-LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
- | ^^^^^^^^^^^^^^
- = note: expected `(&'a U, &'b T)`
- found `(&U, &T)`
- = note: but, the lifetime must be valid for the static lifetime...
-note: ...so that the types are compatible
- --> $DIR/async-associated-types.rs:19:43
- |
-LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
- | ^^^^^^^^^^^^^^
- = note: expected `MyTrait<'static, 'static, T>`
- found `MyTrait<'_, '_, T>`
-
-error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
- --> $DIR/async-associated-types.rs:19:43
- |
-LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
- | ^^^^^^^^^^^^^^
- |
-note: first, the lifetime cannot outlive the lifetime `'b` as defined here...
- --> $DIR/async-associated-types.rs:16:10
- |
-LL | impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
- | ^^
-note: ...so that the types are compatible
- --> $DIR/async-associated-types.rs:19:43
- |
-LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
- | ^^^^^^^^^^^^^^
- = note: expected `(&'a U, &'b T)`
- found `(&U, &T)`
- = note: but, the lifetime must be valid for the static lifetime...
-note: ...so that the types are compatible
- --> $DIR/async-associated-types.rs:19:43
- |
-LL | async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
- | ^^^^^^^^^^^^^^
- = note: expected `MyTrait<'static, 'static, T>`
- found `MyTrait<'_, '_, T>`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0495`.
diff --git a/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr b/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr
index 5c8d64fc6..f1f0d7e59 100644
--- a/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr
+++ b/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr
@@ -4,11 +4,11 @@ error[E0311]: the parameter type `U` may not live long enough
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^^^
|
-note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
+note: the parameter type `U` must be valid for the anonymous lifetime defined here...
--> $DIR/async-generics-and-bounds.rs:12:18
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
- | ^
+ | ^^^^^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics-and-bounds.rs:12:28
|
@@ -21,11 +21,11 @@ error[E0311]: the parameter type `T` may not live long enough
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^^^
|
-note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
+note: the parameter type `T` must be valid for the anonymous lifetime defined here...
--> $DIR/async-generics-and-bounds.rs:12:18
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
- | ^
+ | ^^^^^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics-and-bounds.rs:12:28
|
diff --git a/src/test/ui/async-await/in-trait/async-generics.stderr b/src/test/ui/async-await/in-trait/async-generics.stderr
index 6ae73d9e3..2f0556456 100644
--- a/src/test/ui/async-await/in-trait/async-generics.stderr
+++ b/src/test/ui/async-await/in-trait/async-generics.stderr
@@ -4,11 +4,11 @@ error[E0311]: the parameter type `U` may not live long enough
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^
|
-note: the parameter type `U` must be valid for the anonymous lifetime as defined here...
+note: the parameter type `U` must be valid for the anonymous lifetime defined here...
--> $DIR/async-generics.rs:9:18
|
LL | async fn foo(&self) -> &(T, U);
- | ^
+ | ^^^^^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics.rs:9:28
|
@@ -21,11 +21,11 @@ error[E0311]: the parameter type `T` may not live long enough
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^
|
-note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
+note: the parameter type `T` must be valid for the anonymous lifetime defined here...
--> $DIR/async-generics.rs:9:18
|
LL | async fn foo(&self) -> &(T, U);
- | ^
+ | ^^^^^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics.rs:9:28
|
diff --git a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs b/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs
index 3f7448cec..d5481d277 100644
--- a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs
+++ b/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs
@@ -1,5 +1,4 @@
-// check-fail
-// known-bug: #102682
+// check-pass
// edition: 2021
#![feature(async_fn_in_trait)]
diff --git a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr b/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr
deleted file mode 100644
index 0f0242027..000000000
--- a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.stderr
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0309]: the parameter type `Self` may not live long enough
- --> $DIR/async-lifetimes-and-bounds.rs:11:43
- |
-LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
- | ^^^^^^^^^^^^^^^^^
- |
- = help: consider adding an explicit lifetime bound `Self: 'a`...
- = note: ...so that the reference type `&'a Self` does not outlive the data it points at
-
-error[E0309]: the parameter type `T` may not live long enough
- --> $DIR/async-lifetimes-and-bounds.rs:11:43
- |
-LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
- | ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'b T` does not outlive the data it points at
- |
-help: consider adding an explicit lifetime bound...
- |
-LL | trait MyTrait<'a, 'b, T: 'b> {
- | ++++
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0309`.
diff --git a/src/test/ui/async-await/in-trait/async-lifetimes.rs b/src/test/ui/async-await/in-trait/async-lifetimes.rs
index acbac471c..f298e45d2 100644
--- a/src/test/ui/async-await/in-trait/async-lifetimes.rs
+++ b/src/test/ui/async-await/in-trait/async-lifetimes.rs
@@ -1,5 +1,4 @@
-// check-fail
-// known-bug: #102682
+// check-pass
// edition: 2021
#![feature(async_fn_in_trait)]
diff --git a/src/test/ui/async-await/in-trait/async-lifetimes.stderr b/src/test/ui/async-await/in-trait/async-lifetimes.stderr
deleted file mode 100644
index 9a7d294bb..000000000
--- a/src/test/ui/async-await/in-trait/async-lifetimes.stderr
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0309]: the parameter type `Self` may not live long enough
- --> $DIR/async-lifetimes.rs:9:43
- |
-LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T);
- | ^^^^^^^^^^^^^^^^^
- |
- = help: consider adding an explicit lifetime bound `Self: 'a`...
- = note: ...so that the reference type `&'a Self` does not outlive the data it points at
-
-error[E0309]: the parameter type `T` may not live long enough
- --> $DIR/async-lifetimes.rs:9:43
- |
-LL | async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T);
- | ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'b T` does not outlive the data it points at
- |
-help: consider adding an explicit lifetime bound...
- |
-LL | trait MyTrait<'a, 'b, T: 'b> {
- | ++++
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0309`.
diff --git a/src/test/ui/async-await/in-trait/early-bound-1.rs b/src/test/ui/async-await/in-trait/early-bound-1.rs
new file mode 100644
index 000000000..6b3b14201
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/early-bound-1.rs
@@ -0,0 +1,17 @@
+// check-pass
+// edition:2021
+
+#![feature(async_fn_in_trait)]
+#![allow(incomplete_features)]
+
+pub trait Foo {
+ async fn foo(&mut self);
+}
+
+struct MyFoo<'a>(&'a mut ());
+
+impl<'a> Foo for MyFoo<'a> {
+ async fn foo(&mut self) {}
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/in-trait/early-bound-2.rs b/src/test/ui/async-await/in-trait/early-bound-2.rs
new file mode 100644
index 000000000..270443229
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/early-bound-2.rs
@@ -0,0 +1,15 @@
+// check-pass
+// edition:2021
+
+#![feature(async_fn_in_trait)]
+#![allow(incomplete_features)]
+
+pub trait Foo {
+ async fn foo(&mut self);
+}
+
+impl<T: Foo> Foo for &mut T {
+ async fn foo(&mut self) {}
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/in-trait/implied-bounds.rs b/src/test/ui/async-await/in-trait/implied-bounds.rs
new file mode 100644
index 000000000..52bceb3cc
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/implied-bounds.rs
@@ -0,0 +1,13 @@
+// check-pass
+// edition: 2021
+
+#![feature(async_fn_in_trait)]
+#![allow(incomplete_features)]
+
+trait TcpStack {
+ type Connection<'a>: Sized where Self: 'a;
+ fn connect<'a>(&'a self) -> Self::Connection<'a>;
+ async fn async_connect<'a>(&'a self) -> Self::Connection<'a>;
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/in-trait/lifetime-mismatch.rs b/src/test/ui/async-await/in-trait/lifetime-mismatch.rs
new file mode 100644
index 000000000..45ede193c
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/lifetime-mismatch.rs
@@ -0,0 +1,20 @@
+// edition:2021
+
+#![feature(async_fn_in_trait)]
+//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+
+trait MyTrait {
+ async fn foo<'a>(&self);
+ async fn bar(&self);
+}
+
+impl MyTrait for i32 {
+ async fn foo(&self) {}
+ //~^ ERROR lifetime parameters or bounds on method `foo` do not match the trait declaration
+
+ async fn bar(&self) {
+ self.foo();
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/in-trait/lifetime-mismatch.stderr b/src/test/ui/async-await/in-trait/lifetime-mismatch.stderr
new file mode 100644
index 000000000..d87adcc78
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/lifetime-mismatch.stderr
@@ -0,0 +1,21 @@
+warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/lifetime-mismatch.rs:3:12
+ |
+LL | #![feature(async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration
+ --> $DIR/lifetime-mismatch.rs:12:17
+ |
+LL | async fn foo<'a>(&self);
+ | ---- lifetimes in impl do not match this method in trait
+...
+LL | async fn foo(&self) {}
+ | ^ lifetimes do not match method in trait
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0195`.
diff --git a/src/test/ui/async-await/in-trait/nested-rpit.rs b/src/test/ui/async-await/in-trait/nested-rpit.rs
new file mode 100644
index 000000000..41d72ebb4
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/nested-rpit.rs
@@ -0,0 +1,19 @@
+// edition: 2021
+// known-bug: #105197
+// failure-status:101
+// dont-check-compiler-stderr
+
+#![feature(async_fn_in_trait)]
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::future::Future;
+use std::marker::PhantomData;
+
+trait Lockable<K, V> {
+ async fn lock_all_entries(&self) -> impl Future<Output = Guard<'_>>;
+}
+
+struct Guard<'a>(PhantomData<&'a ()>);
+
+fn main() {}
diff --git a/src/test/ui/async-await/in-trait/object-safety.rs b/src/test/ui/async-await/in-trait/object-safety.rs
new file mode 100644
index 000000000..a8bc35f7e
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/object-safety.rs
@@ -0,0 +1,13 @@
+// edition:2021
+
+#![feature(async_fn_in_trait)]
+//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+
+trait Foo {
+ async fn foo(&self);
+}
+
+fn main() {
+ let x: &dyn Foo = todo!();
+ //~^ ERROR the trait `Foo` cannot be made into an object
+}
diff --git a/src/test/ui/async-await/in-trait/object-safety.stderr b/src/test/ui/async-await/in-trait/object-safety.stderr
new file mode 100644
index 000000000..0b318f71f
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/object-safety.stderr
@@ -0,0 +1,27 @@
+warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/object-safety.rs:3:12
+ |
+LL | #![feature(async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+error[E0038]: the trait `Foo` cannot be made into an object
+ --> $DIR/object-safety.rs:11:12
+ |
+LL | let x: &dyn Foo = todo!();
+ | ^^^^^^^^ `Foo` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/object-safety.rs:7:14
+ |
+LL | trait Foo {
+ | --- this trait cannot be made into an object...
+LL | async fn foo(&self);
+ | ^^^ ...because method `foo` is `async`
+ = help: consider moving `foo` to another trait
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0038`.
diff --git a/src/test/ui/async-await/in-trait/return-type-suggestion.rs b/src/test/ui/async-await/in-trait/return-type-suggestion.rs
new file mode 100644
index 000000000..3446761d1
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/return-type-suggestion.rs
@@ -0,0 +1,14 @@
+// edition: 2021
+
+#![feature(async_fn_in_trait)]
+//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+
+trait A {
+ async fn e() {
+ Ok(())
+ //~^ ERROR mismatched types
+ //~| HELP consider using a semicolon here
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/in-trait/return-type-suggestion.stderr b/src/test/ui/async-await/in-trait/return-type-suggestion.stderr
new file mode 100644
index 000000000..5a9b15e54
--- /dev/null
+++ b/src/test/ui/async-await/in-trait/return-type-suggestion.stderr
@@ -0,0 +1,23 @@
+warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/return-type-suggestion.rs:3:12
+ |
+LL | #![feature(async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+error[E0308]: mismatched types
+ --> $DIR/return-type-suggestion.rs:8:9
+ |
+LL | Ok(())
+ | ^^^^^^- help: consider using a semicolon here: `;`
+ | |
+ | expected `()`, found enum `Result`
+ |
+ = note: expected unit type `()`
+ found enum `Result<(), _>`
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/async-await/issue-107036.rs b/src/test/ui/async-await/issue-107036.rs
new file mode 100644
index 000000000..6a22de2c9
--- /dev/null
+++ b/src/test/ui/async-await/issue-107036.rs
@@ -0,0 +1,14 @@
+// aux-build:issue-107036.rs
+// edition:2021
+// check-pass
+
+extern crate issue_107036;
+use issue_107036::S;
+
+async fn f() {
+ S{}.f().await;
+}
+
+fn main() {
+ let _ = f();
+}
diff --git a/src/test/ui/async-await/issue-61949-self-return-type.rs b/src/test/ui/async-await/issue-61949-self-return-type.rs
index 43429ba23..d73dbc6e8 100644
--- a/src/test/ui/async-await/issue-61949-self-return-type.rs
+++ b/src/test/ui/async-await/issue-61949-self-return-type.rs
@@ -1,4 +1,5 @@
// edition:2018
+// gate-test-impl_trait_projections
// This test checks that `Self` is prohibited as a return type. See #61949 for context.
@@ -19,6 +20,7 @@ async fn foo() {
let x = {
let bar = 22;
Foo::new(&bar).await
+ //~^ ERROR `bar` does not live long enough
};
drop(x);
}
diff --git a/src/test/ui/async-await/issue-61949-self-return-type.stderr b/src/test/ui/async-await/issue-61949-self-return-type.stderr
index 52b726e18..638b197bc 100644
--- a/src/test/ui/async-await/issue-61949-self-return-type.stderr
+++ b/src/test/ui/async-await/issue-61949-self-return-type.stderr
@@ -1,9 +1,25 @@
-error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
- --> $DIR/issue-61949-self-return-type.rs:10:40
+error[E0658]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
+ --> $DIR/issue-61949-self-return-type.rs:11:40
|
LL | pub async fn new(_bar: &'a i32) -> Self {
| ^^^^ help: consider spelling out the type instead: `Foo<'a>`
+ |
+ = note: see issue #103532 <https://github.com/rust-lang/rust/issues/103532> for more information
+ = help: add `#![feature(impl_trait_projections)]` to the crate attributes to enable
+
+error[E0597]: `bar` does not live long enough
+ --> $DIR/issue-61949-self-return-type.rs:22:18
+ |
+LL | let x = {
+ | - borrow later stored here
+LL | let bar = 22;
+LL | Foo::new(&bar).await
+ | ^^^^ borrowed value does not live long enough
+LL |
+LL | };
+ | - `bar` dropped here while still borrowed
-error: aborting due to previous error
+error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0760`.
+Some errors have detailed explanations: E0597, E0658.
+For more information about an error, try `rustc --explain E0597`.
diff --git a/src/test/ui/async-await/issue-67252-unnamed-future.stderr b/src/test/ui/async-await/issue-67252-unnamed-future.stderr
index af99b608c..fcba4410b 100644
--- a/src/test/ui/async-await/issue-67252-unnamed-future.stderr
+++ b/src/test/ui/async-await/issue-67252-unnamed-future.stderr
@@ -8,7 +8,7 @@ LL | | AFuture.await;
LL | | });
| |_____^ future created by async block is not `Send`
|
- = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*mut ()`
+ = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:18:11: 21:6]`, the trait `Send` is not implemented for `*mut ()`
note: future is not `Send` as this value is used across an await
--> $DIR/issue-67252-unnamed-future.rs:20:16
|
diff --git a/src/test/ui/async-await/issue-68112.drop_tracking.stderr b/src/test/ui/async-await/issue-68112.drop_tracking.stderr
index c915164cf..f2802698f 100644
--- a/src/test/ui/async-await/issue-68112.drop_tracking.stderr
+++ b/src/test/ui/async-await/issue-68112.drop_tracking.stderr
@@ -59,10 +59,10 @@ LL | fn make_non_send_future2() -> impl Future<Output = Arc<RefCell<i32>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: required because it captures the following types: `ResumeTy`, `impl Future<Output = Arc<RefCell<i32>>>`, `()`, `Ready<i32>`
note: required because it's used within this `async` block
- --> $DIR/issue-68112.rs:60:26
+ --> $DIR/issue-68112.rs:60:20
|
LL | let send_fut = async {
- | __________________________^
+ | ____________________^
LL | | let non_send_fut = make_non_send_future2();
LL | | let _ = non_send_fut.await;
LL | | ready(0).await;
diff --git a/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr b/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr
index 11b7d1aaa..38eb85b30 100644
--- a/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr
+++ b/src/test/ui/async-await/issue-68112.no_drop_tracking.stderr
@@ -59,10 +59,10 @@ LL | fn make_non_send_future2() -> impl Future<Output = Arc<RefCell<i32>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: required because it captures the following types: `ResumeTy`, `impl Future<Output = Arc<RefCell<i32>>>`, `()`, `i32`, `Ready<i32>`
note: required because it's used within this `async` block
- --> $DIR/issue-68112.rs:60:26
+ --> $DIR/issue-68112.rs:60:20
|
LL | let send_fut = async {
- | __________________________^
+ | ____________________^
LL | | let non_send_fut = make_non_send_future2();
LL | | let _ = non_send_fut.await;
LL | | ready(0).await;
diff --git a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr
index 7fb881166..721234aa4 100644
--- a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr
+++ b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr
@@ -20,10 +20,9 @@ LL | | }
| |_^
= note: required because it captures the following types: `ResumeTy`, `impl Future<Output = ()>`, `()`
note: required because it's used within this `async` block
- --> $DIR/issue-70935-complex-spans.rs:16:16
+ --> $DIR/issue-70935-complex-spans.rs:16:5
|
-LL | async move {
- | ________________^
+LL | / async move {
LL | | baz(|| async{
LL | | foo(tx.clone());
LL | | }).await;
diff --git a/src/test/ui/async-await/issue-86507.stderr b/src/test/ui/async-await/issue-86507.stderr
index 0e21dba98..8c2c06da2 100644
--- a/src/test/ui/async-await/issue-86507.stderr
+++ b/src/test/ui/async-await/issue-86507.stderr
@@ -13,7 +13,7 @@ note: captured value is not `Send` because `&` references cannot be sent unless
|
LL | let x = x;
| ^ has type `&T` which is not `Send`, because `T` is not `Sync`
- = note: required for the cast from `impl Future<Output = ()>` to the object type `dyn Future<Output = ()> + Send`
+ = note: required for the cast from `[async block@$DIR/issue-86507.rs:18:17: 20:18]` to the object type `dyn Future<Output = ()> + Send`
help: consider further restricting this bound
|
LL | fn bar<'me, 'async_trait, T: Send + std::marker::Sync>(x: &'me T)
diff --git a/src/test/ui/async-await/issues/issue-65159.rs b/src/test/ui/async-await/issues/issue-65159.rs
index 1dbf5db6c..df2ca0257 100644
--- a/src/test/ui/async-await/issues/issue-65159.rs
+++ b/src/test/ui/async-await/issues/issue-65159.rs
@@ -6,7 +6,6 @@ async fn copy() -> Result<()>
//~^ ERROR this enum takes 2 generic arguments
{
Ok(())
- //~^ ERROR type annotations needed
}
fn main() { }
diff --git a/src/test/ui/async-await/issues/issue-65159.stderr b/src/test/ui/async-await/issues/issue-65159.stderr
index 9918f569c..45f5ec40c 100644
--- a/src/test/ui/async-await/issues/issue-65159.stderr
+++ b/src/test/ui/async-await/issues/issue-65159.stderr
@@ -16,18 +16,6 @@ help: add missing generic argument
LL | async fn copy() -> Result<(), E>
| +++
-error[E0282]: type annotations needed
- --> $DIR/issue-65159.rs:8:5
- |
-LL | Ok(())
- | ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
- |
-help: consider specifying the generic arguments
- |
-LL | Ok::<(), E>(())
- | +++++++++
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
-Some errors have detailed explanations: E0107, E0282.
-For more information about an error, try `rustc --explain E0107`.
+For more information about this error, try `rustc --explain E0107`.
diff --git a/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr
index a72350377..ab196dca2 100644
--- a/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr
+++ b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr
@@ -8,7 +8,7 @@ LL | | bar(Foo(std::ptr::null())).await;
LL | | })
| |_____^ future created by async block is not `Send`
|
- = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const u8`
+ = help: within `[async block@$DIR/issue-65436-raw-ptr-not-send.rs:16:17: 19:6]`, the trait `Send` is not implemented for `*const u8`
note: future is not `Send` as this value is used across an await
--> $DIR/issue-65436-raw-ptr-not-send.rs:18:35
|
diff --git a/src/test/ui/async-await/issues/issue-78600.stderr b/src/test/ui/async-await/issues/issue-78600.stderr
index 92b661471..37eafa996 100644
--- a/src/test/ui/async-await/issues/issue-78600.stderr
+++ b/src/test/ui/async-await/issues/issue-78600.stderr
@@ -1,11 +1,14 @@
-error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
+error[E0658]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
--> $DIR/issue-78600.rs:6:33
|
LL | async fn new(i: &'a i32) -> Result<Self, ()> {
| ^^^^^^^----^^^^^
| |
| help: consider spelling out the type instead: `S<'a>`
+ |
+ = note: see issue #103532 <https://github.com/rust-lang/rust/issues/103532> for more information
+ = help: add `#![feature(impl_trait_projections)]` to the crate attributes to enable
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0760`.
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/async-await/issues/issue-78938-async-block.stderr b/src/test/ui/async-await/issues/issue-78938-async-block.stderr
index 29aa8372f..c1a4b467f 100644
--- a/src/test/ui/async-await/issues/issue-78938-async-block.stderr
+++ b/src/test/ui/async-await/issues/issue-78938-async-block.stderr
@@ -1,8 +1,8 @@
error[E0373]: async block may outlive the current function, but it borrows `room_ref`, which is owned by the current function
- --> $DIR/issue-78938-async-block.rs:8:39
+ --> $DIR/issue-78938-async-block.rs:8:33
|
LL | let gameloop_handle = spawn(async {
- | _______________________________________^
+ | _________________________________^
LL | | game_loop(Arc::clone(&room_ref))
| | -------- `room_ref` is borrowed here
LL | | });
diff --git a/src/test/ui/async-await/large_moves.attribute.stderr b/src/test/ui/async-await/large_moves.attribute.stderr
index da34f44b2..0c5452475 100644
--- a/src/test/ui/async-await/large_moves.attribute.stderr
+++ b/src/test/ui/async-await/large_moves.attribute.stderr
@@ -1,5 +1,5 @@
error: moving 10024 bytes
- --> $DIR/large_moves.rs:12:13
+ --> $DIR/large_moves.rs:13:13
|
LL | let x = async {
| _____________^
@@ -18,7 +18,7 @@ LL | #![deny(large_assignments)]
| ^^^^^^^^^^^^^^^^^
error: moving 10024 bytes
- --> $DIR/large_moves.rs:18:14
+ --> $DIR/large_moves.rs:19:14
|
LL | let z = (x, 42);
| ^ value moved from here
@@ -26,7 +26,7 @@ LL | let z = (x, 42);
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
error: moving 10024 bytes
- --> $DIR/large_moves.rs:18:13
+ --> $DIR/large_moves.rs:19:13
|
LL | let z = (x, 42);
| ^^^^^^^ value moved from here
@@ -34,7 +34,7 @@ LL | let z = (x, 42);
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
error: moving 10024 bytes
- --> $DIR/large_moves.rs:20:13
+ --> $DIR/large_moves.rs:21:13
|
LL | let a = z.0;
| ^^^ value moved from here
diff --git a/src/test/ui/async-await/large_moves.option.stderr b/src/test/ui/async-await/large_moves.option.stderr
index da34f44b2..0c5452475 100644
--- a/src/test/ui/async-await/large_moves.option.stderr
+++ b/src/test/ui/async-await/large_moves.option.stderr
@@ -1,5 +1,5 @@
error: moving 10024 bytes
- --> $DIR/large_moves.rs:12:13
+ --> $DIR/large_moves.rs:13:13
|
LL | let x = async {
| _____________^
@@ -18,7 +18,7 @@ LL | #![deny(large_assignments)]
| ^^^^^^^^^^^^^^^^^
error: moving 10024 bytes
- --> $DIR/large_moves.rs:18:14
+ --> $DIR/large_moves.rs:19:14
|
LL | let z = (x, 42);
| ^ value moved from here
@@ -26,7 +26,7 @@ LL | let z = (x, 42);
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
error: moving 10024 bytes
- --> $DIR/large_moves.rs:18:13
+ --> $DIR/large_moves.rs:19:13
|
LL | let z = (x, 42);
| ^^^^^^^ value moved from here
@@ -34,7 +34,7 @@ LL | let z = (x, 42);
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
error: moving 10024 bytes
- --> $DIR/large_moves.rs:20:13
+ --> $DIR/large_moves.rs:21:13
|
LL | let a = z.0;
| ^^^ value moved from here
diff --git a/src/test/ui/async-await/large_moves.rs b/src/test/ui/async-await/large_moves.rs
index 18bb538a8..d43d0eec0 100644
--- a/src/test/ui/async-await/large_moves.rs
+++ b/src/test/ui/async-await/large_moves.rs
@@ -7,6 +7,7 @@
// [option]compile-flags: -Zmove-size-limit=1000
// edition:2018
+// compile-flags: -Zmir-opt-level=0
fn main() {
let x = async { //~ ERROR large_assignments
diff --git a/src/test/ui/async-await/track-caller/async-closure-gate.rs b/src/test/ui/async-await/track-caller/async-closure-gate.rs
new file mode 100644
index 000000000..d9d556855
--- /dev/null
+++ b/src/test/ui/async-await/track-caller/async-closure-gate.rs
@@ -0,0 +1,9 @@
+// edition:2021
+
+#![feature(async_closure, stmt_expr_attributes)]
+
+fn main() {
+ let _ = #[track_caller] async || {
+ //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
+ };
+}
diff --git a/src/test/ui/async-await/track-caller/async-closure-gate.stderr b/src/test/ui/async-await/track-caller/async-closure-gate.stderr
new file mode 100644
index 000000000..498f1b43b
--- /dev/null
+++ b/src/test/ui/async-await/track-caller/async-closure-gate.stderr
@@ -0,0 +1,12 @@
+error[E0658]: `#[track_caller]` on closures is currently unstable
+ --> $DIR/async-closure-gate.rs:6:13
+ |
+LL | let _ = #[track_caller] async || {
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
+ = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/async-await/track-caller/issue-105134.rs b/src/test/ui/async-await/track-caller/issue-105134.rs
new file mode 100644
index 000000000..4e52b8e25
--- /dev/null
+++ b/src/test/ui/async-await/track-caller/issue-105134.rs
@@ -0,0 +1,11 @@
+// check-pass
+// edition:2021
+
+#[track_caller]
+fn f() {
+ let _ = async {};
+}
+
+fn main() {
+ f();
+}
diff --git a/src/test/ui/async-await/track-caller/panic-track-caller.nofeat.stderr b/src/test/ui/async-await/track-caller/panic-track-caller.nofeat.stderr
new file mode 100644
index 000000000..51ea225f4
--- /dev/null
+++ b/src/test/ui/async-await/track-caller/panic-track-caller.nofeat.stderr
@@ -0,0 +1,29 @@
+warning: `#[track_caller]` on async functions is a no-op
+ --> $DIR/panic-track-caller.rs:50:1
+ |
+LL | #[track_caller]
+ | ^^^^^^^^^^^^^^^
+LL | / async fn bar_track_caller() {
+LL | | panic!()
+LL | | }
+ | |_- this function will not propagate the caller location
+ |
+ = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
+ = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
+ = note: `#[warn(ungated_async_fn_track_caller)]` on by default
+
+warning: `#[track_caller]` on async functions is a no-op
+ --> $DIR/panic-track-caller.rs:62:5
+ |
+LL | #[track_caller]
+ | ^^^^^^^^^^^^^^^
+LL | / async fn bar_assoc() {
+LL | | panic!();
+LL | | }
+ | |_____- this function will not propagate the caller location
+ |
+ = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
+ = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
+
+warning: 2 warnings emitted
+
diff --git a/src/test/ui/async-await/track-caller/panic-track-caller.rs b/src/test/ui/async-await/track-caller/panic-track-caller.rs
new file mode 100644
index 000000000..118361d6c
--- /dev/null
+++ b/src/test/ui/async-await/track-caller/panic-track-caller.rs
@@ -0,0 +1,100 @@
+// run-pass
+// edition:2021
+// revisions: feat nofeat
+// needs-unwind
+#![feature(async_closure, stmt_expr_attributes)]
+#![cfg_attr(feat, feature(closure_track_caller))]
+
+use std::future::Future;
+use std::panic;
+use std::sync::{Arc, Mutex};
+use std::task::{Context, Poll, Wake};
+use std::thread::{self, Thread};
+
+/// A waker that wakes up the current thread when called.
+struct ThreadWaker(Thread);
+
+impl Wake for ThreadWaker {
+ fn wake(self: Arc<Self>) {
+ self.0.unpark();
+ }
+}
+
+/// Run a future to completion on the current thread.
+fn block_on<T>(fut: impl Future<Output = T>) -> T {
+ // Pin the future so it can be polled.
+ let mut fut = Box::pin(fut);
+
+ // Create a new context to be passed to the future.
+ let t = thread::current();
+ let waker = Arc::new(ThreadWaker(t)).into();
+ let mut cx = Context::from_waker(&waker);
+
+ // Run the future to completion.
+ loop {
+ match fut.as_mut().poll(&mut cx) {
+ Poll::Ready(res) => return res,
+ Poll::Pending => thread::park(),
+ }
+ }
+}
+
+async fn bar() {
+ panic!()
+}
+
+async fn foo() {
+ bar().await
+}
+
+#[track_caller] //[nofeat]~ WARN `#[track_caller]` on async functions is a no-op
+async fn bar_track_caller() {
+ panic!()
+}
+
+async fn foo_track_caller() {
+ bar_track_caller().await
+}
+
+struct Foo;
+
+impl Foo {
+ #[track_caller] //[nofeat]~ WARN `#[track_caller]` on async functions is a no-op
+ async fn bar_assoc() {
+ panic!();
+ }
+}
+
+async fn foo_assoc() {
+ Foo::bar_assoc().await
+}
+
+fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 {
+ let loc = Arc::new(Mutex::new(None));
+
+ let hook = panic::take_hook();
+ {
+ let loc = loc.clone();
+ panic::set_hook(Box::new(move |info| {
+ *loc.lock().unwrap() = info.location().map(|loc| loc.line())
+ }));
+ }
+ panic::catch_unwind(f).unwrap_err();
+ panic::set_hook(hook);
+ let x = loc.lock().unwrap().unwrap();
+ x
+}
+
+fn main() {
+ assert_eq!(panicked_at(|| block_on(foo())), 43);
+
+ #[cfg(feat)]
+ assert_eq!(panicked_at(|| block_on(foo_track_caller())), 56);
+ #[cfg(nofeat)]
+ assert_eq!(panicked_at(|| block_on(foo_track_caller())), 52);
+
+ #[cfg(feat)]
+ assert_eq!(panicked_at(|| block_on(foo_assoc())), 69);
+ #[cfg(nofeat)]
+ assert_eq!(panicked_at(|| block_on(foo_assoc())), 64);
+}
diff --git a/src/test/ui/async-await/try-on-option-in-async.stderr b/src/test/ui/async-await/try-on-option-in-async.stderr
index a55850d76..4c7b4fa41 100644
--- a/src/test/ui/async-await/try-on-option-in-async.stderr
+++ b/src/test/ui/async-await/try-on-option-in-async.stderr
@@ -1,8 +1,7 @@
error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-on-option-in-async.rs:8:10
|
-LL | async {
- | ___________-
+LL | / async {
LL | | let x: Option<u32> = None;
LL | | x?;
| | ^ cannot use the `?` operator in an async block that returns `{integer}`