Actually create ranged int types in the type system.
This commit is contained in:
parent
6b24a9cf70
commit
84acfe86de
97 changed files with 1208 additions and 77 deletions
|
@ -14,8 +14,8 @@ use stable_mir::mir::{Mutability, Place, ProjectionElem, Safety};
|
|||
use stable_mir::ty::{
|
||||
Abi, AdtDef, Binder, BoundRegionKind, BoundTyKind, BoundVariableKind, ClosureKind, Const,
|
||||
DynKind, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, FloatTy, FnSig,
|
||||
GenericArgKind, GenericArgs, IndexedVal, IntTy, Movability, Region, RigidTy, Span, TermKind,
|
||||
TraitRef, Ty, UintTy, VariantDef, VariantIdx,
|
||||
GenericArgKind, GenericArgs, IndexedVal, IntTy, Movability, Pattern, Region, RigidTy, Span,
|
||||
TermKind, TraitRef, Ty, UintTy, VariantDef, VariantIdx,
|
||||
};
|
||||
use stable_mir::{CrateItem, CrateNum, DefId};
|
||||
|
||||
|
@ -76,6 +76,19 @@ impl RustcInternal for Ty {
|
|||
}
|
||||
}
|
||||
|
||||
impl RustcInternal for Pattern {
|
||||
type T<'tcx> = rustc_ty::Pattern<'tcx>;
|
||||
fn internal<'tcx>(&self, tables: &mut Tables<'_>, tcx: TyCtxt<'tcx>) -> Self::T<'tcx> {
|
||||
tcx.mk_pat(match self {
|
||||
Pattern::Range { start, end, include_end } => rustc_ty::PatternKind::Range {
|
||||
start: start.as_ref().map(|c| ty_const(c, tables, tcx)),
|
||||
end: end.as_ref().map(|c| ty_const(c, tables, tcx)),
|
||||
include_end: *include_end,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl RustcInternal for RigidTy {
|
||||
type T<'tcx> = rustc_ty::TyKind<'tcx>;
|
||||
|
||||
|
@ -90,6 +103,9 @@ impl RustcInternal for RigidTy {
|
|||
RigidTy::Array(ty, cnst) => {
|
||||
rustc_ty::TyKind::Array(ty.internal(tables, tcx), ty_const(cnst, tables, tcx))
|
||||
}
|
||||
RigidTy::Pat(ty, pat) => {
|
||||
rustc_ty::TyKind::Pat(ty.internal(tables, tcx), pat.internal(tables, tcx))
|
||||
}
|
||||
RigidTy::Adt(def, args) => {
|
||||
rustc_ty::TyKind::Adt(def.internal(tables, tcx), args.internal(tables, tcx))
|
||||
}
|
||||
|
|
|
@ -330,6 +330,9 @@ impl<'tcx> Stable<'tcx> for ty::TyKind<'tcx> {
|
|||
ty::Array(ty, constant) => {
|
||||
TyKind::RigidTy(RigidTy::Array(ty.stable(tables), constant.stable(tables)))
|
||||
}
|
||||
ty::Pat(ty, pat) => {
|
||||
TyKind::RigidTy(RigidTy::Pat(ty.stable(tables), pat.stable(tables)))
|
||||
}
|
||||
ty::Slice(ty) => TyKind::RigidTy(RigidTy::Slice(ty.stable(tables))),
|
||||
ty::RawPtr(ty, mutbl) => {
|
||||
TyKind::RigidTy(RigidTy::RawPtr(ty.stable(tables), mutbl.stable(tables)))
|
||||
|
@ -385,6 +388,20 @@ impl<'tcx> Stable<'tcx> for ty::TyKind<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::Pattern<'tcx> {
|
||||
type T = stable_mir::ty::Pattern;
|
||||
|
||||
fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
|
||||
match **self {
|
||||
ty::PatternKind::Range { start, end, include_end } => stable_mir::ty::Pattern::Range {
|
||||
start: start.stable(tables),
|
||||
end: end.stable(tables),
|
||||
include_end,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
|
||||
type T = stable_mir::ty::Const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue