Skip to content

Incorrect elided lifetime shown #18094

Open
@theemathas

Description

@theemathas

rust-analyzer version: 0.3.2104-standalone (08c7bbc 2024-09-06)

rustc version: rustc 1.81.0 (eeb90cda1 2024-09-04)

editor or extension: VsCode, with rust-analyzer extension version v0.3.2104

relevant settings:

{
    "rust-analyzer.inlayHints.genericParameterHints.lifetime.enable": true,
    "rust-analyzer.inlayHints.lifetimeElisionHints.enable": "always",
}

code snippet to reproduce:

pub struct FooRef<'a>(pub &'a i32);

pub struct Foo(i32);

impl Foo {
    pub fn foo_as_ref(&self) -> FooRef<'_> {
        FooRef(&self.0)
    }
}
image

The elided lifetime for self and for FooRef should be shown as the same lifetime in the inlay hint. However, they're shown as different lifetimes.

Discovered by tionway on the rust community discord.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions