Fix generics_of for impl's RPITIT synthesized associated type

This commit is contained in:
Santiago Pastorino 2023-03-17 14:05:26 -03:00
parent 9139ed076d
commit 640c20272e
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF
6 changed files with 13 additions and 7 deletions

View File

@ -383,6 +383,8 @@ fn impl_associated_item_for_impl_trait_in_trait(
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;
@ -391,16 +393,10 @@ fn impl_associated_item_for_impl_trait_in_trait(
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();

View File

@ -1,5 +1,7 @@
// check-pass
// edition:2021
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
// revisions: current next
#![feature(async_fn_in_trait)]
#![allow(incomplete_features)]

View File

@ -1,5 +1,7 @@
// check-pass
// edition:2021
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
// revisions: current next
#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]

View File

@ -1,4 +1,6 @@
// check-pass
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
// revisions: current next
#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]

View File

@ -1,4 +1,6 @@
// check-pass
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
// revisions: current next
#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]

View File

@ -1,5 +1,7 @@
// check-pass
// edition: 2021
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
// revisions: current next
#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]