Make Region::as_var
infallible.
It's what all the call sites require.
This commit is contained in:
parent
9693b178fc
commit
c802694bda
@ -507,9 +507,7 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
|
|||||||
F: Fn() -> RegionCtxt,
|
F: Fn() -> RegionCtxt,
|
||||||
{
|
{
|
||||||
let next_region = self.infcx.next_region_var(origin);
|
let next_region = self.infcx.next_region_var(origin);
|
||||||
let vid = next_region
|
let vid = next_region.as_var();
|
||||||
.as_var()
|
|
||||||
.unwrap_or_else(|| bug!("expected RegionKind::RegionVar on {:?}", next_region));
|
|
||||||
|
|
||||||
if cfg!(debug_assertions) && !self.inside_canonicalization_ctxt() {
|
if cfg!(debug_assertions) && !self.inside_canonicalization_ctxt() {
|
||||||
debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin);
|
debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin);
|
||||||
@ -531,9 +529,7 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
|
|||||||
F: Fn() -> RegionCtxt,
|
F: Fn() -> RegionCtxt,
|
||||||
{
|
{
|
||||||
let next_region = self.infcx.next_nll_region_var(origin.clone());
|
let next_region = self.infcx.next_nll_region_var(origin.clone());
|
||||||
let vid = next_region
|
let vid = next_region.as_var();
|
||||||
.as_var()
|
|
||||||
.unwrap_or_else(|| bug!("expected RegionKind::RegionVar on {:?}", next_region));
|
|
||||||
|
|
||||||
if cfg!(debug_assertions) && !self.inside_canonicalization_ctxt() {
|
if cfg!(debug_assertions) && !self.inside_canonicalization_ctxt() {
|
||||||
debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin);
|
debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin);
|
||||||
|
@ -131,13 +131,9 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
|
|||||||
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(sym::env),
|
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(sym::env),
|
||||||
};
|
};
|
||||||
|
|
||||||
let reg_var =
|
|
||||||
reg.as_var().unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg));
|
|
||||||
|
|
||||||
if cfg!(debug_assertions) && !self.type_checker.infcx.inside_canonicalization_ctxt() {
|
if cfg!(debug_assertions) && !self.type_checker.infcx.inside_canonicalization_ctxt() {
|
||||||
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
|
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
|
||||||
debug!(?reg_var);
|
var_to_origin.insert(reg.as_var(), RegionCtxt::Placeholder(reg_info));
|
||||||
var_to_origin.insert(reg_var, RegionCtxt::Placeholder(reg_info));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reg
|
reg
|
||||||
@ -150,12 +146,9 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
|
|||||||
universe,
|
universe,
|
||||||
);
|
);
|
||||||
|
|
||||||
let reg_var =
|
|
||||||
reg.as_var().unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg));
|
|
||||||
|
|
||||||
if cfg!(debug_assertions) && !self.type_checker.infcx.inside_canonicalization_ctxt() {
|
if cfg!(debug_assertions) && !self.type_checker.infcx.inside_canonicalization_ctxt() {
|
||||||
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
|
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
|
||||||
var_to_origin.insert(reg_var, RegionCtxt::Existential(None));
|
var_to_origin.insert(reg.as_var(), RegionCtxt::Existential(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
reg
|
reg
|
||||||
|
@ -1772,10 +1772,10 @@ impl<'tcx> Region<'tcx> {
|
|||||||
matches!(self.kind(), ty::ReVar(_))
|
matches!(self.kind(), ty::ReVar(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_var(self) -> Option<RegionVid> {
|
pub fn as_var(self) -> RegionVid {
|
||||||
match self.kind() {
|
match self.kind() {
|
||||||
ty::ReVar(vid) => Some(vid),
|
ty::ReVar(vid) => vid,
|
||||||
_ => None,
|
_ => bug!("expected region {:?} to be of kind ReVar", self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user