Skip to content

Improve error message for one named, one anonymous lifetime parameters #43433

Open
@gaurikholkar-zz

Description

@gaurikholkar-zz

For the following example

fn foo<'a>(x: &'a i32, y: Vec<&i32>) {
                       - consider changing the type of `y` to `std::vec::Vec<&'a i32>`
    y.push(x);
           ^ this reference must have lifetime 'a
}

can be refined to


fn foo<'a>(x: &'a i32, y: Vec<&i32>) {
                              ---- consider changing this type to `&'a i32`
    y.push(x);
           ^ this reference must have lifetime 'a
}

Underline &i32 instead of the whole type.

cc @nikomatsakis

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler 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