Fix generics_of for impl's RPITIT synthesized associated type
This commit is contained in:
parent
9139ed076d
commit
640c20272e
@ -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));
|
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.
|
// 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({
|
impl_assoc_ty.generics_of({
|
||||||
let trait_assoc_generics = tcx.generics_of(trait_assoc_def_id);
|
let trait_assoc_generics = tcx.generics_of(trait_assoc_def_id);
|
||||||
let trait_assoc_parent_count = trait_assoc_generics.parent_count;
|
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_generics = tcx.generics_of(impl_def_id);
|
||||||
let parent_count = parent_generics.parent_count + parent_generics.params.len();
|
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 {
|
for param in &mut params {
|
||||||
param.index = param.index + parent_count as u32 + impl_fn_params.len() as u32
|
param.index = param.index + parent_count as u32 - trait_assoc_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 =
|
let param_def_id_to_index =
|
||||||
params.iter().map(|param| (param.def_id, param.index)).collect();
|
params.iter().map(|param| (param.def_id, param.index)).collect();
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// check-pass
|
// check-pass
|
||||||
// edition:2021
|
// edition:2021
|
||||||
|
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||||
|
// revisions: current next
|
||||||
|
|
||||||
#![feature(async_fn_in_trait)]
|
#![feature(async_fn_in_trait)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// check-pass
|
// check-pass
|
||||||
// edition:2021
|
// 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)]
|
#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// check-pass
|
// check-pass
|
||||||
|
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||||
|
// revisions: current next
|
||||||
|
|
||||||
#![feature(return_position_impl_trait_in_trait)]
|
#![feature(return_position_impl_trait_in_trait)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// check-pass
|
// check-pass
|
||||||
|
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||||
|
// revisions: current next
|
||||||
|
|
||||||
#![feature(return_position_impl_trait_in_trait)]
|
#![feature(return_position_impl_trait_in_trait)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// check-pass
|
// check-pass
|
||||||
// edition: 2021
|
// edition: 2021
|
||||||
|
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||||
|
// revisions: current next
|
||||||
|
|
||||||
#![feature(return_position_impl_trait_in_trait)]
|
#![feature(return_position_impl_trait_in_trait)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
|
Loading…
Reference in New Issue
Block a user