Skip to content

unlike closure parent args, we check member constraints for unused early-bound FnDef lifetimes #155087

@lcnr

Description

@lcnr

FnDef lifetime arguments are ignored by outlives constraints. They are not ignored by member constraints. This is inconsistent.

fn cool<'a: 'a>() {}

fn closure_outlives<'a>() -> impl Sized + use<'a> + 'static {
    || ()
}
fn fn_def_outlives<'a>() -> impl Sized + use<'a> + 'static {
    cool::<'a>
}

fn closure_member_constraints<'a>() -> impl Sized + use<> {
    || ()
}
fn fn_def_member_constraints<'a>() -> impl Sized + use<> {
    cool::<'a> //~ ERROR hidden type for `impl Sized` captures lifetime that does not appear in bounds
}

We shouldn't try to make this consistent before resolving #153140 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsT-typesRelevant to the types team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    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