add RegionDef
This commit is contained in:
parent
02b01a46de
commit
e49aa04000
3 changed files with 37 additions and 4 deletions
|
@ -86,6 +86,10 @@ impl<'tcx> Tables<'tcx> {
|
||||||
stable_mir::ty::ImplDef(self.create_def_id(did))
|
stable_mir::ty::ImplDef(self.create_def_id(did))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn region_def(&mut self, did: DefId) -> stable_mir::ty::RegionDef {
|
||||||
|
stable_mir::ty::RegionDef(self.create_def_id(did))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn prov(&mut self, aid: AllocId) -> stable_mir::ty::Prov {
|
pub fn prov(&mut self, aid: AllocId) -> stable_mir::ty::Prov {
|
||||||
stable_mir::ty::Prov(self.create_alloc_id(aid))
|
stable_mir::ty::Prov(self.create_alloc_id(aid))
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,12 @@
|
||||||
//!
|
//!
|
||||||
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
|
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
|
||||||
|
|
||||||
use hir::def::DefKind;
|
use crate::rustc_internal::{self, opaque};
|
||||||
|
use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
|
||||||
|
use crate::stable_mir::ty::{
|
||||||
|
EarlyBoundRegion, FloatTy, GenericParamDef, IntTy, Movability, RigidTy, Span, TyKind, UintTy,
|
||||||
|
};
|
||||||
|
use crate::stable_mir::{self, CompilerError, Context};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::mir;
|
use rustc_middle::mir;
|
||||||
use rustc_middle::mir::interpret::{alloc_range, AllocId};
|
use rustc_middle::mir::interpret::{alloc_range, AllocId};
|
||||||
|
@ -1506,6 +1511,27 @@ impl<'tcx> Stable<'tcx> for ty::Region<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
|
||||||
|
type T = stable_mir::ty::RegionKind;
|
||||||
|
|
||||||
|
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
||||||
|
match self {
|
||||||
|
ty::ReEarlyBound(early_reg) => RegionKind::ReEarlyBound(EarlyBoundRegion {
|
||||||
|
def_id: tables.region_def(early_reg.def_id),
|
||||||
|
index: early_reg.index,
|
||||||
|
name: early_reg.name.to_string(),
|
||||||
|
}),
|
||||||
|
ty::ReLateBound(_, _) => todo!(),
|
||||||
|
ty::ReFree(_) => todo!(),
|
||||||
|
ty::ReStatic => todo!(),
|
||||||
|
ty::ReVar(_) => todo!(),
|
||||||
|
ty::RePlaceholder(_) => todo!(),
|
||||||
|
ty::ReErased => todo!(),
|
||||||
|
ty::ReError(_) => todo!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx> Stable<'tcx> for rustc_span::Span {
|
impl<'tcx> Stable<'tcx> for rustc_span::Span {
|
||||||
type T = stable_mir::ty::Span;
|
type T = stable_mir::ty::Span;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub(crate) struct Region {
|
||||||
kind: RegionKind,
|
kind: RegionKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RegionKind {
|
pub enum RegionKind {
|
||||||
ReEarlyBound(EarlyBoundRegion),
|
ReEarlyBound(EarlyBoundRegion),
|
||||||
ReLateBound(DebruijnIndex, BoundRegion),
|
ReLateBound(DebruijnIndex, BoundRegion),
|
||||||
ReFree(FreeRegion),
|
ReFree(FreeRegion),
|
||||||
|
@ -52,7 +52,7 @@ enum RegionKind {
|
||||||
pub(crate) type DebruijnIndex = u32;
|
pub(crate) type DebruijnIndex = u32;
|
||||||
|
|
||||||
pub struct EarlyBoundRegion {
|
pub struct EarlyBoundRegion {
|
||||||
pub def_id: DefId,
|
pub def_id: RegionDef,
|
||||||
pub index: u32,
|
pub index: u32,
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ pub struct BoundRegion {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FreeRegion {
|
pub struct FreeRegion {
|
||||||
pub scope: DefId,
|
pub scope: RegionDef,
|
||||||
pub bound_region: BoundRegionKind,
|
pub bound_region: BoundRegionKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +197,9 @@ pub struct ConstDef(pub DefId);
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct ImplDef(pub DefId);
|
pub struct ImplDef(pub DefId);
|
||||||
|
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
|
pub struct RegionDef(pub(crate) DefId);
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct GenericArgs(pub Vec<GenericArgKind>);
|
pub struct GenericArgs(pub Vec<GenericArgKind>);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue