diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/async-await/in-trait/warn.rs | 11 | ||||
| -rw-r--r-- | tests/ui/async-await/in-trait/warn.stderr | 20 | 
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/async-await/in-trait/warn.rs b/tests/ui/async-await/in-trait/warn.rs new file mode 100644 index 00000000000..defbdcffccd --- /dev/null +++ b/tests/ui/async-await/in-trait/warn.rs @@ -0,0 +1,11 @@ +// edition: 2021 + +#![feature(async_fn_in_trait)] +#![deny(async_fn_in_trait)] + +trait Foo { + async fn not_send(); + //~^ ERROR +} + +fn main() {} diff --git a/tests/ui/async-await/in-trait/warn.stderr b/tests/ui/async-await/in-trait/warn.stderr new file mode 100644 index 00000000000..3680bd393b1 --- /dev/null +++ b/tests/ui/async-await/in-trait/warn.stderr @@ -0,0 +1,20 @@ +error: usage of `async fn` in trait is discouraged because they do not automatically have auto trait bounds + --> $DIR/warn.rs:7:5 + | +LL | async fn not_send(); + | ^^^^^ + | + = note: you can suppress this lint if you plan to use the trait locally, for concrete types, or do not care about auto traits like `Send` on the future +note: the lint level is defined here + --> $DIR/warn.rs:4:9 + | +LL | #![deny(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ +help: you can alternatively desugar the `async fn` and any add additional traits such as `Send` to the signature + | +LL - async fn not_send(); +LL + fn not_send() -> impl std::future::Future<Output = ()> + Send; + | + +error: aborting due to previous error +  | 
