Remove index from BrAnon
This commit is contained in:
parent
e4edf00f12
commit
f0edcc8a6f
33 changed files with 68 additions and 88 deletions
|
@ -411,7 +411,7 @@ impl<'tcx> CanonicalVarValues<'tcx> {
|
|||
CanonicalVarKind::Region(_) | CanonicalVarKind::PlaceholderRegion(_) => {
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(i),
|
||||
kind: ty::BrAnon(i as u32, None),
|
||||
kind: ty::BrAnon(None),
|
||||
};
|
||||
tcx.mk_re_late_bound(ty::INNERMOST, br).into()
|
||||
}
|
||||
|
|
|
@ -411,10 +411,8 @@ impl<'tcx> ClosureOutlivesSubjectTy<'tcx> {
|
|||
pub fn bind(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self {
|
||||
let inner = tcx.fold_regions(ty, |r, depth| match r.kind() {
|
||||
ty::ReVar(vid) => {
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::new(vid.index()),
|
||||
kind: ty::BrAnon(vid.as_u32(), None),
|
||||
};
|
||||
let br =
|
||||
ty::BoundRegion { var: ty::BoundVar::new(vid.index()), kind: ty::BrAnon(None) };
|
||||
tcx.mk_re_late_bound(depth, br)
|
||||
}
|
||||
_ => bug!("unexpected region in ClosureOutlivesSubjectTy: {r:?}"),
|
||||
|
|
|
@ -311,7 +311,7 @@ pub struct CommonLifetimes<'tcx> {
|
|||
pub re_vars: Vec<Region<'tcx>>,
|
||||
|
||||
/// Pre-interned values of the form:
|
||||
/// `ReLateBound(DebruijnIndex(i), BoundRegion { var: v, kind: BrAnon(v, None) })`
|
||||
/// `ReLateBound(DebruijnIndex(i), BoundRegion { var: v, kind: BrAnon(None) })`
|
||||
/// for small values of `i` and `v`.
|
||||
pub re_late_bounds: Vec<Vec<Region<'tcx>>>,
|
||||
}
|
||||
|
@ -386,10 +386,7 @@ impl<'tcx> CommonLifetimes<'tcx> {
|
|||
.map(|v| {
|
||||
mk(ty::ReLateBound(
|
||||
ty::DebruijnIndex::from(i),
|
||||
ty::BoundRegion {
|
||||
var: ty::BoundVar::from(v),
|
||||
kind: ty::BrAnon(v, None),
|
||||
},
|
||||
ty::BoundRegion { var: ty::BoundVar::from(v), kind: ty::BrAnon(None) },
|
||||
))
|
||||
})
|
||||
.collect()
|
||||
|
@ -2075,10 +2072,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
bound_region: ty::BoundRegion,
|
||||
) -> Region<'tcx> {
|
||||
// Use a pre-interned one when possible.
|
||||
if let ty::BoundRegion { var, kind: ty::BrAnon(v, None) } = bound_region
|
||||
&& var.as_u32() == v
|
||||
if let ty::BoundRegion { var, kind: ty::BrAnon(None) } = bound_region
|
||||
&& let Some(inner) = self.lifetimes.re_late_bounds.get(debruijn.as_usize())
|
||||
&& let Some(re) = inner.get(v as usize).copied()
|
||||
&& let Some(re) = inner.get(var.as_usize()).copied()
|
||||
{
|
||||
re
|
||||
} else {
|
||||
|
|
|
@ -379,9 +379,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let index = entry.index();
|
||||
let var = ty::BoundVar::from_usize(index);
|
||||
let kind = entry
|
||||
.or_insert_with(|| {
|
||||
ty::BoundVariableKind::Region(ty::BrAnon(index as u32, None))
|
||||
})
|
||||
.or_insert_with(|| ty::BoundVariableKind::Region(ty::BrAnon(None)))
|
||||
.expect_region();
|
||||
let br = ty::BoundRegion { var, kind };
|
||||
self.tcx.mk_re_late_bound(ty::INNERMOST, br)
|
||||
|
|
|
@ -68,7 +68,7 @@ impl<'tcx> fmt::Debug for ty::adjustment::Adjustment<'tcx> {
|
|||
impl fmt::Debug for ty::BoundRegionKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
ty::BrAnon(n, span) => write!(f, "BrAnon({n:?}, {span:?})"),
|
||||
ty::BrAnon(span) => write!(f, "BrAnon({span:?})"),
|
||||
ty::BrNamed(did, name) => {
|
||||
if did.is_crate_root() {
|
||||
write!(f, "BrNamed({})", name)
|
||||
|
|
|
@ -60,7 +60,7 @@ pub struct FreeRegion {
|
|||
#[derive(HashStable)]
|
||||
pub enum BoundRegionKind {
|
||||
/// An anonymous region parameter for a given fn (&T)
|
||||
BrAnon(u32, Option<Span>),
|
||||
BrAnon(Option<Span>),
|
||||
|
||||
/// Named region parameters for functions (a in &'a T)
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue