@@ -935,6 +935,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
935
935
. filter ( |( a, b) | a == b)
936
936
. count ( ) ;
937
937
let len = sub1. len ( ) - common_default_params;
938
+ let consts_offset = len - sub1. consts ( ) . count ( ) ;
938
939
939
940
// Only draw `<...>` if there're lifetime/type arguments.
940
941
if len > 0 {
@@ -981,7 +982,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
981
982
// ^ elided type as this type argument was the same in both sides
982
983
let type_arguments = sub1. types ( ) . zip ( sub2. types ( ) ) ;
983
984
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 ( ) {
985
987
let i = i + regions_len;
986
988
if ta1 == ta2 {
987
989
values. 0 . push_normal ( "_" ) ;
@@ -994,6 +996,21 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
994
996
self . push_comma ( & mut values. 0 , & mut values. 1 , len, i) ;
995
997
}
996
998
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
+
997
1014
// Close the type argument bracket.
998
1015
// Only draw `<...>` if there're lifetime/type arguments.
999
1016
if len > 0 {
0 commit comments