@@ -56,21 +56,6 @@ pub fn demangle(s: &str) -> Result<(Demangle, &str), Invalid> {
56
56
Ok ( ( Demangle { inner } , & parser. sym [ parser. next ..] ) )
57
57
}
58
58
59
- fn supported_const_generic_type ( ty_tag : u8 ) -> bool {
60
- match ty_tag {
61
- // Unsigned integer types.
62
- b'h' | b't' | b'm' | b'y' | b'o' | b'j' |
63
- // Signed integer types.
64
- b'a' | b's' | b'l' | b'x' | b'n' | b'i' |
65
- // Bool.
66
- b'b' |
67
- // Char.
68
- b'c' => true ,
69
-
70
- _ => false ,
71
- }
72
- }
73
-
74
59
impl < ' s > Display for Demangle < ' s > {
75
60
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
76
61
let mut printer = Printer {
@@ -554,14 +539,23 @@ impl<'s> Parser<'s> {
554
539
return Ok ( ( ) ) ;
555
540
}
556
541
557
- if !supported_const_generic_type ( ty_tag) {
558
- return Err ( Invalid ) ;
559
- }
542
+ match ty_tag {
543
+ // Unsigned integer types.
544
+ b'h' | b't' | b'm' | b'y' | b'o' | b'j' |
545
+ // Bool.
546
+ b'b' |
547
+ // Char.
548
+ b'c' => { }
560
549
561
- // Negation on signed integers.
562
- if let b'a' | b's' | b'l' | b'x' | b'n' | b'i' = ty_tag {
563
- let _ = self . eat ( b'n' ) ;
550
+ // Signed integer types.
551
+ b'a' | b's' | b'l' | b'x' | b'n' | b'i' => {
552
+ // Negation on signed integers.
553
+ let _ = self . eat ( b'n' ) ;
554
+ }
555
+
556
+ _ => return Err ( Invalid ) ,
564
557
}
558
+
565
559
self . hex_nibbles ( ) ?;
566
560
Ok ( ( ) )
567
561
}
@@ -963,10 +957,6 @@ impl<'a, 'b, 's> Printer<'a, 'b, 's> {
963
957
return Ok ( ( ) ) ;
964
958
}
965
959
966
- if !supported_const_generic_type ( ty_tag) {
967
- invalid ! ( self ) ;
968
- }
969
-
970
960
match ty_tag {
971
961
// Unsigned integer types.
972
962
b'h' | b't' | b'm' | b'y' | b'o' | b'j' => self . print_const_uint ( ) ?,
@@ -1035,7 +1025,7 @@ impl<'a, 'b, 's> Printer<'a, 'b, 's> {
1035
1025
v = ( v << 4 ) | ( c. to_digit ( 16 ) . unwrap ( ) as u32 ) ;
1036
1026
}
1037
1027
if let Some ( c) = char:: from_u32 ( v) {
1038
- write ! ( self . out, "'{}' " , c)
1028
+ write ! ( self . out, "{:?} " , c)
1039
1029
} else {
1040
1030
invalid ! ( self )
1041
1031
}
@@ -1120,6 +1110,10 @@ mod tests {
1120
1110
"_RMCs4fqI2P2rA04_13const_genericINtB0_4CharKc76_E" ,
1121
1111
"<const_generic::Char<'v'>>"
1122
1112
) ;
1113
+ t_nohash ! (
1114
+ "_RMCs4fqI2P2rA04_13const_genericINtB0_4CharKca_E" ,
1115
+ "<const_generic::Char<'\\ n'>>"
1116
+ ) ;
1123
1117
t_nohash ! (
1124
1118
"_RMCs4fqI2P2rA04_13const_genericINtB0_4CharKc2202_E" ,
1125
1119
"<const_generic::Char<'∂'>>"
0 commit comments