Rename etc -> has_rest_pat
This commit is contained in:
parent
3d83ff6aa3
commit
b06409ebcd
1 changed files with 8 additions and 8 deletions
|
@ -181,8 +181,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
self.check_pat_tuple_struct(pat, qpath, subpats, ddpos, expected, def_bm, ti)
|
self.check_pat_tuple_struct(pat, qpath, subpats, ddpos, expected, def_bm, ti)
|
||||||
}
|
}
|
||||||
PatKind::Path(_) => self.check_pat_path(pat, path_res.unwrap(), expected, ti),
|
PatKind::Path(_) => self.check_pat_path(pat, path_res.unwrap(), expected, ti),
|
||||||
PatKind::Struct(ref qpath, fields, etc) => {
|
PatKind::Struct(ref qpath, fields, has_rest_pat) => {
|
||||||
self.check_pat_struct(pat, qpath, fields, etc, expected, def_bm, ti)
|
self.check_pat_struct(pat, qpath, fields, has_rest_pat, expected, def_bm, ti)
|
||||||
}
|
}
|
||||||
PatKind::Or(pats) => {
|
PatKind::Or(pats) => {
|
||||||
let parent_pat = Some(pat);
|
let parent_pat = Some(pat);
|
||||||
|
@ -685,7 +685,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
pat: &'tcx Pat<'tcx>,
|
pat: &'tcx Pat<'tcx>,
|
||||||
qpath: &hir::QPath<'_>,
|
qpath: &hir::QPath<'_>,
|
||||||
fields: &'tcx [hir::PatField<'tcx>],
|
fields: &'tcx [hir::PatField<'tcx>],
|
||||||
etc: bool,
|
has_rest_pat: bool,
|
||||||
expected: Ty<'tcx>,
|
expected: Ty<'tcx>,
|
||||||
def_bm: BindingMode,
|
def_bm: BindingMode,
|
||||||
ti: TopInfo<'tcx>,
|
ti: TopInfo<'tcx>,
|
||||||
|
@ -707,7 +707,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
self.demand_eqtype_pat(pat.span, expected, pat_ty, ti);
|
self.demand_eqtype_pat(pat.span, expected, pat_ty, ti);
|
||||||
|
|
||||||
// Type-check subpatterns.
|
// Type-check subpatterns.
|
||||||
if self.check_struct_pat_fields(pat_ty, pat, variant, fields, etc, def_bm, ti) {
|
if self.check_struct_pat_fields(pat_ty, &pat, variant, fields, has_rest_pat, def_bm, ti) {
|
||||||
pat_ty
|
pat_ty
|
||||||
} else {
|
} else {
|
||||||
self.tcx.ty_error()
|
self.tcx.ty_error()
|
||||||
|
@ -1189,7 +1189,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
pat: &'tcx Pat<'tcx>,
|
pat: &'tcx Pat<'tcx>,
|
||||||
variant: &'tcx ty::VariantDef,
|
variant: &'tcx ty::VariantDef,
|
||||||
fields: &'tcx [hir::PatField<'tcx>],
|
fields: &'tcx [hir::PatField<'tcx>],
|
||||||
etc: bool,
|
has_rest_pat: bool,
|
||||||
def_bm: BindingMode,
|
def_bm: BindingMode,
|
||||||
ti: TopInfo<'tcx>,
|
ti: TopInfo<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
@ -1263,7 +1263,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
// Require `..` if struct has non_exhaustive attribute.
|
// Require `..` if struct has non_exhaustive attribute.
|
||||||
let non_exhaustive = variant.is_field_list_non_exhaustive() && !adt.did.is_local();
|
let non_exhaustive = variant.is_field_list_non_exhaustive() && !adt.did.is_local();
|
||||||
if non_exhaustive && !etc {
|
if non_exhaustive && !has_rest_pat {
|
||||||
self.error_foreign_non_exhaustive_spat(pat, adt.variant_descr(), fields.is_empty());
|
self.error_foreign_non_exhaustive_spat(pat, adt.variant_descr(), fields.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1275,7 +1275,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
.struct_span_err(pat.span, "union patterns should have exactly one field")
|
.struct_span_err(pat.span, "union patterns should have exactly one field")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
if etc {
|
if has_rest_pat {
|
||||||
tcx.sess.struct_span_err(pat.span, "`..` cannot be used in union patterns").emit();
|
tcx.sess.struct_span_err(pat.span, "`..` cannot be used in union patterns").emit();
|
||||||
}
|
}
|
||||||
} else if !unmentioned_fields.is_empty() {
|
} else if !unmentioned_fields.is_empty() {
|
||||||
|
@ -1287,7 +1287,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if !etc {
|
if !has_rest_pat {
|
||||||
if accessible_unmentioned_fields.is_empty() {
|
if accessible_unmentioned_fields.is_empty() {
|
||||||
unmentioned_err = Some(self.error_no_accessible_fields(pat, fields));
|
unmentioned_err = Some(self.error_no_accessible_fields(pat, fields));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue