From 83c0ff8fa5eb1789b9d5caa1d5bb2b344165e897 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 3 Mar 2023 12:34:16 -0300 Subject: [PATCH] Map to new synthesized assoc ty for RPITITs in astconv --- compiler/rustc_hir_analysis/src/astconv/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 899029d98e0..2a64e09b9c6 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -3049,10 +3049,18 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } &hir::TyKind::OpaqueDef(item_id, lifetimes, in_trait) => { let opaque_ty = tcx.hir().item(item_id); - let def_id = item_id.owner_id.to_def_id(); match opaque_ty.kind { hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => { + let local_def_id = item_id.owner_id.def_id; + // If this is an RPITIT and we are using the new RPITIT lowering scheme, we + // generate the def_id of an associated type for the trait and return as + // type a projection. + let def_id = if in_trait && tcx.lower_impl_trait_in_trait_to_assoc_ty() { + tcx.associated_item_for_impl_trait_in_trait(local_def_id).to_def_id() + } else { + local_def_id.to_def_id() + }; self.impl_trait_ty_to_ty(def_id, lifetimes, origin, in_trait) } ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i),