Skip to content

Commit

Permalink
Add ui test testing the recommendation to use async-trait
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 23, 2023
1 parent 799db66 commit 247c8e7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/ui/no-attribute-macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pub trait Trait {
async fn method(&self);
}

pub struct Struct;

impl Trait for Struct {
async fn method(&self) {}
}

fn main() {}
25 changes: 25 additions & 0 deletions tests/ui/no-attribute-macro.stderr
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable

0 comments on commit 247c8e7

Please sign in to comment.