Skip to content

Commit f9886de

Browse files
committed
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.
1 parent 676d042 commit f9886de

File tree

1 file changed

+16
-0
lines changed
  • compiler/rustc_borrowck/src/type_check

1 file changed

+16
-0
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,22 @@ pub(crate) fn type_check<'mir, 'tcx>(
243243
hidden_type.ty = Ty::new_error(infcx.tcx, reported);
244244
}
245245

246+
// Convert all regions to nll vars.
247+
let (opaque_type_key, hidden_type) =
248+
infcx.tcx.fold_regions((opaque_type_key, hidden_type), |region, _| {
249+
match region.kind() {
250+
ty::ReVar(_) => region,
251+
ty::RePlaceholder(placeholder) => checker
252+
.borrowck_context
253+
.constraints
254+
.placeholder_region(infcx, placeholder),
255+
_ => ty::Region::new_var(
256+
infcx.tcx,
257+
checker.borrowck_context.universal_regions.to_region_vid(region),
258+
),
259+
}
260+
});
261+
246262
(opaque_type_key, hidden_type)
247263
})
248264
.collect();

0 commit comments

Comments
 (0)