@@ -34,8 +34,8 @@ use chalk_ir::{
3434} ;
3535use either:: Either ;
3636use hir_def:: {
37- AdtId , AssocItemId , DefWithBodyId , FieldId , FunctionId , GenericDefId , ImplId , ItemContainerId ,
38- Lookup , TraitId , TupleFieldId , TupleId , TypeAliasId , VariantId ,
37+ AdtId , AssocItemId , DefWithBodyId , FieldId , FunctionId , GenericDefId , GenericParamId , ImplId ,
38+ ItemContainerId , Lookup , TraitId , TupleFieldId , TupleId , TypeAliasId , VariantId ,
3939 builtin_type:: { BuiltinInt , BuiltinType , BuiltinUint } ,
4040 expr_store:: { Body , ExpressionStore , HygieneId , path:: Path } ,
4141 hir:: { BindingAnnotation , BindingId , ExprId , ExprOrPatId , LabelId , PatId } ,
@@ -55,8 +55,9 @@ use triomphe::Arc;
5555
5656use crate :: {
5757 AliasEq , AliasTy , Binders , ClosureId , Const , DomainGoal , GenericArg , Goal , ImplTraitId ,
58- ImplTraitIdx , InEnvironment , Interner , Lifetime , OpaqueTyId , ParamLoweringMode ,
59- PathLoweringDiagnostic , ProjectionTy , Substitution , TraitEnvironment , Ty , TyBuilder , TyExt ,
58+ ImplTraitIdx , InEnvironment , IncorrectGenericsLenKind , Interner , Lifetime , OpaqueTyId ,
59+ ParamLoweringMode , PathLoweringDiagnostic , ProjectionTy , Substitution , TraitEnvironment , Ty ,
60+ TyBuilder , TyExt ,
6061 db:: HirDatabase ,
6162 fold_tys,
6263 generics:: Generics ,
@@ -66,7 +67,7 @@ use crate::{
6667 expr:: ExprIsRead ,
6768 unify:: InferenceTable ,
6869 } ,
69- lower:: { ImplTraitLoweringMode , diagnostics:: TyLoweringDiagnostic } ,
70+ lower:: { GenericArgsPosition , ImplTraitLoweringMode , diagnostics:: TyLoweringDiagnostic } ,
7071 mir:: MirSpan ,
7172 to_assoc_type_id,
7273 traits:: FnTrait ,
@@ -275,6 +276,20 @@ pub enum InferenceDiagnostic {
275276 node : ExprOrPatId ,
276277 diag : PathLoweringDiagnostic ,
277278 } ,
279+ MethodCallIncorrectGenericsLen {
280+ expr : ExprId ,
281+ provided_count : u32 ,
282+ expected_count : u32 ,
283+ kind : IncorrectGenericsLenKind ,
284+ def : GenericDefId ,
285+ } ,
286+ MethodCallIncorrectGenericsOrder {
287+ expr : ExprId ,
288+ param_id : GenericParamId ,
289+ arg_idx : u32 ,
290+ /// Whether the `GenericArgs` contains a `Self` arg.
291+ has_self_arg : bool ,
292+ } ,
278293}
279294
280295/// A mismatch between an expected and an inferred type.
@@ -909,6 +924,7 @@ impl<'a> InferenceContext<'a> {
909924 let mut param_tys =
910925 self . with_ty_lowering ( & data. store , InferenceTyDiagnosticSource :: Signature , |ctx| {
911926 ctx. type_param_mode ( ParamLoweringMode :: Placeholder ) ;
927+ ctx. in_fn_signature = true ;
912928 data. params . iter ( ) . map ( |& type_ref| ctx. lower_ty ( type_ref) ) . collect :: < Vec < _ > > ( )
913929 } ) ;
914930
@@ -953,8 +969,9 @@ impl<'a> InferenceContext<'a> {
953969 InferenceTyDiagnosticSource :: Signature ,
954970 |ctx| {
955971 ctx. type_param_mode ( ParamLoweringMode :: Placeholder )
956- . impl_trait_mode ( ImplTraitLoweringMode :: Opaque )
957- . lower_ty ( return_ty)
972+ . impl_trait_mode ( ImplTraitLoweringMode :: Opaque ) ;
973+ ctx. in_fn_signature = true ;
974+ ctx. lower_ty ( return_ty)
958975 } ,
959976 ) ;
960977 let return_ty = self . insert_type_vars ( return_ty) ;
@@ -1513,7 +1530,7 @@ impl<'a> InferenceContext<'a> {
15131530 InferenceTyDiagnosticSource :: Body ,
15141531 self . generic_def ,
15151532 ) ;
1516- let mut path_ctx = ctx. at_path ( path, node) ;
1533+ let mut path_ctx = ctx. at_path ( path, node, GenericArgsPosition :: Value ) ;
15171534 let ( resolution, unresolved) = if value_ns {
15181535 let Some ( res) = path_ctx. resolve_path_in_value_ns ( HygieneId :: ROOT ) else {
15191536 return ( self . err_ty ( ) , None ) ;
0 commit comments