Skip to content

Difference in trait object default bounds for early/late bound lifetimes #47078

Open
@matthewjasper

Description

@matthewjasper

It looks like early- and late-bound lifetimes behave differently in default object bounds:

trait A<'a>: 'a {}

pub fn foo<'a>(x: Box<A<'a>>) -> Box<A<'a> + 'static> // Infers 'static
{
    x
}
pub fn bar<'a>(x: Box<A<'a> + 'a>) -> Box<A<'a>> // Infers 'a
where 'a: 'a
{
    x
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dyn-traitArea: trait objects, vtable layoutA-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions