Rollup merge of #109277 - spastorino:new-rpitit-14, r=compiler-errors
Fix generics_of for impl's RPITIT synthesized associated type The only useful commit is the last one. This makes `generics_of` for the impl side RPITIT copy from the trait's associated type and avoid the fn on the impl side which was previously wrongly used. This solution is better but we still need to fix resolution of the generated generics. r? ``@compiler-errors``
This commit is contained in:
commit
d86fd83ef6
13 changed files with 60 additions and 12 deletions
|
@ -396,6 +396,8 @@ fn associated_type_for_impl_trait_in_impl(
|
|||
impl_assoc_ty.impl_defaultness(tcx.impl_defaultness(impl_fn_def_id));
|
||||
|
||||
// Copy generics_of the trait's associated item but the impl as the parent.
|
||||
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty) resolves to the trait instead of the impl
|
||||
// generics.
|
||||
impl_assoc_ty.generics_of({
|
||||
let trait_assoc_generics = tcx.generics_of(trait_assoc_def_id);
|
||||
let trait_assoc_parent_count = trait_assoc_generics.parent_count;
|
||||
|
@ -404,16 +406,10 @@ fn associated_type_for_impl_trait_in_impl(
|
|||
let parent_generics = tcx.generics_of(impl_def_id);
|
||||
let parent_count = parent_generics.parent_count + parent_generics.params.len();
|
||||
|
||||
let mut impl_fn_params = tcx.generics_of(impl_fn_def_id).params.clone();
|
||||
|
||||
for param in &mut params {
|
||||
param.index = param.index + parent_count as u32 + impl_fn_params.len() as u32
|
||||
- trait_assoc_parent_count as u32;
|
||||
param.index = param.index + parent_count as u32 - trait_assoc_parent_count as u32;
|
||||
}
|
||||
|
||||
impl_fn_params.extend(params);
|
||||
params = impl_fn_params;
|
||||
|
||||
let param_def_id_to_index =
|
||||
params.iter().map(|param| (param.def_id, param.index)).collect();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue