about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorAli MJ Al-Nasrawy <alimjalnasrawy@gmail.com>2023-10-18 09:33:57 +0000
committerAli MJ Al-Nasrawy <alimjalnasrawy@gmail.com>2024-03-28 06:00:26 +0000
commit08c8caa5244b91ab7bda3bbc383f66ae07f3cc93 (patch)
treede28f60626f94438dd89763910f31faf18901fc2 /compiler
parent15c7e59c05d14be214ded1f8fe703bfb0c14ffa0 (diff)
downloadrust-08c8caa5244b91ab7bda3bbc383f66ae07f3cc93.tar.gz
rust-08c8caa5244b91ab7bda3bbc383f66ae07f3cc93.zip
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.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_borrowck/src/type_check/mod.rs16
1 files changed, 16 insertions, 0 deletions
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();