Closed
Description
When using the #![feature(async_fn_in_trait)]
flag, I stumbled upon a warning that I don't understand and assume to be a bug/missed implementation.
If this is the intended behavior, could anyone please explain why?
This is simplified code that generates the warning:
#![feature(async_fn_in_trait)]
trait Repository {
async fn new() -> Self;
}
struct MyRepository {}
impl Repository for MyRepository {
async fn new() -> Self {
todo!()
}
}
fn main() {
todo!()
}
warning: opaque type `impl Future<Output = Self>` does not satisfy its associated type bounds
--> src\main.rs:4:23
|
4 | async fn new() -> Self;
| ^^^^
|
::: C:\Users\arthu\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\future\future.rs:41:5
|
41 | type Output;
| ------------ this associated type bound is unsatisfied for `Self`
|
= note: `#[warn(opaque_hidden_inferred_bound)]` on by default
But when adding a type restriction on self (in this case Sized) the warning does not appear anymore.
#![feature(async_fn_in_trait)]
trait Repository
where
Self: Sized,
{
async fn new() -> Self;
}
struct MyRepository {}
impl Repository for MyRepository {
async fn new() -> Self {
todo!()
}
}
fn main() {
todo!()
}
Meta
rustc --version --verbose
:
rustc 1.72.0-nightly (cb80ff132 2023-07-07)
binary: rustc
commit-hash: cb80ff132a0e9aa71529b701427e4e6c243b58df
commit-date: 2023-07-07
host: x86_64-pc-windows-msvc
release: 1.72.0-nightly
LLVM version: 16.0.5
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done