extend warning cycle to cover matching unit-structs via S(..)
(this makes them handled like enum unit-variants.)
This commit is contained in:
parent
25d1f4bc21
commit
d4039c5d40
1 changed files with 10 additions and 7 deletions
|
@ -659,6 +659,12 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
let report_bad_struct_kind = |is_warning| {
|
||||
bad_struct_kind_err(tcx.sess, pat.span, path, is_warning);
|
||||
if is_warning {
|
||||
// Boo! Too painful to attach this to the actual warning,
|
||||
// it should go away at some point though.
|
||||
tcx.sess.span_note_without_error(
|
||||
pat.span,
|
||||
"this warning will become a HARD ERROR in a future release. \
|
||||
See RFC 218 for details.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -699,12 +705,6 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
report_bad_struct_kind(is_special_case);
|
||||
if !is_special_case {
|
||||
return
|
||||
} else {
|
||||
// Boo! Too painful to attach this to the actual warning,
|
||||
// it should go away at some point though.
|
||||
tcx.sess.span_note_without_error(pat.span,
|
||||
"this warning will become a HARD ERROR in a future release. \
|
||||
See RFC 218 for details.");
|
||||
}
|
||||
}
|
||||
(variant.fields
|
||||
|
@ -718,7 +718,10 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
ty::TyStruct(struct_def, expected_substs) => {
|
||||
let variant = struct_def.struct_variant();
|
||||
if is_tuple_struct_pat && variant.kind() != ty::VariantKind::Tuple {
|
||||
report_bad_struct_kind(false);
|
||||
// Matching unit structs with tuple variant patterns (`UnitVariant(..)`)
|
||||
// is allowed for backward compatibility.
|
||||
let is_special_case = variant.kind() == ty::VariantKind::Unit;
|
||||
report_bad_struct_kind(is_special_case);
|
||||
return;
|
||||
}
|
||||
(variant.fields
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue