Skip to content

Commit

Permalink
Test dyn Trait containing async fn
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 23, 2023
1 parent 247c8e7 commit 5ba643c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/ui/no-attribute-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ impl Trait for Struct {
async fn method(&self) {}
}

fn main() {}
fn main() {
let _: &dyn Trait;
}
15 changes: 15 additions & 0 deletions tests/ui/no-attribute-macro.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@ error[E0706]: functions in traits cannot be declared `async`
= 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[E0038]: the trait `Trait` cannot be made into an object
--> tests/ui/no-attribute-macro.rs:12:12
|
12 | let _: &dyn Trait;
| ^^^^^^^^^^ `Trait` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> tests/ui/no-attribute-macro.rs:2:14
|
1 | pub trait Trait {
| ----- this trait cannot be made into an object...
2 | async fn method(&self);
| ^^^^^^ ...because method `method` is `async`
= help: consider moving `method` to another trait

0 comments on commit 5ba643c

Please sign in to comment.