@@ -659,6 +659,12 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
659
659
let report_bad_struct_kind = |is_warning| {
660
660
bad_struct_kind_err ( tcx. sess , pat. span , path, is_warning) ;
661
661
if is_warning {
662
+ // Boo! Too painful to attach this to the actual warning,
663
+ // it should go away at some point though.
664
+ tcx. sess . span_note_without_error (
665
+ pat. span ,
666
+ "this warning will become a HARD ERROR in a future release. \
667
+ See RFC 218 for details.") ;
662
668
return ;
663
669
}
664
670
@@ -699,12 +705,6 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
699
705
report_bad_struct_kind ( is_special_case) ;
700
706
if !is_special_case {
701
707
return
702
- } else {
703
- // Boo! Too painful to attach this to the actual warning,
704
- // it should go away at some point though.
705
- tcx. sess . span_note_without_error ( pat. span ,
706
- "this warning will become a HARD ERROR in a future release. \
707
- See RFC 218 for details.") ;
708
708
}
709
709
}
710
710
( variant. fields
@@ -718,7 +718,10 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
718
718
ty:: TyStruct ( struct_def, expected_substs) => {
719
719
let variant = struct_def. struct_variant ( ) ;
720
720
if is_tuple_struct_pat && variant. kind ( ) != ty:: VariantKind :: Tuple {
721
- report_bad_struct_kind ( false ) ;
721
+ // Matching unit structs with tuple variant patterns (`UnitVariant(..)`)
722
+ // is allowed for backward compatibility.
723
+ let is_special_case = variant. kind ( ) == ty:: VariantKind :: Unit ;
724
+ report_bad_struct_kind ( is_special_case) ;
722
725
return ;
723
726
}
724
727
( variant. fields
0 commit comments