diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/crashes/117629.rs | 10 | ||||
| -rw-r--r-- | tests/ui/traits/const-traits/const-trait-async-assoc-fn.rs | 18 | ||||
| -rw-r--r-- | tests/ui/traits/const-traits/const-trait-async-assoc-fn.stderr | 18 |
3 files changed, 36 insertions, 10 deletions
diff --git a/tests/crashes/117629.rs b/tests/crashes/117629.rs deleted file mode 100644 index f63365395c6..00000000000 --- a/tests/crashes/117629.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ known-bug: #117629 -//@ edition:2021 - -#![feature(const_trait_impl)] - -const trait Tr { - async fn ft1() {} -} - -fn main() {} diff --git a/tests/ui/traits/const-traits/const-trait-async-assoc-fn.rs b/tests/ui/traits/const-traits/const-trait-async-assoc-fn.rs new file mode 100644 index 00000000000..00fdccc2ac8 --- /dev/null +++ b/tests/ui/traits/const-traits/const-trait-async-assoc-fn.rs @@ -0,0 +1,18 @@ +//@ edition: 2021 +#![feature(const_trait_impl)] + +const trait Tr { + async fn ft1() {} +//~^ ERROR async functions are not allowed in `const` traits +} + +const trait Tr2 { + fn f() -> impl std::future::Future<Output = ()>; +} + +impl const Tr2 for () { + async fn f() {} +//~^ ERROR async functions are not allowed in `const` trait impls +} + +fn main() {} diff --git a/tests/ui/traits/const-traits/const-trait-async-assoc-fn.stderr b/tests/ui/traits/const-traits/const-trait-async-assoc-fn.stderr new file mode 100644 index 00000000000..09ba0969dc9 --- /dev/null +++ b/tests/ui/traits/const-traits/const-trait-async-assoc-fn.stderr @@ -0,0 +1,18 @@ +error: async functions are not allowed in `const` traits + --> $DIR/const-trait-async-assoc-fn.rs:5:5 + | +LL | const trait Tr { + | ----- associated functions of `const` cannot be declared `async` +LL | async fn ft1() {} + | ^^^^^ + +error: async functions are not allowed in `const` trait impls + --> $DIR/const-trait-async-assoc-fn.rs:14:5 + | +LL | impl const Tr2 for () { + | ----- associated functions of `const` cannot be declared `async` +LL | async fn f() {} + | ^^^^^ + +error: aborting due to 2 previous errors + |
