From 5ba643c001a55f70c4a44690e040cdfab873ba56 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 22 Sep 2023 19:14:34 -0700 Subject: [PATCH] Test dyn Trait containing async fn --- tests/ui/no-attribute-macro.rs | 4 +++- tests/ui/no-attribute-macro.stderr | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/ui/no-attribute-macro.rs b/tests/ui/no-attribute-macro.rs index 965a485..c0fb431 100644 --- a/tests/ui/no-attribute-macro.rs +++ b/tests/ui/no-attribute-macro.rs @@ -8,4 +8,6 @@ impl Trait for Struct { async fn method(&self) {} } -fn main() {} +fn main() { + let _: &dyn Trait; +} diff --git a/tests/ui/no-attribute-macro.stderr b/tests/ui/no-attribute-macro.stderr index 3085e6d..c7f2502 100644 --- a/tests/ui/no-attribute-macro.stderr +++ b/tests/ui/no-attribute-macro.stderr @@ -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 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 + --> 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