gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Wrong lowering of `AST::IdentifierPattern`

Open tamaroning opened this issue 6 months ago • 1 comments

Summary

AST::IdentifierPattern should lower to HIR::PathPattern only when identifiers resolve to enum variants or structs. However, they always lower to HIR::IdentifierPattern which introduces a new binding.

See https://doc.rust-lang.org/reference/patterns.html

Reproducer

I tried this code:

enum E {
    A,
    B,
}

use E::*;

fn main() -> i32 {
    match E::B {
        A => 1,
        B => 2,
    } 
}

Does the code make use of any (1.49) nightly feature ?

  • [ ] Nightly

Godbolt link

No response

Actual behavior

The current behavior is...

$ echo $?
1

Expected behavior

I expected to see...

$ echo $?
2

GCC Version

master

tamaroning avatar Aug 04 '24 15:08 tamaroning