Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/hir-ty/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,12 @@ impl<'a> InferenceContext<'a> {
path: &ModPath,
) -> (Ty, Option<VariantId>) {
let remaining = unresolved.map(|it| path.segments()[it..].len()).filter(|it| it > &0);
let ty = match ty.kind(Interner) {
TyKind::Alias(AliasTy::Projection(proj_ty)) => {
self.db.normalize_projection(proj_ty.clone(), self.table.trait_env.clone())
}
_ => ty,
};
match remaining {
None => {
let variant = ty.as_adt().and_then(|(adt_id, _)| match adt_id {
Expand Down
34 changes: 34 additions & 0 deletions crates/hir-ty/src/tests/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,40 @@ fn main() {
);
}

#[test]
fn generic_alias_with_qualified_path() {
check_types(
r#"
type Wrap<T> = T;

struct S;

trait Schematic {
type Props;
}

impl Schematic for S {
type Props = X;
}

enum X {
A { cool: u32, stuff: u32 },
B,
}

fn main() {
let wrapped = Wrap::<<S as Schematic>::Props>::A {
cool: 100,
stuff: 100,
};

if let Wrap::<<S as Schematic>::Props>::A { cool, ..} = &wrapped {}
//^^^^ &u32
}
"#,
);
}

#[test]
fn type_mismatch_pat_const_reference() {
check_no_mismatches(
Expand Down