@@ -1009,6 +1009,11 @@ mod tests {
1009
1009
assert_eq!( format!( "{:#}" , :: demangle( $a) ) , $b) ;
1010
1010
} )
1011
1011
}
1012
+ macro_rules! t_nohash_type {
1013
+ ( $a: expr, $b: expr) => (
1014
+ t_nohash!( concat!( "_RMC0" , $a) , concat!( "<" , $b, ">" ) )
1015
+ )
1016
+ }
1012
1017
1013
1018
#[ test]
1014
1019
fn demangle_utf8_idents ( ) {
@@ -1042,9 +1047,25 @@ mod tests {
1042
1047
fn demangle_const_generics ( ) {
1043
1048
// NOTE(eddyb) this was hand-written, before rustc had working
1044
1049
// const generics support (but the mangling format did include them).
1045
- t_nohash ! (
1046
- "_RNvINtC8arrayvec8ArrayVechKj7b_E3new" ,
1047
- "arrayvec::ArrayVec::<u8, 123>::new"
1050
+ t_nohash_type ! (
1051
+ "INtC8arrayvec8ArrayVechKj7b_E" ,
1052
+ "arrayvec::ArrayVec<u8, 123>"
1053
+ ) ;
1054
+ }
1055
+
1056
+ #[ test]
1057
+ fn demangle_exponential_explosion ( ) {
1058
+ // NOTE(eddyb) because of the prefix added by `t_nohash_type!` is
1059
+ // 3 bytes long, `B2_` refers to the start of the type, not `B_`.
1060
+ // 6 backrefs (`B8_E` through `B3_E`) result in 2^6 = 64 copies of `_`.
1061
+ // Also, because the `p` (`_`) type is after all of the starts of the
1062
+ // backrefs, it can be replaced with any other type, independently.
1063
+ t_nohash_type ! (
1064
+ concat!( "TTTTTT" , "p" , "B8_E" , "B7_E" , "B6_E" , "B5_E" , "B4_E" , "B3_E" ) ,
1065
+ "((((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _)))), \
1066
+ ((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _))))), \
1067
+ (((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _)))), \
1068
+ ((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _))))))"
1048
1069
) ;
1049
1070
}
1050
1071
}
0 commit comments