diff options
Diffstat (limited to '')
-rw-r--r-- | tests/ui/async-await/in-trait/async-associated-types.rs (renamed from src/test/ui/async-await/in-trait/async-associated-types.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-associated-types2.rs (renamed from src/test/ui/async-await/in-trait/async-associated-types2.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs (renamed from src/test/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr (renamed from src/test/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr) | 4 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-example-desugared-boxed.rs | 21 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr | 11 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-example-desugared-extra.rs | 37 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs (renamed from src/test/ui/async-await/in-trait/async-example-desugared-in-trait.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-example-desugared-manual.rs | 29 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-example-desugared-manual.stderr | 11 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-example-desugared.rs | 20 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-example.rs (renamed from src/test/ui/async-await/in-trait/async-example.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-generics-and-bounds.rs (renamed from src/test/ui/async-await/in-trait/async-generics-and-bounds.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-generics-and-bounds.stderr (renamed from src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-generics.rs (renamed from src/test/ui/async-await/in-trait/async-generics.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-generics.stderr (renamed from src/test/ui/async-await/in-trait/async-generics.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs (renamed from src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-lifetimes.rs (renamed from src/test/ui/async-await/in-trait/async-lifetimes.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-recursive-generic.rs (renamed from src/test/ui/async-await/in-trait/async-recursive-generic.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-recursive-generic.stderr (renamed from src/test/ui/async-await/in-trait/async-recursive-generic.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-recursive.rs (renamed from src/test/ui/async-await/in-trait/async-recursive.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/async-recursive.stderr (renamed from src/test/ui/async-await/in-trait/async-recursive.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/bad-signatures.rs | 16 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/bad-signatures.stderr | 26 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/early-bound-1.rs (renamed from src/test/ui/async-await/in-trait/early-bound-1.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/early-bound-2.rs (renamed from src/test/ui/async-await/in-trait/early-bound-2.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/fn-not-async-err.rs (renamed from src/test/ui/async-await/in-trait/fn-not-async-err.rs) | 2 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/fn-not-async-err.stderr | 11 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/fn-not-async-err2.rs (renamed from src/test/ui/async-await/in-trait/fn-not-async-err2.rs) | 4 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/fn-not-async-err2.stderr (renamed from src/test/ui/async-await/in-trait/fn-not-async-err2.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/implied-bounds.rs (renamed from src/test/ui/async-await/in-trait/implied-bounds.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/issue-102138.rs (renamed from src/test/ui/async-await/in-trait/issue-102138.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/issue-102219.rs (renamed from src/test/ui/async-await/in-trait/issue-102219.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/issue-102310.rs (renamed from src/test/ui/async-await/in-trait/issue-102310.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/issue-104678.rs | 31 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/lifetime-mismatch.rs (renamed from src/test/ui/async-await/in-trait/lifetime-mismatch.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/lifetime-mismatch.stderr (renamed from src/test/ui/async-await/in-trait/lifetime-mismatch.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/missing-send-bound.rs | 21 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/missing-send-bound.stderr | 29 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/nested-rpit.rs (renamed from src/test/ui/async-await/in-trait/nested-rpit.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/object-safety.rs (renamed from src/test/ui/async-await/in-trait/object-safety.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/object-safety.stderr (renamed from src/test/ui/async-await/in-trait/object-safety.stderr) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/return-type-suggestion.rs (renamed from src/test/ui/async-await/in-trait/return-type-suggestion.rs) | 0 | ||||
-rw-r--r-- | tests/ui/async-await/in-trait/return-type-suggestion.stderr (renamed from src/test/ui/async-await/in-trait/return-type-suggestion.stderr) | 0 |
44 files changed, 267 insertions, 6 deletions
diff --git a/src/test/ui/async-await/in-trait/async-associated-types.rs b/tests/ui/async-await/in-trait/async-associated-types.rs index 974f5aaff..974f5aaff 100644 --- a/src/test/ui/async-await/in-trait/async-associated-types.rs +++ b/tests/ui/async-await/in-trait/async-associated-types.rs diff --git a/src/test/ui/async-await/in-trait/async-associated-types2.rs b/tests/ui/async-await/in-trait/async-associated-types2.rs index e546a0579..e546a0579 100644 --- a/src/test/ui/async-await/in-trait/async-associated-types2.rs +++ b/tests/ui/async-await/in-trait/async-associated-types2.rs diff --git a/src/test/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs index 38ba29718..38ba29718 100644 --- a/src/test/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs diff --git a/src/test/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr index 22d2928f2..13e722255 100644 --- a/src/test/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr @@ -9,8 +9,8 @@ note: type in trait | LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected fn pointer `fn(&i32) -> Pin<Box<dyn Future<Output = i32>>>` - found fn pointer `fn(&i32) -> impl Future<Output = i32>` + = note: expected signature `fn(&i32) -> Pin<Box<dyn Future<Output = i32>>>` + found signature `fn(&i32) -> impl Future<Output = i32>` error: aborting due to previous error diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs new file mode 100644 index 000000000..1b1b3cffd --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs @@ -0,0 +1,21 @@ +// edition: 2021 + +#![feature(async_fn_in_trait)] +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +use std::future::Future; +use std::pin::Pin; + +trait MyTrait { + async fn foo(&self) -> i32; +} + +impl MyTrait for i32 { + fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>> { + //~^ ERROR method `foo` should be async + Box::pin(async { *self }) + } +} + +fn main() {} diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr new file mode 100644 index 000000000..60fa534a6 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr @@ -0,0 +1,11 @@ +error: method `foo` should be async because the method from the trait is async + --> $DIR/async-example-desugared-boxed.rs:15:5 + | +LL | async fn foo(&self) -> i32; + | --------------------------- required because the trait method is async +... +LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/async-await/in-trait/async-example-desugared-extra.rs b/tests/ui/async-await/in-trait/async-example-desugared-extra.rs new file mode 100644 index 000000000..81e1e59a3 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-extra.rs @@ -0,0 +1,37 @@ +// check-pass +// edition: 2021 + +#![feature(async_fn_in_trait)] +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +use std::future::Future; +use std::pin::Pin; +use std::task::Poll; + +trait MyTrait { + async fn foo(&self) -> i32; +} + +#[derive(Clone)] +struct MyFuture(i32); + +impl Future for MyFuture { + type Output = i32; + fn poll( + self: Pin<&mut Self>, + _: &mut std::task::Context<'_>, + ) -> Poll<<Self as Future>::Output> { + Poll::Ready(self.0) + } +} + +impl MyTrait for i32 { + // FIXME: this should eventually require `#[refine]` to compile, because it also provides + // `Clone`. + fn foo(&self) -> impl Future<Output = i32> + Clone { + MyFuture(*self) + } +} + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/async-example-desugared-in-trait.rs b/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs index feeda719e..feeda719e 100644 --- a/src/test/ui/async-await/in-trait/async-example-desugared-in-trait.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.rs b/tests/ui/async-await/in-trait/async-example-desugared-manual.rs new file mode 100644 index 000000000..71473e745 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.rs @@ -0,0 +1,29 @@ +// edition: 2021 + +#![feature(async_fn_in_trait)] +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +use std::future::Future; +use std::task::Poll; + +trait MyTrait { + async fn foo(&self) -> i32; +} + +struct MyFuture; +impl Future for MyFuture { + type Output = i32; + fn poll(self: std::pin::Pin<&mut Self>, _: &mut std::task::Context<'_>) -> Poll<Self::Output> { + Poll::Ready(0) + } +} + +impl MyTrait for u32 { + fn foo(&self) -> MyFuture { + //~^ ERROR method `foo` should be async + MyFuture + } +} + +fn main() {} diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr new file mode 100644 index 000000000..567a36a86 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr @@ -0,0 +1,11 @@ +error: method `foo` should be async because the method from the trait is async + --> $DIR/async-example-desugared-manual.rs:23:5 + | +LL | async fn foo(&self) -> i32; + | --------------------------- required because the trait method is async +... +LL | fn foo(&self) -> MyFuture { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/async-await/in-trait/async-example-desugared.rs b/tests/ui/async-await/in-trait/async-example-desugared.rs new file mode 100644 index 000000000..fb92ec786 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared.rs @@ -0,0 +1,20 @@ +// check-pass +// edition: 2021 + +#![feature(async_fn_in_trait)] +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +use std::future::Future; + +trait MyTrait { + async fn foo(&self) -> i32; +} + +impl MyTrait for i32 { + fn foo(&self) -> impl Future<Output = i32> + '_ { + async { *self } + } +} + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/async-example.rs b/tests/ui/async-await/in-trait/async-example.rs index abf94ef74..abf94ef74 100644 --- a/src/test/ui/async-await/in-trait/async-example.rs +++ b/tests/ui/async-await/in-trait/async-example.rs diff --git a/src/test/ui/async-await/in-trait/async-generics-and-bounds.rs b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs index a73d55adf..a73d55adf 100644 --- a/src/test/ui/async-await/in-trait/async-generics-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs diff --git a/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr index f1f0d7e59..f1f0d7e59 100644 --- a/src/test/ui/async-await/in-trait/async-generics-and-bounds.stderr +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr diff --git a/src/test/ui/async-await/in-trait/async-generics.rs b/tests/ui/async-await/in-trait/async-generics.rs index 67000e577..67000e577 100644 --- a/src/test/ui/async-await/in-trait/async-generics.rs +++ b/tests/ui/async-await/in-trait/async-generics.rs diff --git a/src/test/ui/async-await/in-trait/async-generics.stderr b/tests/ui/async-await/in-trait/async-generics.stderr index 2f0556456..2f0556456 100644 --- a/src/test/ui/async-await/in-trait/async-generics.stderr +++ b/tests/ui/async-await/in-trait/async-generics.stderr diff --git a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs b/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs index d5481d277..d5481d277 100644 --- a/src/test/ui/async-await/in-trait/async-lifetimes-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs diff --git a/src/test/ui/async-await/in-trait/async-lifetimes.rs b/tests/ui/async-await/in-trait/async-lifetimes.rs index f298e45d2..f298e45d2 100644 --- a/src/test/ui/async-await/in-trait/async-lifetimes.rs +++ b/tests/ui/async-await/in-trait/async-lifetimes.rs diff --git a/src/test/ui/async-await/in-trait/async-recursive-generic.rs b/tests/ui/async-await/in-trait/async-recursive-generic.rs index 6839abd38..6839abd38 100644 --- a/src/test/ui/async-await/in-trait/async-recursive-generic.rs +++ b/tests/ui/async-await/in-trait/async-recursive-generic.rs diff --git a/src/test/ui/async-await/in-trait/async-recursive-generic.stderr b/tests/ui/async-await/in-trait/async-recursive-generic.stderr index cab173bdd..cab173bdd 100644 --- a/src/test/ui/async-await/in-trait/async-recursive-generic.stderr +++ b/tests/ui/async-await/in-trait/async-recursive-generic.stderr diff --git a/src/test/ui/async-await/in-trait/async-recursive.rs b/tests/ui/async-await/in-trait/async-recursive.rs index 61119f809..61119f809 100644 --- a/src/test/ui/async-await/in-trait/async-recursive.rs +++ b/tests/ui/async-await/in-trait/async-recursive.rs diff --git a/src/test/ui/async-await/in-trait/async-recursive.stderr b/tests/ui/async-await/in-trait/async-recursive.stderr index 9feff37b3..9feff37b3 100644 --- a/src/test/ui/async-await/in-trait/async-recursive.stderr +++ b/tests/ui/async-await/in-trait/async-recursive.stderr diff --git a/tests/ui/async-await/in-trait/bad-signatures.rs b/tests/ui/async-await/in-trait/bad-signatures.rs new file mode 100644 index 000000000..b86f1d1c1 --- /dev/null +++ b/tests/ui/async-await/in-trait/bad-signatures.rs @@ -0,0 +1,16 @@ +// edition:2021 + +#![feature(async_fn_in_trait)] +//~^ WARN the feature `async_fn_in_trait` is incomplete + +trait MyTrait { + async fn bar(&abc self); + //~^ ERROR expected identifier, found keyword `self` + //~| ERROR expected one of `:`, `@`, or `|`, found keyword `self` +} + +impl MyTrait for () { + async fn bar(&self) {} +} + +fn main() {} diff --git a/tests/ui/async-await/in-trait/bad-signatures.stderr b/tests/ui/async-await/in-trait/bad-signatures.stderr new file mode 100644 index 000000000..e0ba7b53e --- /dev/null +++ b/tests/ui/async-await/in-trait/bad-signatures.stderr @@ -0,0 +1,26 @@ +error: expected identifier, found keyword `self` + --> $DIR/bad-signatures.rs:7:23 + | +LL | async fn bar(&abc self); + | ^^^^ expected identifier, found keyword + +error: expected one of `:`, `@`, or `|`, found keyword `self` + --> $DIR/bad-signatures.rs:7:23 + | +LL | async fn bar(&abc self); + | -----^^^^ + | | | + | | expected one of `:`, `@`, or `|` + | help: declare the type after the parameter binding: `<identifier>: <type>` + +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/bad-signatures.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: aborting due to 2 previous errors; 1 warning emitted + diff --git a/src/test/ui/async-await/in-trait/early-bound-1.rs b/tests/ui/async-await/in-trait/early-bound-1.rs index 6b3b14201..6b3b14201 100644 --- a/src/test/ui/async-await/in-trait/early-bound-1.rs +++ b/tests/ui/async-await/in-trait/early-bound-1.rs diff --git a/src/test/ui/async-await/in-trait/early-bound-2.rs b/tests/ui/async-await/in-trait/early-bound-2.rs index 270443229..270443229 100644 --- a/src/test/ui/async-await/in-trait/early-bound-2.rs +++ b/tests/ui/async-await/in-trait/early-bound-2.rs diff --git a/src/test/ui/async-await/in-trait/fn-not-async-err.rs b/tests/ui/async-await/in-trait/fn-not-async-err.rs index f94d32145..9598d53bc 100644 --- a/src/test/ui/async-await/in-trait/fn-not-async-err.rs +++ b/tests/ui/async-await/in-trait/fn-not-async-err.rs @@ -9,7 +9,7 @@ trait MyTrait { impl MyTrait for i32 { fn foo(&self) -> i32 { - //~^ ERROR: `i32` is not a future [E0277] + //~^ ERROR: method `foo` should be async *self } } diff --git a/tests/ui/async-await/in-trait/fn-not-async-err.stderr b/tests/ui/async-await/in-trait/fn-not-async-err.stderr new file mode 100644 index 000000000..579801d0f --- /dev/null +++ b/tests/ui/async-await/in-trait/fn-not-async-err.stderr @@ -0,0 +1,11 @@ +error: method `foo` should be async because the method from the trait is async + --> $DIR/fn-not-async-err.rs:11:5 + | +LL | async fn foo(&self) -> i32; + | --------------------------- required because the trait method is async +... +LL | fn foo(&self) -> i32 { + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/async-await/in-trait/fn-not-async-err2.rs b/tests/ui/async-await/in-trait/fn-not-async-err2.rs index 594baa91a..2c4ed5535 100644 --- a/src/test/ui/async-await/in-trait/fn-not-async-err2.rs +++ b/tests/ui/async-await/in-trait/fn-not-async-err2.rs @@ -12,9 +12,7 @@ trait MyTrait { impl MyTrait for i32 { fn foo(&self) -> impl Future<Output = i32> { //~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `impl` method return [E0562] - async { - *self - } + async { *self } } } diff --git a/src/test/ui/async-await/in-trait/fn-not-async-err2.stderr b/tests/ui/async-await/in-trait/fn-not-async-err2.stderr index f591f1847..f591f1847 100644 --- a/src/test/ui/async-await/in-trait/fn-not-async-err2.stderr +++ b/tests/ui/async-await/in-trait/fn-not-async-err2.stderr diff --git a/src/test/ui/async-await/in-trait/implied-bounds.rs b/tests/ui/async-await/in-trait/implied-bounds.rs index 52bceb3cc..52bceb3cc 100644 --- a/src/test/ui/async-await/in-trait/implied-bounds.rs +++ b/tests/ui/async-await/in-trait/implied-bounds.rs diff --git a/src/test/ui/async-await/in-trait/issue-102138.rs b/tests/ui/async-await/in-trait/issue-102138.rs index f61b34ed9..f61b34ed9 100644 --- a/src/test/ui/async-await/in-trait/issue-102138.rs +++ b/tests/ui/async-await/in-trait/issue-102138.rs diff --git a/src/test/ui/async-await/in-trait/issue-102219.rs b/tests/ui/async-await/in-trait/issue-102219.rs index 9a35f6515..9a35f6515 100644 --- a/src/test/ui/async-await/in-trait/issue-102219.rs +++ b/tests/ui/async-await/in-trait/issue-102219.rs diff --git a/src/test/ui/async-await/in-trait/issue-102310.rs b/tests/ui/async-await/in-trait/issue-102310.rs index 49c3e9fee..49c3e9fee 100644 --- a/src/test/ui/async-await/in-trait/issue-102310.rs +++ b/tests/ui/async-await/in-trait/issue-102310.rs diff --git a/tests/ui/async-await/in-trait/issue-104678.rs b/tests/ui/async-await/in-trait/issue-104678.rs new file mode 100644 index 000000000..e396df4e5 --- /dev/null +++ b/tests/ui/async-await/in-trait/issue-104678.rs @@ -0,0 +1,31 @@ +// edition:2021 +// check-pass + +#![feature(async_fn_in_trait)] +#![allow(incomplete_features)] + +use std::future::Future; +pub trait Pool { + type Conn; + + async fn async_callback<'a, F: FnOnce(&'a Self::Conn) -> Fut, Fut: Future<Output = ()>>( + &'a self, + callback: F, + ) -> (); +} + +pub struct PoolImpl; +pub struct ConnImpl; + +impl Pool for PoolImpl { + type Conn = ConnImpl; + + async fn async_callback<'a, F: FnOnce(&'a Self::Conn) -> Fut, Fut: Future<Output = ()>>( + &'a self, + _callback: F, + ) -> () { + todo!() + } +} + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/lifetime-mismatch.rs b/tests/ui/async-await/in-trait/lifetime-mismatch.rs index 45ede193c..45ede193c 100644 --- a/src/test/ui/async-await/in-trait/lifetime-mismatch.rs +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.rs diff --git a/src/test/ui/async-await/in-trait/lifetime-mismatch.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.stderr index d87adcc78..d87adcc78 100644 --- a/src/test/ui/async-await/in-trait/lifetime-mismatch.stderr +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.stderr diff --git a/tests/ui/async-await/in-trait/missing-send-bound.rs b/tests/ui/async-await/in-trait/missing-send-bound.rs new file mode 100644 index 000000000..78922b59b --- /dev/null +++ b/tests/ui/async-await/in-trait/missing-send-bound.rs @@ -0,0 +1,21 @@ +// 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 bar(); +} + +async fn test<T: Foo>() { + T::bar().await; +} + +fn test2<T: Foo>() { + assert_is_send(test::<T>()); + //~^ ERROR future cannot be sent between threads safely +} + +fn assert_is_send(_: impl Send) {} + +fn main() {} diff --git a/tests/ui/async-await/in-trait/missing-send-bound.stderr b/tests/ui/async-await/in-trait/missing-send-bound.stderr new file mode 100644 index 000000000..5cedf3ddb --- /dev/null +++ b/tests/ui/async-await/in-trait/missing-send-bound.stderr @@ -0,0 +1,29 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/missing-send-bound.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: future cannot be sent between threads safely + --> $DIR/missing-send-bound.rs:15:20 + | +LL | assert_is_send(test::<T>()); + | ^^^^^^^^^^^ future returned by `test` is not `Send` + | + = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` +note: future is not `Send` as it awaits another future which is not `Send` + --> $DIR/missing-send-bound.rs:11:5 + | +LL | T::bar().await; + | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` +note: required by a bound in `assert_is_send` + --> $DIR/missing-send-bound.rs:19:27 + | +LL | fn assert_is_send(_: impl Send) {} + | ^^^^ required by this bound in `assert_is_send` + +error: aborting due to previous error; 1 warning emitted + diff --git a/src/test/ui/async-await/in-trait/nested-rpit.rs b/tests/ui/async-await/in-trait/nested-rpit.rs index 41d72ebb4..41d72ebb4 100644 --- a/src/test/ui/async-await/in-trait/nested-rpit.rs +++ b/tests/ui/async-await/in-trait/nested-rpit.rs diff --git a/src/test/ui/async-await/in-trait/object-safety.rs b/tests/ui/async-await/in-trait/object-safety.rs index a8bc35f7e..a8bc35f7e 100644 --- a/src/test/ui/async-await/in-trait/object-safety.rs +++ b/tests/ui/async-await/in-trait/object-safety.rs diff --git a/src/test/ui/async-await/in-trait/object-safety.stderr b/tests/ui/async-await/in-trait/object-safety.stderr index 0b318f71f..0b318f71f 100644 --- a/src/test/ui/async-await/in-trait/object-safety.stderr +++ b/tests/ui/async-await/in-trait/object-safety.stderr diff --git a/src/test/ui/async-await/in-trait/return-type-suggestion.rs b/tests/ui/async-await/in-trait/return-type-suggestion.rs index 3446761d1..3446761d1 100644 --- a/src/test/ui/async-await/in-trait/return-type-suggestion.rs +++ b/tests/ui/async-await/in-trait/return-type-suggestion.rs diff --git a/src/test/ui/async-await/in-trait/return-type-suggestion.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.stderr index 5a9b15e54..5a9b15e54 100644 --- a/src/test/ui/async-await/in-trait/return-type-suggestion.stderr +++ b/tests/ui/async-await/in-trait/return-type-suggestion.stderr |