mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
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,
|
||||
{
|
||||
let next_region = self.infcx.next_region_var(origin);
|
||||
let vid = next_region
|
||||
.as_var()
|
||||
.unwrap_or_else(|| bug!("expected RegionKind::RegionVar on {:?}", next_region));
|
||||
let vid = next_region.as_var();
|
||||
|
||||
if cfg!(debug_assertions) && !self.inside_canonicalization_ctxt() {
|
||||
debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin);
|
||||
@ -531,9 +529,7 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
|
||||
F: Fn() -> RegionCtxt,
|
||||
{
|
||||
let next_region = self.infcx.next_nll_region_var(origin.clone());
|
||||
let vid = next_region
|
||||
.as_var()
|
||||
.unwrap_or_else(|| bug!("expected RegionKind::RegionVar on {:?}", next_region));
|
||||
let vid = next_region.as_var();
|
||||
|
||||
if cfg!(debug_assertions) && !self.inside_canonicalization_ctxt() {
|
||||
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),
|
||||
};
|
||||
|
||||
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() {
|
||||
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
|
||||
debug!(?reg_var);
|
||||
var_to_origin.insert(reg_var, RegionCtxt::Placeholder(reg_info));
|
||||
var_to_origin.insert(reg.as_var(), RegionCtxt::Placeholder(reg_info));
|
||||
}
|
||||
|
||||
reg
|
||||
@ -150,12 +146,9 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
|
||||
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() {
|
||||
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
|
||||
|
@ -1772,10 +1772,10 @@ impl<'tcx> Region<'tcx> {
|
||||
matches!(self.kind(), ty::ReVar(_))
|
||||
}
|
||||
|
||||
pub fn as_var(self) -> Option<RegionVid> {
|
||||
pub fn as_var(self) -> RegionVid {
|
||||
match self.kind() {
|
||||
ty::ReVar(vid) => Some(vid),
|
||||
_ => None,
|
||||
ty::ReVar(vid) => vid,
|
||||
_ => bug!("expected region {:?} to be of kind ReVar", self),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user