mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
add RegionDef
This commit is contained in:
parent
02b01a46de
commit
e49aa04000
@ -86,6 +86,10 @@ impl<'tcx> Tables<'tcx> {
|
||||
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 {
|
||||
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.
|
||||
|
||||
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_middle::mir;
|
||||
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 {
|
||||
type T = stable_mir::ty::Span;
|
||||
|
||||
|
@ -38,7 +38,7 @@ pub(crate) struct Region {
|
||||
kind: RegionKind,
|
||||
}
|
||||
|
||||
enum RegionKind {
|
||||
pub enum RegionKind {
|
||||
ReEarlyBound(EarlyBoundRegion),
|
||||
ReLateBound(DebruijnIndex, BoundRegion),
|
||||
ReFree(FreeRegion),
|
||||
@ -52,7 +52,7 @@ enum RegionKind {
|
||||
pub(crate) type DebruijnIndex = u32;
|
||||
|
||||
pub struct EarlyBoundRegion {
|
||||
pub def_id: DefId,
|
||||
pub def_id: RegionDef,
|
||||
pub index: u32,
|
||||
pub name: Symbol,
|
||||
}
|
||||
@ -65,7 +65,7 @@ pub struct BoundRegion {
|
||||
}
|
||||
|
||||
pub struct FreeRegion {
|
||||
pub scope: DefId,
|
||||
pub scope: RegionDef,
|
||||
pub bound_region: BoundRegionKind,
|
||||
}
|
||||
|
||||
@ -197,6 +197,9 @@ pub struct ConstDef(pub DefId);
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct ImplDef(pub DefId);
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct RegionDef(pub(crate) DefId);
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct GenericArgs(pub Vec<GenericArgKind>);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user