@@ -1739,24 +1739,7 @@ fn split_grouped_constructors<'p, 'tcx>(
1739
1739
let mut borders: Vec < _ > = row_borders. chain ( ctor_borders) . collect ( ) ;
1740
1740
borders. sort_unstable ( ) ;
1741
1741
1742
- if let ( true , Some ( hir_id) ) = ( !overlaps. is_empty ( ) , hir_id) {
1743
- let mut err = tcx. struct_span_lint_hir (
1744
- lint:: builtin:: OVERLAPPING_PATTERNS ,
1745
- hir_id,
1746
- ctor_range. span ,
1747
- "multiple patterns covering the same range" ,
1748
- ) ;
1749
- err. span_label ( ctor_range. span , "overlapping patterns" ) ;
1750
- for int_range in overlaps {
1751
- // Use the real type for user display of the ranges:
1752
- err. span_label ( int_range. span , & format ! (
1753
- "this range overlaps on `{}`" ,
1754
- IntRange :: range_to_ctor( tcx, ty, int_range. range, DUMMY_SP )
1755
- . display( tcx) ,
1756
- ) ) ;
1757
- }
1758
- err. emit ( ) ;
1759
- }
1742
+ lint_unreachable_patterns ( tcx, hir_id, ctor_range, ty, overlaps) ;
1760
1743
1761
1744
// We're going to iterate through every pair of borders, making sure that each
1762
1745
// represents an interval of nonnegative length, and convert each such interval
@@ -1787,6 +1770,32 @@ fn split_grouped_constructors<'p, 'tcx>(
1787
1770
split_ctors
1788
1771
}
1789
1772
1773
+ fn lint_unreachable_patterns (
1774
+ tcx : TyCtxt < ' tcx > ,
1775
+ hir_id : Option < HirId > ,
1776
+ ctor_range : IntRange < ' tcx > ,
1777
+ ty : Ty < ' tcx > ,
1778
+ overlaps : Vec < IntRange < ' tcx > > ,
1779
+ ) {
1780
+ if let ( true , Some ( hir_id) ) = ( !overlaps. is_empty ( ) , hir_id) {
1781
+ let mut err = tcx. struct_span_lint_hir (
1782
+ lint:: builtin:: OVERLAPPING_PATTERNS ,
1783
+ hir_id,
1784
+ ctor_range. span ,
1785
+ "multiple patterns covering the same range" ,
1786
+ ) ;
1787
+ err. span_label ( ctor_range. span , "overlapping patterns" ) ;
1788
+ for int_range in overlaps {
1789
+ // Use the real type for user display of the ranges:
1790
+ err. span_label ( int_range. span , & format ! (
1791
+ "this range overlaps on `{}`" ,
1792
+ IntRange :: range_to_ctor( tcx, ty, int_range. range, DUMMY_SP ) . display( tcx) ,
1793
+ ) ) ;
1794
+ }
1795
+ err. emit ( ) ;
1796
+ }
1797
+ }
1798
+
1790
1799
fn constructor_covered_by_range < ' tcx > (
1791
1800
tcx : TyCtxt < ' tcx > ,
1792
1801
param_env : ty:: ParamEnv < ' tcx > ,
0 commit comments