From 247c8e7b0b3ff69c9518ebf93e69fe74d47f17b6 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 22 Sep 2023 19:13:39 -0700 Subject: [PATCH] Add ui test testing the recommendation to use async-trait --- tests/ui/no-attribute-macro.rs | 11 +++++++++++ tests/ui/no-attribute-macro.stderr | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/ui/no-attribute-macro.rs create mode 100644 tests/ui/no-attribute-macro.stderr diff --git a/tests/ui/no-attribute-macro.rs b/tests/ui/no-attribute-macro.rs new file mode 100644 index 0000000..965a485 --- /dev/null +++ b/tests/ui/no-attribute-macro.rs @@ -0,0 +1,11 @@ +pub trait Trait { + async fn method(&self); +} + +pub struct Struct; + +impl Trait for Struct { + async fn method(&self) {} +} + +fn main() {} diff --git a/tests/ui/no-attribute-macro.stderr b/tests/ui/no-attribute-macro.stderr new file mode 100644 index 0000000..3085e6d --- /dev/null +++ b/tests/ui/no-attribute-macro.stderr @@ -0,0 +1,25 @@ +error[E0706]: functions in traits cannot be declared `async` + --> tests/ui/no-attribute-macro.rs:2:5 + | +2 | async fn method(&self); + | -----^^^^^^^^^^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error[E0706]: functions in traits cannot be declared `async` + --> tests/ui/no-attribute-macro.rs:8:5 + | +8 | async fn method(&self) {} + | -----^^^^^^^^^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable