Rust-GCC / gccrs

GCC Front-End for Rust
https://rust-gcc.github.io/
GNU General Public License v2.0
2.4k stars 155 forks source link

Wrong lowering of `AST::IdentifierPattern` #3117

Open tamaroning opened 2 months ago

tamaroning commented 2 months ago

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 ?

Godbolt link

No response

Actual behavior

The current behavior is...

$ echo $?
1

Expected behavior

I expected to see...

$ echo $?
2

GCC Version

master

tamaroning commented 1 month ago

Glob imports do not seem to work correctly for enum variants.