From 84a24a1b3c183066644be2db03c48545d796f01f Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 19 Jul 2022 22:16:32 -0300 Subject: [PATCH] Unroll while_capturing_lifetimes into lower_opaque_impl_trait --- compiler/rustc_ast_lowering/src/lib.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 2749af72b68f..72e0466761a0 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1376,11 +1376,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let hir_bounds = if origin == hir::OpaqueTyOrigin::TyAlias { lower_bounds(lctx) } else { - lctx.while_capturing_lifetimes( - opaque_ty_def_id, - &mut collected_lifetimes, - lower_bounds, - ) + let lifetime_stash = std::mem::replace( + &mut lctx.captured_lifetimes, + Some(LifetimeCaptureContext { + parent_def_id: opaque_ty_def_id, + captures: std::mem::take(&mut collected_lifetimes), + binders_to_ignore: Default::default(), + }), + ); + + let ret = lower_bounds(lctx); + + let ctxt = std::mem::replace(&mut lctx.captured_lifetimes, lifetime_stash).unwrap(); + collected_lifetimes = ctxt.captures; + + ret }; debug!(?collected_lifetimes);