Skip to content

With impl trait, some variables are not recognised as 'static when used with AsRef. #42451

@P-E-Meunier

Description

@P-E-Meunier

An example is the following code:

fn f() -> impl Future<Item = (), Error = Error> {
    my_future.and_then(move |_| {
        foo("blah")
    })
}
fn foo<T: AsRef<str>>(t: T) {
     unimplemented!()
}

The current nightly rustc complains about unnamed lifetimes in impl trait. It accepts the same code with "blah" replaced by "blah".to_owned().

I believe "blah" should be recognised of lifetime 'static, and this code should be accepted by the compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions