Add types to all constants
This commit is contained in:
parent
a370f1baa3
commit
627fa80bdf
@ -1136,7 +1136,6 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
|
||||
ty::PlaceholderCt(_) => unimplemented!(),
|
||||
ty::Unevaluated(uv) => {
|
||||
stable_mir::ty::ConstantKind::Unevaluated(stable_mir::ty::UnevaluatedConst {
|
||||
ty: tables.intern_ty(self.ty()),
|
||||
def: tables.const_def(uv.def),
|
||||
args: uv.args.stable(tables),
|
||||
promoted: None,
|
||||
@ -1144,6 +1143,7 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
|
||||
}
|
||||
ty::ExprCt(_) => unimplemented!(),
|
||||
},
|
||||
ty: tables.intern_ty(self.ty()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1224,17 +1224,18 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::ConstantKind<'tcx> {
|
||||
ConstantKind::Unevaluated(unev_const, ty) => stable_mir::ty::Const {
|
||||
literal: stable_mir::ty::ConstantKind::Unevaluated(
|
||||
stable_mir::ty::UnevaluatedConst {
|
||||
ty: tables.intern_ty(ty),
|
||||
def: tables.const_def(unev_const.def),
|
||||
args: unev_const.args.stable(tables),
|
||||
promoted: unev_const.promoted.map(|u| u.as_u32()),
|
||||
},
|
||||
),
|
||||
ty: tables.intern_ty(ty),
|
||||
},
|
||||
ConstantKind::Val(val, ty) => stable_mir::ty::Const {
|
||||
literal: stable_mir::ty::ConstantKind::Allocated(alloc::new_allocation(
|
||||
ty, val, tables,
|
||||
)),
|
||||
ty: tables.intern_ty(ty),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ impl Foldable for Const {
|
||||
super::ty::ConstantKind::Unevaluated(uv) => *uv = uv.fold(folder)?,
|
||||
super::ty::ConstantKind::ParamCt(param) => *param = param.fold(folder)?,
|
||||
}
|
||||
this.ty = this.ty.fold(folder)?;
|
||||
ControlFlow::Continue(this)
|
||||
}
|
||||
}
|
||||
@ -69,9 +70,8 @@ impl Foldable for Allocation {
|
||||
|
||||
impl Foldable for UnevaluatedConst {
|
||||
fn super_fold<V: Folder>(&self, folder: &mut V) -> ControlFlow<V::Break, Self> {
|
||||
let UnevaluatedConst { ty, def, args, promoted } = self;
|
||||
let UnevaluatedConst { def, args, promoted } = self;
|
||||
ControlFlow::Continue(UnevaluatedConst {
|
||||
ty: ty.fold(folder)?,
|
||||
def: def.fold(folder)?,
|
||||
args: args.fold(folder)?,
|
||||
promoted: promoted.fold(folder)?,
|
||||
|
@ -19,6 +19,7 @@ impl From<TyKind> for Ty {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Const {
|
||||
pub literal: ConstantKind,
|
||||
pub ty: Ty,
|
||||
}
|
||||
|
||||
type Ident = Opaque;
|
||||
@ -298,7 +299,6 @@ pub enum ConstantKind {
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct UnevaluatedConst {
|
||||
pub ty: Ty,
|
||||
pub def: ConstDef,
|
||||
pub args: GenericArgs,
|
||||
pub promoted: Option<Promoted>,
|
||||
|
@ -47,7 +47,8 @@ impl Visitable for Const {
|
||||
super::ty::ConstantKind::Allocated(alloc) => alloc.visit(visitor),
|
||||
super::ty::ConstantKind::Unevaluated(uv) => uv.visit(visitor),
|
||||
super::ty::ConstantKind::ParamCt(param) => param.visit(visitor),
|
||||
}
|
||||
}?;
|
||||
self.ty.visit(visitor)
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,8 +66,7 @@ impl Visitable for Allocation {
|
||||
|
||||
impl Visitable for UnevaluatedConst {
|
||||
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
|
||||
let UnevaluatedConst { ty, def, args, promoted } = self;
|
||||
ty.visit(visitor)?;
|
||||
let UnevaluatedConst { def, args, promoted } = self;
|
||||
def.visit(visitor)?;
|
||||
args.visit(visitor)?;
|
||||
promoted.visit(visitor)
|
||||
|
Loading…
x
Reference in New Issue
Block a user