@@ -34,8 +34,8 @@ use chalk_ir::{
34
34
} ;
35
35
use either:: Either ;
36
36
use 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 ,
39
39
builtin_type:: { BuiltinInt , BuiltinType , BuiltinUint } ,
40
40
expr_store:: { Body , ExpressionStore , HygieneId , path:: Path } ,
41
41
hir:: { BindingAnnotation , BindingId , ExprId , ExprOrPatId , LabelId , PatId } ,
@@ -55,8 +55,9 @@ use triomphe::Arc;
55
55
56
56
use crate :: {
57
57
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 ,
60
61
db:: HirDatabase ,
61
62
fold_tys,
62
63
generics:: Generics ,
@@ -66,7 +67,7 @@ use crate::{
66
67
expr:: ExprIsRead ,
67
68
unify:: InferenceTable ,
68
69
} ,
69
- lower:: { ImplTraitLoweringMode , diagnostics:: TyLoweringDiagnostic } ,
70
+ lower:: { GenericArgsPosition , ImplTraitLoweringMode , diagnostics:: TyLoweringDiagnostic } ,
70
71
mir:: MirSpan ,
71
72
to_assoc_type_id,
72
73
traits:: FnTrait ,
@@ -275,6 +276,20 @@ pub enum InferenceDiagnostic {
275
276
node : ExprOrPatId ,
276
277
diag : PathLoweringDiagnostic ,
277
278
} ,
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
+ } ,
278
293
}
279
294
280
295
/// A mismatch between an expected and an inferred type.
@@ -909,6 +924,7 @@ impl<'a> InferenceContext<'a> {
909
924
let mut param_tys =
910
925
self . with_ty_lowering ( & data. store , InferenceTyDiagnosticSource :: Signature , |ctx| {
911
926
ctx. type_param_mode ( ParamLoweringMode :: Placeholder ) ;
927
+ ctx. in_fn_signature = true ;
912
928
data. params . iter ( ) . map ( |& type_ref| ctx. lower_ty ( type_ref) ) . collect :: < Vec < _ > > ( )
913
929
} ) ;
914
930
@@ -953,8 +969,9 @@ impl<'a> InferenceContext<'a> {
953
969
InferenceTyDiagnosticSource :: Signature ,
954
970
|ctx| {
955
971
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)
958
975
} ,
959
976
) ;
960
977
let return_ty = self . insert_type_vars ( return_ty) ;
@@ -1513,7 +1530,7 @@ impl<'a> InferenceContext<'a> {
1513
1530
InferenceTyDiagnosticSource :: Body ,
1514
1531
self . generic_def ,
1515
1532
) ;
1516
- let mut path_ctx = ctx. at_path ( path, node) ;
1533
+ let mut path_ctx = ctx. at_path ( path, node, GenericArgsPosition :: Value ) ;
1517
1534
let ( resolution, unresolved) = if value_ns {
1518
1535
let Some ( res) = path_ctx. resolve_path_in_value_ns ( HygieneId :: ROOT ) else {
1519
1536
return ( self . err_ty ( ) , None ) ;
0 commit comments