2023-07-13 05:07:50 +00:00
|
|
|
use super::{mir::Mutability, with, DefId};
|
2023-07-12 19:24:33 +00:00
|
|
|
use crate::rustc_internal::Opaque;
|
2023-04-24 01:04:44 +00:00
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug)]
|
|
|
|
pub struct Ty(pub usize);
|
|
|
|
|
|
|
|
impl Ty {
|
|
|
|
pub fn kind(&self) -> TyKind {
|
|
|
|
with(|context| context.ty_kind(*self))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-12 19:24:33 +00:00
|
|
|
type Const = Opaque;
|
2023-07-13 05:07:50 +00:00
|
|
|
pub(crate) type Region = Opaque;
|
2023-07-12 19:24:33 +00:00
|
|
|
|
2023-07-05 21:50:13 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2023-04-24 01:04:44 +00:00
|
|
|
pub enum TyKind {
|
2023-06-28 14:31:28 +00:00
|
|
|
RigidTy(RigidTy),
|
|
|
|
}
|
|
|
|
|
2023-07-05 21:50:13 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2023-06-28 14:31:28 +00:00
|
|
|
pub enum RigidTy {
|
2023-04-24 01:04:44 +00:00
|
|
|
Bool,
|
2023-07-05 22:01:11 +00:00
|
|
|
Char,
|
2023-07-05 22:06:49 +00:00
|
|
|
Int(IntTy),
|
2023-07-05 22:26:52 +00:00
|
|
|
Uint(UintTy),
|
2023-07-05 22:30:24 +00:00
|
|
|
Float(FloatTy),
|
2023-07-18 15:11:49 +00:00
|
|
|
Adt(AdtDef, GenericArgs),
|
2023-07-18 14:18:40 +00:00
|
|
|
Foreign(ForeignDef),
|
2023-07-12 04:56:45 +00:00
|
|
|
Str,
|
|
|
|
Array(Ty, Const),
|
|
|
|
Slice(Ty),
|
2023-07-13 04:23:22 +00:00
|
|
|
RawPtr(Ty, Mutability),
|
2023-07-13 05:07:50 +00:00
|
|
|
Ref(Region, Ty, Mutability),
|
2023-07-18 15:16:38 +00:00
|
|
|
FnDef(FnDef, GenericArgs),
|
2023-07-18 15:19:41 +00:00
|
|
|
Closure(ClosureDef, GenericArgs),
|
2023-07-18 16:38:16 +00:00
|
|
|
Generator(GeneratorDef, GenericArgs, Movability),
|
2023-07-18 15:02:35 +00:00
|
|
|
Never,
|
2023-04-24 01:04:44 +00:00
|
|
|
Tuple(Vec<Ty>),
|
|
|
|
}
|
2023-07-05 22:06:49 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
pub enum IntTy {
|
|
|
|
Isize,
|
|
|
|
I8,
|
|
|
|
I16,
|
|
|
|
I32,
|
|
|
|
I64,
|
|
|
|
I128,
|
|
|
|
}
|
2023-07-05 22:26:52 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
pub enum UintTy {
|
|
|
|
Usize,
|
|
|
|
U8,
|
|
|
|
U16,
|
|
|
|
U32,
|
|
|
|
U64,
|
|
|
|
U128,
|
|
|
|
}
|
2023-07-05 22:30:24 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
pub enum FloatTy {
|
|
|
|
F32,
|
|
|
|
F64,
|
|
|
|
}
|
2023-07-12 19:24:33 +00:00
|
|
|
|
2023-07-18 16:38:16 +00:00
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
pub enum Movability {
|
|
|
|
Static,
|
|
|
|
Movable,
|
|
|
|
}
|
|
|
|
|
2023-07-18 14:18:40 +00:00
|
|
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
|
|
|
pub struct ForeignDef(pub(crate) DefId);
|
|
|
|
|
2023-07-18 15:16:38 +00:00
|
|
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
|
|
|
pub struct FnDef(pub(crate) DefId);
|
|
|
|
|
2023-07-18 15:19:41 +00:00
|
|
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
|
|
|
pub struct ClosureDef(pub(crate) DefId);
|
|
|
|
|
2023-07-18 16:38:16 +00:00
|
|
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
|
|
|
pub struct GeneratorDef(pub(crate) DefId);
|
|
|
|
|
2023-07-12 19:24:33 +00:00
|
|
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
|
|
|
pub struct AdtDef(pub(crate) DefId);
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
2023-07-18 15:11:49 +00:00
|
|
|
pub struct GenericArgs(pub Vec<GenericArgKind>);
|
2023-07-12 19:24:33 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub enum GenericArgKind {
|
|
|
|
Lifetime(Region),
|
|
|
|
Type(Ty),
|
|
|
|
Const(Const),
|
|
|
|
}
|