Make mk_bound_region closure more generic.

This is necessary for the subsequent commits.
This commit is contained in:
Nicholas Nethercote 2023-04-13 12:08:45 +10:00
parent 722e07854a
commit c18773a286

View File

@ -239,8 +239,7 @@ pub fn resolve_interior<'a, 'tcx>(
// typeck had previously found constraints that would cause them to be related. // typeck had previously found constraints that would cause them to be related.
let mut counter = 0; let mut counter = 0;
let mut mk_bound_region = |span| { let mut mk_bound_region = |kind| {
let kind = ty::BrAnon(span);
let var = ty::BoundVar::from_u32(counter); let var = ty::BoundVar::from_u32(counter);
counter += 1; counter += 1;
ty::BoundRegion { var, kind } ty::BoundRegion { var, kind }
@ -252,24 +251,24 @@ pub fn resolve_interior<'a, 'tcx>(
let origin = fcx.region_var_origin(vid); let origin = fcx.region_var_origin(vid);
match origin { match origin {
RegionVariableOrigin::EarlyBoundRegion(span, _) => { 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` // FIXME: these should use `BrNamed`
ty::ReEarlyBound(region) => { 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::ReLateBound(_, ty::BoundRegion { kind, .. })
| ty::ReFree(ty::FreeRegion { bound_region: kind, .. }) => match 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, _) => { 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); let r = fcx.tcx.mk_re_late_bound(current_depth, br);
r r