@@ -888,7 +888,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
888
888
let comma = if args. len ( ) > 0 { ", " } else { "" } ;
889
889
let trait_path = self . tcx . def_path_str ( trait_def_id) ;
890
890
let method_name = self . tcx . item_name ( self . def_id ) ;
891
- err. span_suggestion (
891
+ err. span_suggestion_verbose (
892
892
expr. span ,
893
893
msg,
894
894
format ! ( "{trait_path}::{generics}::{method_name}({rcvr}{comma}{rest})" ) ,
@@ -939,18 +939,20 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
939
939
}
940
940
}
941
941
942
- let span_lo_redundant_lt_args = lt_arg_spans[ self . num_expected_lifetime_args ( ) ] ;
942
+ let span_lo_redundant_lt_args = if self . num_expected_lifetime_args ( ) == 0 {
943
+ lt_arg_spans[ 0 ]
944
+ } else {
945
+ lt_arg_spans[ self . num_expected_lifetime_args ( ) - 1 ]
946
+ } ;
943
947
let span_hi_redundant_lt_args = lt_arg_spans[ lt_arg_spans. len ( ) - 1 ] ;
944
948
945
- let span_redundant_lt_args = span_lo_redundant_lt_args. to ( span_hi_redundant_lt_args) ;
949
+ let span_redundant_lt_args =
950
+ span_lo_redundant_lt_args. shrink_to_hi ( ) . to ( span_hi_redundant_lt_args) ;
946
951
debug ! ( "span_redundant_lt_args: {:?}" , span_redundant_lt_args) ;
947
952
948
953
let num_redundant_lt_args = lt_arg_spans. len ( ) - self . num_expected_lifetime_args ( ) ;
949
- let msg_lifetimes = format ! (
950
- "remove {these} lifetime argument{s}" ,
951
- these = pluralize!( "this" , num_redundant_lt_args) ,
952
- s = pluralize!( num_redundant_lt_args) ,
953
- ) ;
954
+ let msg_lifetimes =
955
+ format ! ( "remove the lifetime argument{s}" , s = pluralize!( num_redundant_lt_args) ) ;
954
956
955
957
err. span_suggestion (
956
958
span_redundant_lt_args,
@@ -979,18 +981,22 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
979
981
}
980
982
981
983
let span_lo_redundant_type_or_const_args =
982
- gen_arg_spans[ self . num_expected_type_or_const_args ( ) ] ;
984
+ if self . num_expected_type_or_const_args ( ) == 0 {
985
+ gen_arg_spans[ 0 ]
986
+ } else {
987
+ gen_arg_spans[ self . num_expected_type_or_const_args ( ) - 1 ]
988
+ } ;
983
989
let span_hi_redundant_type_or_const_args = gen_arg_spans[ gen_arg_spans. len ( ) - 1 ] ;
990
+ let span_redundant_type_or_const_args = span_lo_redundant_type_or_const_args
991
+ . shrink_to_hi ( )
992
+ . to ( span_hi_redundant_type_or_const_args) ;
984
993
985
- let span_redundant_type_or_const_args =
986
- span_lo_redundant_type_or_const_args. to ( span_hi_redundant_type_or_const_args) ;
987
994
debug ! ( "span_redundant_type_or_const_args: {:?}" , span_redundant_type_or_const_args) ;
988
995
989
996
let num_redundant_gen_args =
990
997
gen_arg_spans. len ( ) - self . num_expected_type_or_const_args ( ) ;
991
998
let msg_types_or_consts = format ! (
992
- "remove {these} generic argument{s}" ,
993
- these = pluralize!( "this" , num_redundant_gen_args) ,
999
+ "remove the unnecessary generic argument{s}" ,
994
1000
s = pluralize!( num_redundant_gen_args) ,
995
1001
) ;
996
1002
@@ -1036,7 +1042,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
1036
1042
. with_lo ( self . path_segment . ident . span . hi ( ) ) ;
1037
1043
1038
1044
let msg = format ! (
1039
- "remove these {}generics" ,
1045
+ "remove the unnecessary {}generics" ,
1040
1046
if self . gen_args. parenthesized == hir:: GenericArgsParentheses :: ParenSugar {
1041
1047
"parenthetical "
1042
1048
} else {
0 commit comments