Deopaquify ParamConst
This commit is contained in:
parent
627fa80bdf
commit
98d26d9c4d
4 changed files with 26 additions and 11 deletions
|
@ -1129,7 +1129,7 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
|
|||
tables,
|
||||
))
|
||||
}
|
||||
ty::ParamCt(param) => stable_mir::ty::ConstantKind::ParamCt(opaque(¶m)),
|
||||
ty::ParamCt(param) => stable_mir::ty::ConstantKind::Param(param.stable(tables)),
|
||||
ty::ErrorCt(_) => unreachable!(),
|
||||
ty::InferCt(_) => unreachable!(),
|
||||
ty::BoundCt(_, _) => unimplemented!(),
|
||||
|
@ -1148,6 +1148,14 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ParamConst {
|
||||
type T = stable_mir::ty::ParamConst;
|
||||
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
||||
use stable_mir::ty::ParamConst;
|
||||
ParamConst { index: self.index, name: self.name.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ParamTy {
|
||||
type T = stable_mir::ty::ParamTy;
|
||||
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
||||
|
|
|
@ -49,7 +49,7 @@ impl Foldable for Const {
|
|||
match &mut this.literal {
|
||||
super::ty::ConstantKind::Allocated(alloc) => *alloc = alloc.fold(folder)?,
|
||||
super::ty::ConstantKind::Unevaluated(uv) => *uv = uv.fold(folder)?,
|
||||
super::ty::ConstantKind::ParamCt(param) => *param = param.fold(folder)?,
|
||||
super::ty::ConstantKind::Param(_) => {}
|
||||
}
|
||||
this.ty = this.ty.fold(folder)?;
|
||||
ControlFlow::Continue(this)
|
||||
|
|
|
@ -294,7 +294,13 @@ pub struct Allocation {
|
|||
pub enum ConstantKind {
|
||||
Allocated(Allocation),
|
||||
Unevaluated(UnevaluatedConst),
|
||||
ParamCt(Opaque),
|
||||
Param(ParamConst),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ParamConst {
|
||||
pub index: u32,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
|
@ -30,11 +30,12 @@ impl Visitable for Ty {
|
|||
}
|
||||
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
|
||||
match self.kind() {
|
||||
super::ty::TyKind::RigidTy(ty) => ty.visit(visitor),
|
||||
super::ty::TyKind::Alias(_, alias) => alias.args.visit(visitor),
|
||||
super::ty::TyKind::Param(_) => todo!(),
|
||||
super::ty::TyKind::Bound(_, _) => todo!(),
|
||||
super::ty::TyKind::RigidTy(ty) => ty.visit(visitor)?,
|
||||
super::ty::TyKind::Alias(_, alias) => alias.args.visit(visitor)?,
|
||||
super::ty::TyKind::Param(_) => {}
|
||||
super::ty::TyKind::Bound(_, _) => {}
|
||||
}
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,10 +45,10 @@ impl Visitable for Const {
|
|||
}
|
||||
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
|
||||
match &self.literal {
|
||||
super::ty::ConstantKind::Allocated(alloc) => alloc.visit(visitor),
|
||||
super::ty::ConstantKind::Unevaluated(uv) => uv.visit(visitor),
|
||||
super::ty::ConstantKind::ParamCt(param) => param.visit(visitor),
|
||||
}?;
|
||||
super::ty::ConstantKind::Allocated(alloc) => alloc.visit(visitor)?,
|
||||
super::ty::ConstantKind::Unevaluated(uv) => uv.visit(visitor)?,
|
||||
super::ty::ConstantKind::Param(_) => {}
|
||||
}
|
||||
self.ty.visit(visitor)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue