Wrong lowering of `AST::IdentifierPattern`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 20h 2m
- Merged PRs (30d)
- 66
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the lowering of AST::IdentifierPattern into HIR patterns and trace how identifier resolution distinguishes enum variants and structs from new bindings. Use the Rust reproducer as a regression case; done means the unqualified A and B patterns match E::A and E::B and produce the expected result of 2.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100