@@ -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 , ImplId , ItemContainerId , Lookup ,
38
- 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
data:: { ConstData , StaticData } ,
41
41
expr_store:: { Body , HygieneId } ,
@@ -56,8 +56,9 @@ use triomphe::Arc;
56
56
57
57
use crate :: {
58
58
AliasEq , AliasTy , Binders , ClosureId , Const , DomainGoal , GenericArg , Goal , ImplTraitId ,
59
- ImplTraitIdx , InEnvironment , Interner , Lifetime , OpaqueTyId , ParamLoweringMode ,
60
- PathLoweringDiagnostic , ProjectionTy , Substitution , TraitEnvironment , Ty , TyBuilder , TyExt ,
59
+ ImplTraitIdx , InEnvironment , IncorrectGenericsLenKind , Interner , Lifetime , OpaqueTyId ,
60
+ ParamLoweringMode , PathLoweringDiagnostic , ProjectionTy , Substitution , TraitEnvironment , Ty ,
61
+ TyBuilder , TyExt ,
61
62
db:: HirDatabase ,
62
63
fold_tys,
63
64
generics:: Generics ,
@@ -67,7 +68,7 @@ use crate::{
67
68
expr:: ExprIsRead ,
68
69
unify:: InferenceTable ,
69
70
} ,
70
- lower:: { ImplTraitLoweringMode , diagnostics:: TyLoweringDiagnostic } ,
71
+ lower:: { GenericArgsPosition , ImplTraitLoweringMode , diagnostics:: TyLoweringDiagnostic } ,
71
72
mir:: MirSpan ,
72
73
to_assoc_type_id,
73
74
traits:: FnTrait ,
@@ -286,6 +287,20 @@ pub enum InferenceDiagnostic {
286
287
node : ExprOrPatId ,
287
288
diag : PathLoweringDiagnostic ,
288
289
} ,
290
+ MethodCallIncorrectGenericsLen {
291
+ expr : ExprId ,
292
+ provided_count : u32 ,
293
+ expected_count : u32 ,
294
+ kind : IncorrectGenericsLenKind ,
295
+ def : GenericDefId ,
296
+ } ,
297
+ MethodCallIncorrectGenericsOrder {
298
+ expr : ExprId ,
299
+ param_id : GenericParamId ,
300
+ arg_idx : u32 ,
301
+ /// Whether the `GenericArgs` contains a `Self` arg.
302
+ has_self_arg : bool ,
303
+ } ,
289
304
}
290
305
291
306
/// A mismatch between an expected and an inferred type.
@@ -920,6 +935,7 @@ impl<'a> InferenceContext<'a> {
920
935
self . with_ty_lowering ( & data. types_map , InferenceTyDiagnosticSource :: Signature , |ctx| {
921
936
ctx. type_param_mode ( ParamLoweringMode :: Placeholder )
922
937
. impl_trait_mode ( ImplTraitLoweringMode :: Param ) ;
938
+ ctx. in_fn_signature = true ;
923
939
data. params . iter ( ) . map ( |& type_ref| ctx. lower_ty ( type_ref) ) . collect :: < Vec < _ > > ( )
924
940
} ) ;
925
941
// Check if function contains a va_list, if it does then we append it to the parameter types
@@ -961,8 +977,9 @@ impl<'a> InferenceContext<'a> {
961
977
let return_ty =
962
978
self . with_ty_lowering ( & data. types_map , InferenceTyDiagnosticSource :: Signature , |ctx| {
963
979
ctx. type_param_mode ( ParamLoweringMode :: Placeholder )
964
- . impl_trait_mode ( ImplTraitLoweringMode :: Opaque )
965
- . lower_ty ( return_ty)
980
+ . impl_trait_mode ( ImplTraitLoweringMode :: Opaque ) ;
981
+ ctx. in_fn_signature = true ;
982
+ ctx. lower_ty ( return_ty)
966
983
} ) ;
967
984
let return_ty = self . insert_type_vars ( return_ty) ;
968
985
@@ -1499,7 +1516,7 @@ impl<'a> InferenceContext<'a> {
1499
1516
& self . diagnostics ,
1500
1517
InferenceTyDiagnosticSource :: Body ,
1501
1518
) ;
1502
- let mut path_ctx = ctx. at_path ( path, node) ;
1519
+ let mut path_ctx = ctx. at_path ( path, node, GenericArgsPosition :: Value ) ;
1503
1520
let ( resolution, unresolved) = if value_ns {
1504
1521
let Some ( res) = path_ctx. resolve_path_in_value_ns ( HygieneId :: ROOT ) else {
1505
1522
return ( self . err_ty ( ) , None ) ;
0 commit comments