Skip to content

Commit 5ba643c

Browse files
committed
Test dyn Trait containing async fn
1 parent 247c8e7 commit 5ba643c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

tests/ui/no-attribute-macro.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ impl Trait for Struct {
88
async fn method(&self) {}
99
}
1010

11-
fn main() {}
11+
fn main() {
12+
let _: &dyn Trait;
13+
}

tests/ui/no-attribute-macro.stderr

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,18 @@ error[E0706]: functions in traits cannot be declared `async`
2323
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
2424
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
2525
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
26+
27+
error[E0038]: the trait `Trait` cannot be made into an object
28+
--> tests/ui/no-attribute-macro.rs:12:12
29+
|
30+
12 | let _: &dyn Trait;
31+
| ^^^^^^^^^^ `Trait` cannot be made into an object
32+
|
33+
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>
34+
--> tests/ui/no-attribute-macro.rs:2:14
35+
|
36+
1 | pub trait Trait {
37+
| ----- this trait cannot be made into an object...
38+
2 | async fn method(&self);
39+
| ^^^^^^ ...because method `method` is `async`
40+
= help: consider moving `method` to another trait

0 commit comments

Comments
 (0)