@@ -61,6 +61,13 @@ pub enum PathResolutionError {
6161 UnresolvedWithPossibleTraitsToImport { ident : Ident , traits : Vec < String > } ,
6262 #[ error( "Multiple applicable items in scope" ) ]
6363 MultipleTraitsInScope { ident : Ident , traits : Vec < String > } ,
64+ #[ error( "Multiple `impl`s of `{trait_name}` apply to `{type_name}`" ) ]
65+ MultipleApplicableImpls {
66+ ident : Ident ,
67+ trait_name : String ,
68+ type_name : String ,
69+ impls : Vec < ( String , Location ) > ,
70+ } ,
6471 #[ error( "No function named '{ident}' found for '{typ}' in the current scope" ) ]
6572 UnresolvedMethodForType { typ : String , ident : Ident , available_impls : Vec < String > } ,
6673}
@@ -75,6 +82,7 @@ impl PathResolutionError {
7582 | PathResolutionError :: NotAModule { ident, .. }
7683 | PathResolutionError :: TraitMethodNotInScope { ident, .. }
7784 | PathResolutionError :: MultipleTraitsInScope { ident, .. }
85+ | PathResolutionError :: MultipleApplicableImpls { ident, .. }
7886 | PathResolutionError :: UnresolvedWithPossibleTraitsToImport { ident, .. }
7987 | PathResolutionError :: UnresolvedMethodForType { ident, .. } => ident. location ( ) ,
8088 }
@@ -142,6 +150,17 @@ impl<'a> From<&'a PathResolutionError> for CustomDiagnostic {
142150 ident. location ( ) ,
143151 )
144152 }
153+ PathResolutionError :: MultipleApplicableImpls { ident, impls, .. } => {
154+ let mut diag = CustomDiagnostic :: simple_error (
155+ error. to_string ( ) ,
156+ String :: new ( ) ,
157+ ident. location ( ) ,
158+ ) ;
159+ for ( signature, location) in impls {
160+ diag. add_secondary ( format ! ( "candidate `{signature}` defined here" ) , * location) ;
161+ }
162+ diag
163+ }
145164 PathResolutionError :: UnresolvedMethodForType { typ : _, ident, available_impls } => {
146165 let secondary = if available_impls. is_empty ( ) {
147166 String :: new ( )
0 commit comments