Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Region for smir #116024

Merged
merged 13 commits into from
Sep 29, 2023
Prev Previous commit
Next Next commit
remove un-needed variants
  • Loading branch information
ouz-a committed Sep 28, 2023
commit da2f897e590be03eb4acddfd9df804545b738b65
9 changes: 2 additions & 7 deletions compiler/rustc_smir/src/rustc_smir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 8,7 @@
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.

use crate::rustc_smir::hir::def::DefKind;
use crate::rustc_smir::stable_mir::ty::{BoundRegion, EarlyBoundRegion, FreeRegion, Region};
use crate::rustc_smir::stable_mir::ty::{BoundRegion, EarlyBoundRegion, Region};
use rustc_hir as hir;
use rustc_middle::mir;
use rustc_middle::mir::interpret::{alloc_range, AllocId};
Expand Down Expand Up @@ -1521,12 1521,7 @@ impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
db_index.as_u32(),
BoundRegion { var: bound_reg.var.as_u32(), kind: bound_reg.kind.stable(tables) },
),
ty::ReFree(free_reg) => RegionKind::ReFree(FreeRegion {
scope: tables.region_def(free_reg.scope),
bound_region: free_reg.bound_region.stable(tables),
}),
ty::ReStatic => RegionKind::ReStatic,
ty::ReVar(vid_reg) => RegionKind::ReVar(vid_reg.as_u32()),
ty::RePlaceholder(place_holder) => {
RegionKind::RePlaceholder(stable_mir::ty::Placeholder {
universe: place_holder.universe.as_u32(),
Expand All @@ -1537,7 1532,7 @@ impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
})
}
ty::ReErased => RegionKind::ReErased,
ty::ReError(_) => RegionKind::ReError(()),
_=> unimplemented!()
}
}
}
Expand Down
13 changes: 0 additions & 13 deletions compiler/stable_mir/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 44,9 @@ pub struct Region {
pub enum RegionKind {
ReEarlyBound(EarlyBoundRegion),
ReLateBound(DebruijnIndex, BoundRegion),
ReFree(FreeRegion),
ReStatic,
ReVar(RegionVid),
RePlaceholder(Placeholder<BoundRegion>),
ReErased,
ReError(ErrorGuaranteed),
}

pub(crate) type DebruijnIndex = u32;
Expand All @@ -69,14 66,6 @@ pub struct BoundRegion {
pub kind: BoundRegionKind,
}

#[derive(Debug, Clone)]
pub struct FreeRegion {
pub scope: RegionDef,
pub bound_region: BoundRegionKind,
}

pub(crate) type RegionVid = u32;

pub(crate) type UniverseIndex = u32;

#[derive(Debug, Clone)]
Expand All @@ -85,8 74,6 @@ pub struct Placeholder<T> {
pub bound: T,
}

pub(crate) type ErrorGuaranteed = ();

#[derive(Clone, Copy, PartialEq, Eq)]
pub struct Span(pub usize);

Expand Down