@@ -5,7 +5,7 @@ use common::diagnostics::{
55} ;
66use hir:: {
77 diagnostics:: DiagnosticVoucher ,
8- hir_def:: { IdentId , ImplTrait , Trait , TypeAlias as HirTypeAlias } ,
8+ hir_def:: { FuncParamName , IdentId , ImplTrait , Trait , TypeAlias as HirTypeAlias } ,
99 span:: { DynLazySpan , LazySpan } ,
1010 HirDb , SpannedHirDb ,
1111} ;
@@ -692,6 +692,12 @@ pub enum ImplDiag {
692692 given : usize ,
693693 } ,
694694
695+ MethodArgLabelMismatch {
696+ primary : DynLazySpan ,
697+ definition : DynLazySpan ,
698+ message : String ,
699+ } ,
700+
695701 MethodArgTyMismatch {
696702 primary : DynLazySpan ,
697703 message : String ,
@@ -782,6 +788,26 @@ impl ImplDiag {
782788 Self :: MethodArgTyMismatch { primary, message }
783789 }
784790
791+ pub fn method_arg_label_mismatch (
792+ db : & dyn HirAnalysisDb ,
793+ primary : DynLazySpan ,
794+ definition : DynLazySpan ,
795+ expected : FuncParamName ,
796+ given : FuncParamName ,
797+ ) -> Self {
798+ let message = format ! (
799+ "expected `{}` label, but the given label is `{}`" ,
800+ expected. pretty_print( db. as_hir_db( ) ) ,
801+ given. pretty_print( db. as_hir_db( ) )
802+ ) ;
803+
804+ Self :: MethodArgLabelMismatch {
805+ primary,
806+ definition,
807+ message,
808+ }
809+ }
810+
785811 pub fn method_ret_type_mismatch (
786812 db : & dyn HirAnalysisDb ,
787813 primary : DynLazySpan ,
@@ -855,10 +881,11 @@ impl ImplDiag {
855881 Self :: MethodTypeParamNumMismatch { .. } => 3 ,
856882 Self :: MethodTypeParamKindMismatch { .. } => 4 ,
857883 Self :: MethodArgNumMismatch { .. } => 5 ,
858- Self :: MethodArgTyMismatch { .. } => 6 ,
859- Self :: MethodRetTyMismatch { .. } => 7 ,
860- Self :: MethodStricterBound { .. } => 8 ,
861- Self :: InvalidSelfType { .. } => 9 ,
884+ Self :: MethodArgLabelMismatch { .. } => 6 ,
885+ Self :: MethodArgTyMismatch { .. } => 7 ,
886+ Self :: MethodRetTyMismatch { .. } => 8 ,
887+ Self :: MethodStricterBound { .. } => 9 ,
888+ Self :: InvalidSelfType { .. } => 10 ,
862889 }
863890 }
864891
@@ -891,6 +918,11 @@ impl ImplDiag {
891918 "trait method argument number mismatch" . to_string ( )
892919 }
893920
921+ Self :: MethodArgLabelMismatch { .. } => {
922+ "given argument label doesn't match the expected label required by trait"
923+ . to_string ( )
924+ }
925+
894926 Self :: MethodArgTyMismatch { .. } => {
895927 "given argument type doesn't match the expected type required by trait" . to_string ( )
896928 }
@@ -1002,6 +1034,21 @@ impl ImplDiag {
10021034 ) ]
10031035 }
10041036
1037+ Self :: MethodArgLabelMismatch {
1038+ primary,
1039+ definition,
1040+ message,
1041+ } => {
1042+ vec ! [
1043+ SubDiagnostic :: new( LabelStyle :: Primary , message. clone( ) , primary. resolve( db) ) ,
1044+ SubDiagnostic :: new(
1045+ LabelStyle :: Secondary ,
1046+ "argument label is defined here" . to_string( ) ,
1047+ definition. resolve( db) ,
1048+ ) ,
1049+ ]
1050+ }
1051+
10051052 Self :: MethodArgTyMismatch { primary, message } => {
10061053 vec ! [ SubDiagnostic :: new(
10071054 LabelStyle :: Primary ,
0 commit comments