There can only be one self param

This commit is contained in:
Lukas Wirth 2024-06-21 17:55:16 +02:00
parent cf2b757a1a
commit 480bfd5a7d
5 changed files with 61 additions and 66 deletions

View file

@ -1830,13 +1830,13 @@ impl InferenceContext<'_> {
) -> Substitution {
let (
parent_params,
self_params,
has_self_param,
type_params,
const_params,
impl_trait_params,
lifetime_params,
) = def_generics.provenance_split();
assert_eq!(self_params, 0); // method shouldn't have another Self param
assert!(!has_self_param); // method shouldn't have another Self param
let total_len =
parent_params + type_params + const_params + impl_trait_params + lifetime_params;
let mut substs = Vec::with_capacity(total_len);
@ -1844,13 +1844,11 @@ impl InferenceContext<'_> {
// handle provided arguments
if let Some(generic_args) = generic_args {
// if args are provided, it should be all of them, but we can't rely on that
for (arg, kind_id) in generic_args
.args
.iter()
.take(type_params + const_params + lifetime_params)
.zip(def_generics.iter_id())
let self_params = type_params + const_params + lifetime_params;
for (arg, kind_id) in
generic_args.args.iter().zip(def_generics.iter_self_id()).take(self_params)
{
if let Some(g) = generic_arg_to_chalk(
let arg = generic_arg_to_chalk(
self.db,
kind_id,
arg,
@ -1869,9 +1867,8 @@ impl InferenceContext<'_> {
)
},
|this, lt_ref| this.make_lifetime(lt_ref),
) {
substs.push(g);
}
);
substs.push(arg);
}
};