@@ -636,6 +636,12 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
636
636
let report_bad_struct_kind = |is_warning| {
637
637
bad_struct_kind_err ( tcx. sess , pat. span , path, is_warning) ;
638
638
if is_warning {
639
+ // Boo! Too painful to attach this to the actual warning,
640
+ // it should go away at some point though.
641
+ tcx. sess . span_note_without_error (
642
+ pat. span ,
643
+ "this warning will become a HARD ERROR in a future release. \
644
+ See RFC 218 for details.") ;
639
645
return
640
646
}
641
647
@@ -676,10 +682,6 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
676
682
report_bad_struct_kind ( is_special_case) ;
677
683
if !is_special_case {
678
684
return
679
- } else {
680
- span_note ! ( tcx. sess, pat. span,
681
- "this warning will become a HARD ERROR in a future release. \
682
- See RFC 218 for details.") ;
683
685
}
684
686
}
685
687
( variant. fields
@@ -693,7 +695,10 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
693
695
ty:: TyStruct ( struct_def, expected_substs) => {
694
696
let variant = struct_def. struct_variant ( ) ;
695
697
if is_tuple_struct_pat && variant. kind ( ) != ty:: VariantKind :: Tuple {
696
- report_bad_struct_kind ( false ) ;
698
+ // Matching unit structs with tuple variant patterns (`UnitVariant(..)`)
699
+ // is allowed for backward compatibility.
700
+ let is_special_case = variant. kind ( ) == ty:: VariantKind :: Unit ;
701
+ report_bad_struct_kind ( is_special_case) ;
697
702
return ;
698
703
}
699
704
( variant. fields
0 commit comments