diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2016-01-07 00:45:13 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2016-01-07 21:56:04 +0100 |
| commit | d4039c5d402033e28744b91b95ea1c560fa4ab0b (patch) | |
| tree | 56cef2ac7231cca4c146faac99351d615f161af2 | |
| parent | 25d1f4bc21a2ab77e12ebcd8c5fb479b563d3bf7 (diff) | |
| download | rust-d4039c5d402033e28744b91b95ea1c560fa4ab0b.tar.gz rust-d4039c5d402033e28744b91b95ea1c560fa4ab0b.zip | |
extend warning cycle to cover matching unit-structs via `S(..)`
(this makes them handled like enum unit-variants.)
| -rw-r--r-- | src/librustc_typeck/check/_match.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 926d7fd6e25..2e69ff100bf 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -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 |
