Skip to content

Lifetime arguments of types are missing when hovering a value #17947

@kornelski

Description

@kornelski
let tmp = [0];
let _this_has_a_lifetime = tmp.iter();

When hovering _this_has_a_lifetime, RA shows:

let _this_has_a_lifetime: Iter<i32>

popup

But this is not the full type. Crucially, this isn't a self-contained type, and it is tied a temporary loan. Hiding lifetimes in this case is very unhelpful, because I have to go to the documentation to see if the type has any lifetime arguments.

I'd like this to be displayed as:

let _this_has_a_lifetime: Iter<'_, i32>

or showing the form used at the point of definition of the Iter.

Lack of lifetime information is especially problematic when working with an unfamiliar library, because the code needs to be structured differently if the types are borrowing (to avoid self-referential types etc.), and the types will need to be annotated with lifetime arguments sooner or later. Without RA's help, I only learn about the lifetimes later when getting borrow checker errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugE-easyE-has-instructionsIssue has some instructions and pointers to code to get started

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions