Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect elided lifetime shown #18094

Open
theemathas opened this issue Sep 11, 2024 · 2 comments
Open

Incorrect elided lifetime shown #18094

theemathas opened this issue Sep 11, 2024 · 2 comments
Labels
A-inlay-hints inlay/inline hints A-lifetimes C-bug Category: bug

Comments

@theemathas
Copy link

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.

@theemathas theemathas added the C-bug Category: bug label Sep 11, 2024
@roife roife added A-inlay-hints inlay/inline hints A-lifetimes labels Sep 11, 2024
@Veykril
Copy link
Member

Veykril commented Sep 11, 2024

That hint in FooRef is not an elided lifetime hint, its a generic parameter hint, rendering the name of the generic parameter that the arg is supplied for. 1) We don't have elision hints for path type generic args yet, 2) we wouldn't render them either way when there is a lifetime specified (as is the case with '_ here)

@tionway
Copy link

tionway commented Sep 11, 2024

That hint in FooRef is not an elided lifetime hint, its a generic parameter hint, rendering the name of the generic parameter that the arg is supplied for. 1) We don't have elision hints for path type generic args yet, 2) we wouldn't render them either way when there is a lifetime specified (as is the case with '_ here)

is there a way to show the elided lifetime for path type generic like ordinary function with reference? Like the screenshot shows here

截屏2024-09-11 21 56 54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inlay-hints inlay/inline hints A-lifetimes C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

4 participants