@@ -935,6 +935,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
935935 . filter ( |( a, b) | a == b)
936936 . count ( ) ;
937937 let len = sub1. len ( ) - common_default_params;
938+ let consts_offset = len - sub1. consts ( ) . count ( ) ;
938939
939940 // Only draw `<...>` if there're lifetime/type arguments.
940941 if len > 0 {
@@ -981,7 +982,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
981982 // ^ elided type as this type argument was the same in both sides
982983 let type_arguments = sub1. types ( ) . zip ( sub2. types ( ) ) ;
983984 let regions_len = sub1. regions ( ) . count ( ) ;
984- for ( i, ( ta1, ta2) ) in type_arguments. take ( len) . enumerate ( ) {
985+ let num_display_types = consts_offset - regions_len;
986+ for ( i, ( ta1, ta2) ) in type_arguments. take ( num_display_types) . enumerate ( ) {
985987 let i = i + regions_len;
986988 if ta1 == ta2 {
987989 values. 0 . push_normal ( "_" ) ;
@@ -994,6 +996,21 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
994996 self . push_comma ( & mut values. 0 , & mut values. 1 , len, i) ;
995997 }
996998
999+ // Do the same for const arguments, if they are equal, do not highlight and
1000+ // elide them from the output.
1001+ let const_arguments = sub1. consts ( ) . zip ( sub2. consts ( ) ) ;
1002+ for ( i, ( ca1, ca2) ) in const_arguments. enumerate ( ) {
1003+ let i = i + consts_offset;
1004+ if ca1 == ca2 {
1005+ values. 0 . push_normal ( "_" ) ;
1006+ values. 1 . push_normal ( "_" ) ;
1007+ } else {
1008+ values. 0 . push_highlighted ( ca1. to_string ( ) ) ;
1009+ values. 1 . push_highlighted ( ca2. to_string ( ) ) ;
1010+ }
1011+ self . push_comma ( & mut values. 0 , & mut values. 1 , len, i) ;
1012+ }
1013+
9971014 // Close the type argument bracket.
9981015 // Only draw `<...>` if there're lifetime/type arguments.
9991016 if len > 0 {
0 commit comments