@@ -548,13 +548,16 @@ impl<'s> Parser<'s> {
548
548
}
549
549
550
550
let ty_tag = self . next ( ) ?;
551
+
552
+ if ty_tag == b'p' {
553
+ // We don't encode the type if the value is a placeholder.
554
+ return Ok ( ( ) ) ;
555
+ }
556
+
551
557
if !supported_const_generic_type ( ty_tag) {
552
558
return Err ( Invalid ) ;
553
559
}
554
560
555
- if self . eat ( b'p' ) {
556
- return Ok ( ( ) ) ;
557
- }
558
561
// Negation on signed integers.
559
562
if let b'a' | b's' | b'l' | b'x' | b'n' | b'i' = ty_tag {
560
563
let _ = self . eat ( b'n' ) ;
@@ -953,27 +956,30 @@ impl<'a, 'b, 's> Printer<'a, 'b, 's> {
953
956
}
954
957
955
958
let ty_tag = parse ! ( self , next) ;
959
+
960
+ if ty_tag == b'p' {
961
+ // We don't encode the type if the value is a placeholder.
962
+ self . out . write_str ( "_" ) ?;
963
+ return Ok ( ( ) ) ;
964
+ }
965
+
956
966
if !supported_const_generic_type ( ty_tag) {
957
967
invalid ! ( self ) ;
958
968
}
959
969
960
- if self . eat ( b'p' ) {
961
- self . out . write_str ( "_" ) ?;
962
- } else {
963
- match ty_tag {
964
- // Unsigned integer types.
965
- b'h' | b't' | b'm' | b'y' | b'o' | b'j' => self . print_const_uint ( ) ?,
966
- // Signed integer types.
967
- b'a' | b's' | b'l' | b'x' | b'n' | b'i' => self . print_const_int ( ) ?,
968
- // Bool.
969
- b'b' => self . print_const_bool ( ) ?,
970
- // Char.
971
- b'c' => self . print_const_char ( ) ?,
972
-
973
- // This branch ought to be unreachable.
974
- _ => invalid ! ( self ) ,
975
- } ;
976
- }
970
+ match ty_tag {
971
+ // Unsigned integer types.
972
+ b'h' | b't' | b'm' | b'y' | b'o' | b'j' => self . print_const_uint ( ) ?,
973
+ // Signed integer types.
974
+ b'a' | b's' | b'l' | b'x' | b'n' | b'i' => self . print_const_int ( ) ?,
975
+ // Bool.
976
+ b'b' => self . print_const_bool ( ) ?,
977
+ // Char.
978
+ b'c' => self . print_const_char ( ) ?,
979
+
980
+ // This branch ought to be unreachable.
981
+ _ => invalid ! ( self ) ,
982
+ } ;
977
983
978
984
if !self . out . alternate ( ) {
979
985
self . out . write_str ( ": " ) ?;
@@ -1118,6 +1124,10 @@ mod tests {
1118
1124
"_RMCs4fqI2P2rA04_13const_genericINtB0_4CharKc2202_E" ,
1119
1125
"<const_generic::Char<'∂'>>"
1120
1126
) ;
1127
+ t_nohash ! (
1128
+ "_RNvNvMCs4fqI2P2rA04_13const_genericINtB4_3FooKpE3foo3FOO" ,
1129
+ "<const_generic::Foo<_>>::foo::FOO"
1130
+ ) ;
1121
1131
}
1122
1132
1123
1133
#[ test]
0 commit comments