@@ -56,21 +56,6 @@ pub fn demangle(s: &str) -> Result<(Demangle, &str), Invalid> {
5656 Ok ( ( Demangle { inner } , & parser. sym [ parser. next ..] ) )
5757}
5858
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-
7459impl < ' s > Display for Demangle < ' s > {
7560 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7661 let mut printer = Printer {
@@ -554,14 +539,23 @@ impl<'s> Parser<'s> {
554539 return Ok ( ( ) ) ;
555540 }
556541
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' => { }
560549
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 ) ,
564557 }
558+
565559 self . hex_nibbles ( ) ?;
566560 Ok ( ( ) )
567561 }
@@ -963,10 +957,6 @@ impl<'a, 'b, 's> Printer<'a, 'b, 's> {
963957 return Ok ( ( ) ) ;
964958 }
965959
966- if !supported_const_generic_type ( ty_tag) {
967- invalid ! ( self ) ;
968- }
969-
970960 match ty_tag {
971961 // Unsigned integer types.
972962 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> {
10351025 v = ( v << 4 ) | ( c. to_digit ( 16 ) . unwrap ( ) as u32 ) ;
10361026 }
10371027 if let Some ( c) = char:: from_u32 ( v) {
1038- write ! ( self . out, "'{}' " , c)
1028+ write ! ( self . out, "{:?} " , c)
10391029 } else {
10401030 invalid ! ( self )
10411031 }
@@ -1120,6 +1110,10 @@ mod tests {
11201110 "_RMCs4fqI2P2rA04_13const_genericINtB0_4CharKc76_E" ,
11211111 "<const_generic::Char<'v'>>"
11221112 ) ;
1113+ t_nohash ! (
1114+ "_RMCs4fqI2P2rA04_13const_genericINtB0_4CharKca_E" ,
1115+ "<const_generic::Char<'\\ n'>>"
1116+ ) ;
11231117 t_nohash ! (
11241118 "_RMCs4fqI2P2rA04_13const_genericINtB0_4CharKc2202_E" ,
11251119 "<const_generic::Char<'∂'>>"
0 commit comments