From c18773a286094f1e7ddfb52208819841cbff8897 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 13 Apr 2023 12:08:45 +1000 Subject: [PATCH] Make `mk_bound_region` closure more generic. This is necessary for the subsequent commits. --- .../src/generator_interior/mod.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs index 6f0d078fb2c..161db618b6f 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs @@ -239,8 +239,7 @@ pub fn resolve_interior<'a, 'tcx>( // typeck had previously found constraints that would cause them to be related. let mut counter = 0; - let mut mk_bound_region = |span| { - let kind = ty::BrAnon(span); + let mut mk_bound_region = |kind| { let var = ty::BoundVar::from_u32(counter); counter += 1; ty::BoundRegion { var, kind } @@ -252,24 +251,24 @@ pub fn resolve_interior<'a, 'tcx>( let origin = fcx.region_var_origin(vid); match origin { RegionVariableOrigin::EarlyBoundRegion(span, _) => { - mk_bound_region(Some(span)) + mk_bound_region(ty::BrAnon(Some(span))) } - _ => mk_bound_region(None), + _ => mk_bound_region(ty::BrAnon(None)), } } // FIXME: these should use `BrNamed` ty::ReEarlyBound(region) => { - mk_bound_region(Some(fcx.tcx.def_span(region.def_id))) + mk_bound_region(ty::BrAnon(Some(fcx.tcx.def_span(region.def_id)))) } ty::ReLateBound(_, ty::BoundRegion { kind, .. }) | ty::ReFree(ty::FreeRegion { bound_region: kind, .. }) => match kind { - ty::BoundRegionKind::BrAnon(span) => mk_bound_region(span), + ty::BoundRegionKind::BrAnon(span) => mk_bound_region(ty::BrAnon(span)), ty::BoundRegionKind::BrNamed(def_id, _) => { - mk_bound_region(Some(fcx.tcx.def_span(def_id))) + mk_bound_region(ty::BrAnon(Some(fcx.tcx.def_span(def_id)))) } - ty::BoundRegionKind::BrEnv => mk_bound_region(None), + ty::BoundRegionKind::BrEnv => mk_bound_region(ty::BrAnon(None)), }, - _ => mk_bound_region(None), + _ => mk_bound_region(ty::BrAnon(None)), }; let r = fcx.tcx.mk_re_late_bound(current_depth, br); r