Skip to content

Hide type inlay hints for enum variant constructors and tuple struct constructors with annoated generics #10446

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

Closed
Veykril opened this issue Oct 3, 2021 · 1 comment
Assignees
Labels
A-inlay-hints inlay/inline hints E-easy E-has-instructions Issue has some instructions and pointers to code to get started good first issue S-actionable Someone could pick this issue up and work on it right now

Comments

@Veykril
Copy link
Member

Veykril commented Oct 3, 2021

Improvement for #10441

struct Struct<T, U>(T, U);

enum Enum {
    Variant(u32)
}

fn main() {
    let foo = Struct::<u32, u32>(0, 0);
    let foo = Enum::Variant(0);
}

This will currently give type hints for the two let bindings but ideally we shouldn't need to show these here either.

This should be simple to fix, for the enum case we just need to special case a branch here https://github.com/rust-analyzer/rust-analyzer/blob/4b7675fcc30d3e2c05eafc68a5724db66b58142c/crates/ide/src/inlay_hints.rs#L268-L274
to instead check for the paths qualifier segment instead of the immediate, that is check the enum part instead of the variant.

For the tuple struct part we need to basically just do whats being down a few lines below that snippet for the immediate path segment instead of the qualifier.

@Veykril Veykril added good first issue E-easy E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now labels Oct 3, 2021
@deepto98
Copy link

deepto98 commented Oct 5, 2021

@Veykril I'd like to work on this issue, can you assign this to me?

emeryc added a commit to emeryc/rust-analyzer that referenced this issue Nov 25, 2021
The suggested method in the issue didn't work because that code path
appears not to be hit during the generation of these types. Instead I
introduced a new concept of unambigious types as part of let statements
and filtered out cases that the issue seemed to be pointing at.

There were two tests that seemed to depend on the old behavior that I
cleaned up in order to bring into alignment with the new behavior, this
@Veykril Veykril added the A-inlay-hints inlay/inline hints label Dec 17, 2021
@bors bors bot closed this as completed in abbc7e3 Jan 3, 2022
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 E-easy E-has-instructions Issue has some instructions and pointers to code to get started good first issue S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

2 participants