Skip to content

Do not show type inlay on constant slice pattern match #14124

New issue

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

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

Already on GitHub? # to your account

Closed
HurricanKai opened this issue Feb 11, 2023 · 1 comment · Fixed by #14125
Closed

Do not show type inlay on constant slice pattern match #14124

HurricanKai opened this issue Feb 11, 2023 · 1 comment · Fixed by #14125
Labels
A-inlay-hints inlay/inline hints C-bug Category: bug

Comments

@HurricanKai
Copy link

HurricanKai commented Feb 11, 2023

When writing code similar to:

const A: u8 = 5u8;

fn main() {
    let b = &mut [5u8];
    
    match b {
        [A] => (),
        [_b] => panic!("??")
    };
}

(playground)
A type inlay is shown on [A: <here>] exactly like when matching a variable. They slightly differ in type (above [A: u8] and [_b: &mut u8] but is still confusing in my opinion.
Personally, I checked whether using a constant variable instead of a constant literal was allowed in this context because of this inlay.
I also don't think the inlay is particularly useful and omitting it would resolve the confusion and not loose any relevant information.

(my apologies if the terminology isn't correct, I hope it's understandable)

@HurricanKai HurricanKai added the C-feature Category: feature request label Feb 11, 2023
@Veykril Veykril added C-bug Category: bug A-inlay-hints inlay/inline hints and removed C-feature Category: feature request labels Feb 11, 2023
@Veykril
Copy link
Member

Veykril commented Feb 11, 2023

Oh, A getting a type hint in that pattern is definitely a bug since it's a constant and not a new binding.

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

Successfully merging a pull request may close this issue.

2 participants