Skip to content

“expected bound lifetime parameter, found concrete lifetime” with 'static across await point #1199

Closed
@Ekleog

Description

@Ekleog

ISSUE MOVED TO rust-lang/rust#53548

(edit: simpler reproducer without channels at #1199 (comment))

On the currently-latest commit of futures-rs (c02ec75), with the currently-latest nightly (2018-08-14), the following code does not build:

#![feature(async_await, await_macro, futures_api)]

extern crate futures;

use futures::{channel::mpsc::{self, SendError}, prelude::*};
use std::any::Any;

async fn send(msg: Box<Any + Send + 'static>) -> Result<(), SendError> {
    let (mut sender, _) = mpsc::channel(1);
    await!(sender.send(msg))
}

It fails with the following error:

error[E0279]: the requirement `for<'r> 'r : 'static` is not satisfied (`expected bound lifetime parameter, found concrete lifetime`)
  --> erlust/src/lib.rs:8:72
   |
8  |   async fn send(msg: Box<Any + Send + 'static>) -> Result<(), SendError> {
   |  ________________________________________________________________________^
9  | |     let (mut sender, _) = mpsc::channel(1);
10 | |     await!(sender.send(msg))
11 | | }
   | |_^
   |
   = note: required so that the lifetime bound of `` for `dyn std::any::Any + std::marker::Send` is satisfied

error: aborting due to previous error

I can't figure out the reason why it fails, so I'm assuming it's something in futures-rs. But maybe it's actually a rustc bug from async/await? Or maybe it's just me missing something obvious, actually :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions