@@ -1018,6 +1018,11 @@ impl<'a, 'b, 's> Printer<'a, 'b, 's> {
1018
1018
b'B' => {
1019
1019
self . print_backref ( Self :: print_type) ?;
1020
1020
}
1021
+ b'W' => {
1022
+ self . print_type ( ) ?;
1023
+ self . print ( " is " ) ?;
1024
+ self . print_pat ( ) ?;
1025
+ }
1021
1026
_ => {
1022
1027
// Go back to the tag, so `print_path` also sees it.
1023
1028
let _ = self . parser . as_mut ( ) . map ( |p| p. next -= 1 ) ;
@@ -1079,6 +1084,36 @@ impl<'a, 'b, 's> Printer<'a, 'b, 's> {
1079
1084
Ok ( ( ) )
1080
1085
}
1081
1086
1087
+ fn print_pat ( & mut self ) -> fmt:: Result {
1088
+ let tag = parse ! ( self , next) ;
1089
+
1090
+ match tag {
1091
+ b'R' => {
1092
+ self . print_const ( false ) ?;
1093
+ self . print ( "..=" ) ?;
1094
+ self . print_const ( false ) ?;
1095
+ }
1096
+ b'O' => {
1097
+ parse ! ( self , push_depth) ;
1098
+ self . print_pat ( ) ?;
1099
+ while !self . eat ( b'E' ) {
1100
+ // May have reached the end of the string,
1101
+ // avoid going into an endless loop.
1102
+ if self . parser . is_err ( ) {
1103
+ invalid ! ( self )
1104
+ }
1105
+ self . print ( " | " ) ?;
1106
+ self . print_pat ( ) ?;
1107
+ }
1108
+ self . pop_depth ( ) ;
1109
+ }
1110
+ b'N' => self . print ( "!null" ) ?,
1111
+ _ => invalid ! ( self ) ,
1112
+ }
1113
+
1114
+ Ok ( ( ) )
1115
+ }
1116
+
1082
1117
fn print_const ( & mut self , in_value : bool ) -> fmt:: Result {
1083
1118
let tag = parse ! ( self , next) ;
1084
1119
@@ -1315,6 +1350,13 @@ mod tests {
1315
1350
) ;
1316
1351
}
1317
1352
1353
+ #[ test]
1354
+ fn demangle_pat_ty ( ) {
1355
+ t_nohash_type ! ( "WmRm1_m9_" , "u32 is 1..=9" ) ;
1356
+ t_nohash_type ! ( "WmORm1_m2_Rm5_m6_E" , "u32 is 1..=2 | 5..=6" ) ;
1357
+ assert ! ( :: v0:: demangle( "_RMC0WmORm1_m2_Rm5_m6_" ) . is_err( ) ) ;
1358
+ }
1359
+
1318
1360
#[ test]
1319
1361
fn demangle_const_generics_preview ( ) {
1320
1362
// NOTE(eddyb) this was hand-written, before rustc had working
0 commit comments