From bbc536d3ac83ad0e3600af2d04701faed63ecd79 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 1 May 2023 05:15:45 +0000 Subject: Emit an error when RTN is used with ty/ct params --- .../return-type-notation/ty-or-ct-params.rs | 20 +++++++++++++++ .../return-type-notation/ty-or-ct-params.stderr | 29 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/ui/async-await/return-type-notation/ty-or-ct-params.rs create mode 100644 tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr (limited to 'tests') diff --git a/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs b/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs new file mode 100644 index 00000000000..7871a2fed03 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs @@ -0,0 +1,20 @@ +// edition: 2021 + +#![feature(async_fn_in_trait, return_type_notation)] +//~^ WARN the feature `return_type_notation` is incomplete + +trait Foo { + async fn bar() {} + + async fn baz() {} +} + +fn test() +where + T: Foo, + //~^ ERROR return type notation is not allowed for functions that have const parameters + //~| ERROR return type notation is not allowed for functions that have type parameters +{ +} + +fn main() {} diff --git a/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr b/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr new file mode 100644 index 00000000000..76928c5d7a3 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr @@ -0,0 +1,29 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/ty-or-ct-params.rs:3:31 + | +LL | #![feature(async_fn_in_trait, return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +error: return type notation is not allowed for functions that have type parameters + --> $DIR/ty-or-ct-params.rs:14:12 + | +LL | async fn bar() {} + | - type parameter declared here +... +LL | T: Foo, + | ^^^^^^^^^^^ + +error: return type notation is not allowed for functions that have const parameters + --> $DIR/ty-or-ct-params.rs:14:25 + | +LL | async fn baz() {} + | -------------- const parameter declared here +... +LL | T: Foo, + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors; 1 warning emitted + -- cgit 1.4.1-3-g733a5