Better support for associated types in struct patterns
This commit is contained in:
parent
ba419a78f3
commit
4d4c7be19e
|
@ -76,7 +76,8 @@ pub fn pat_is_variant_or_struct(dm: &DefMap, pat: &hir::Pat) -> bool {
|
|||
PatKind::Path(..) |
|
||||
PatKind::Struct(..) => {
|
||||
match dm.get(&pat.id).map(|d| d.full_def()) {
|
||||
Some(Def::Variant(..)) | Some(Def::Struct(..)) | Some(Def::TyAlias(..)) => true,
|
||||
Some(Def::Variant(..)) | Some(Def::Struct(..)) |
|
||||
Some(Def::TyAlias(..)) | Some(Def::AssociatedTy(..)) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1715,7 +1715,7 @@ impl<'a, 'gcx, 'tcx, 'container> AdtDefData<'gcx, 'container> {
|
|||
pub fn variant_of_def(&self, def: Def) -> &VariantDefData<'gcx, 'container> {
|
||||
match def {
|
||||
Def::Variant(_, vid) => self.variant_with_id(vid),
|
||||
Def::Struct(..) | Def::TyAlias(..) => self.struct_variant(),
|
||||
Def::Struct(..) | Def::TyAlias(..) | Def::AssociatedTy(..) => self.struct_variant(),
|
||||
_ => bug!("unexpected def {:?} in variant_of_def", def)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -796,7 +796,7 @@ fn any_irrefutable_adt_pat(tcx: TyCtxt, m: &[Match], col: usize) -> bool {
|
|||
PatKind::Tuple(..) => true,
|
||||
PatKind::Struct(..) | PatKind::TupleStruct(..) | PatKind::Path(..) => {
|
||||
match tcx.expect_def(pat.id) {
|
||||
Def::Struct(..) | Def::TyAlias(..) => true,
|
||||
Def::Struct(..) | Def::TyAlias(..) | Def::AssociatedTy(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue