From ae7fa1d269a3346372562570da3c51625027097b Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 16 Mar 2023 20:41:24 -0300 Subject: [PATCH] Add generic parameters mismatch test for async in traits --- .../ui/async-await/in-trait/generics-mismatch.rs | 15 +++++++++++++++ .../in-trait/generics-mismatch.stderr | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/ui/async-await/in-trait/generics-mismatch.rs create mode 100644 tests/ui/async-await/in-trait/generics-mismatch.stderr diff --git a/tests/ui/async-await/in-trait/generics-mismatch.rs b/tests/ui/async-await/in-trait/generics-mismatch.rs new file mode 100644 index 00000000000..fc29783c0e3 --- /dev/null +++ b/tests/ui/async-await/in-trait/generics-mismatch.rs @@ -0,0 +1,15 @@ +// edition: 2021 + +#![feature(async_fn_in_trait)] +#![allow(incomplete_features)] + +trait Foo { + async fn foo(); +} + +impl Foo for () { + async fn foo() {} + //~^ ERROR: method `foo` has an incompatible generic parameter for trait `Foo` [E0053] +} + +fn main() {} diff --git a/tests/ui/async-await/in-trait/generics-mismatch.stderr b/tests/ui/async-await/in-trait/generics-mismatch.stderr new file mode 100644 index 00000000000..3518aa05cec --- /dev/null +++ b/tests/ui/async-await/in-trait/generics-mismatch.stderr @@ -0,0 +1,16 @@ +error[E0053]: method `foo` has an incompatible generic parameter for trait `Foo` + --> $DIR/generics-mismatch.rs:11:18 + | +LL | trait Foo { + | --- +LL | async fn foo(); + | - expected type parameter +... +LL | impl Foo for () { + | --------------- +LL | async fn foo() {} + | ^^^^^^^^^^^^^^ found const parameter of type `usize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`.