From 08c8caa5244b91ab7bda3bbc383f66ae07f3cc93 Mon Sep 17 00:00:00 2001 From: Ali MJ Al-Nasrawy Date: Wed, 18 Oct 2023 09:33:57 +0000 Subject: [PATCH] convert all named regions in opaque types to nll vars Do it in typeck before entering region inference routines particularly because we will no longer be able to convert placeholders. --- compiler/rustc_borrowck/src/type_check/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index a206aac0467..b72dccb2ebd 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -229,6 +229,22 @@ pub(crate) fn type_check<'mir, 'tcx>( ); } + // Convert all regions to nll vars. + let (opaque_type_key, hidden_type) = + infcx.tcx.fold_regions((opaque_type_key, hidden_type), |region, _| { + match region.kind() { + ty::ReVar(_) => region, + ty::RePlaceholder(placeholder) => checker + .borrowck_context + .constraints + .placeholder_region(infcx, placeholder), + _ => ty::Region::new_var( + infcx.tcx, + checker.borrowck_context.universal_regions.to_region_vid(region), + ), + } + }); + (opaque_type_key, hidden_type) }) .collect();