Fix detection of ref patterns for path patterns

I was wrong on #19127, I thought hir-def resolver is enough for them, but it turns out not because of paths like `<Enum>::Variant` and `Type::AssocThatIsEnum::Variant`.
This commit is contained in:
Chayim Refael Friedman 2025-02-17 11:51:29 +02:00
parent 09db657439
commit eb69d3734c
4 changed files with 64 additions and 17 deletions

View file

@ -1235,4 +1235,25 @@ fn f() {
"#,
);
}
#[test]
fn complex_enum_variant_non_ref_pat() {
check_diagnostics(
r#"
enum Enum { Variant }
trait Trait {
type Assoc;
}
impl Trait for () {
type Assoc = Enum;
}
fn foo(v: &Enum) {
let <Enum>::Variant = v;
let <() as Trait>::Assoc::Variant = v;
}
"#,
);
}
}