Skip to content

Generic params from impl dont have 'async_trait lifetime #8

@kpp

Description

@kpp

I tried to produce a MRE:

#[async_trait]
pub trait MapInto<T>: Future {
    async fn map_into(self) -> T
        where Self: Sized;
}

#[async_trait]
impl<F, T> MapInto<T> for F
    where F: ?Sized,
          F: Future + Send,
          T: From<F::Output>,
{
    async fn map_into(self) -> T
        where Self: Sized,
    {
        self.await.into()
    }
}

error:

error[E0309]: the parameter type `T` may not live long enough
   --> src/future.rs:116:1
    |
116 | #[async_trait]
    | ^^^^^^^^^^^^^^
117 | impl<F, T> MapInto<T> for F
    |         - help: consider adding an explicit lifetime bound `T: 'async_trait`...
    |

A fix for me: T: 'static, in impl block. Is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions