@@ -1189,6 +1189,25 @@ impl<'p, Cx: TypeCx> Matrix<'p, Cx> {
11891189        } 
11901190        Ok ( matrix) 
11911191    } 
1192+ 
1193+     /// Recover row usefulness and intersection information from a processed specialized matrix. 
1194+ /// `specialized` must come from `self.specialize_constructor`. 
1195+ fn  unspecialize ( & mut  self ,  specialized :  Self )  { 
1196+         for  child_row in  specialized. rows ( )  { 
1197+             let  parent_row_id = child_row. parent_row ; 
1198+             let  parent_row = & mut  self . rows [ parent_row_id] ; 
1199+             // A parent row is useful if any of its children is. 
1200+             parent_row. useful  |= child_row. useful ; 
1201+             for  child_intersection in  child_row. intersects . iter ( )  { 
1202+                 // Convert the intersecting ids into ids for the parent matrix. 
1203+                 let  parent_intersection = specialized. rows [ child_intersection] . parent_row ; 
1204+                 // Note: self-intersection can happen with or-patterns. 
1205+                 if  parent_intersection != parent_row_id { 
1206+                     parent_row. intersects . insert ( parent_intersection) ; 
1207+                 } 
1208+             } 
1209+         } 
1210+     } 
11921211} 
11931212
11941213/// Pretty-printer for matrices of patterns, example: 
@@ -1558,21 +1577,6 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
15581577        // Accumulate the found witnesses. 
15591578        ret. extend ( witnesses) ; 
15601579
1561-         for  child_row in  spec_matrix. rows ( )  { 
1562-             let  parent_row_id = child_row. parent_row ; 
1563-             let  parent_row = & mut  matrix. rows [ parent_row_id] ; 
1564-             // A parent row is useful if any of its children is. 
1565-             parent_row. useful  |= child_row. useful ; 
1566-             for  child_intersection in  child_row. intersects . iter ( )  { 
1567-                 // Convert the intersecting ids into ids for the parent matrix. 
1568-                 let  parent_intersection = spec_matrix. rows [ child_intersection] . parent_row ; 
1569-                 // Note: self-intersection can happen with or-patterns. 
1570-                 if  parent_intersection != parent_row_id { 
1571-                     parent_row. intersects . insert ( parent_intersection) ; 
1572-                 } 
1573-             } 
1574-         } 
1575- 
15761580        // Detect ranges that overlap on their endpoints. 
15771581        if  let  Constructor :: IntRange ( overlap_range)  = ctor { 
15781582            if  overlap_range. is_singleton ( ) 
@@ -1582,6 +1586,8 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
15821586                collect_overlapping_range_endpoints ( mcx,  overlap_range,  matrix,  & spec_matrix) ; 
15831587            } 
15841588        } 
1589+ 
1590+         matrix. unspecialize ( spec_matrix) ; 
15851591    } 
15861592
15871593    // Record usefulness in the patterns. 
0 commit comments