Skip to content

Commit 8764b87

Browse files
committed
Deopaquify ParamConst
1 parent 5a129d1 commit 8764b87

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

compiler/rustc_smir/src/rustc_smir/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
11231123
tables,
11241124
))
11251125
}
1126-
ty::ParamCt(param) => stable_mir::ty::ConstantKind::ParamCt(opaque(&param)),
1126+
ty::ParamCt(param) => stable_mir::ty::ConstantKind::Param(param.stable(tables)),
11271127
ty::ErrorCt(_) => unreachable!(),
11281128
ty::InferCt(_) => unreachable!(),
11291129
ty::BoundCt(_, _) => unimplemented!(),
@@ -1142,6 +1142,14 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
11421142
}
11431143
}
11441144

1145+
impl<'tcx> Stable<'tcx> for ty::ParamConst {
1146+
type T = stable_mir::ty::ParamConst;
1147+
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
1148+
use stable_mir::ty::ParamConst;
1149+
ParamConst { index: self.index, name: self.name.to_string() }
1150+
}
1151+
}
1152+
11451153
impl<'tcx> Stable<'tcx> for ty::ParamTy {
11461154
type T = stable_mir::ty::ParamTy;
11471155
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {

compiler/rustc_smir/src/stable_mir/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Foldable for Const {
4949
match &mut this.literal {
5050
super::ty::ConstantKind::Allocated(alloc) => *alloc = alloc.fold(folder)?,
5151
super::ty::ConstantKind::Unevaluated(uv) => *uv = uv.fold(folder)?,
52-
super::ty::ConstantKind::ParamCt(param) => *param = param.fold(folder)?,
52+
super::ty::ConstantKind::Param(_) => {}
5353
}
5454
this.ty = this.ty.fold(folder)?;
5555
ControlFlow::Continue(this)

compiler/rustc_smir/src/stable_mir/ty.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,13 @@ pub struct Allocation {
294294
pub enum ConstantKind {
295295
Allocated(Allocation),
296296
Unevaluated(UnevaluatedConst),
297-
ParamCt(Opaque),
297+
Param(ParamConst),
298+
}
299+
300+
#[derive(Clone, Debug)]
301+
pub struct ParamConst {
302+
pub index: u32,
303+
pub name: String,
298304
}
299305

300306
#[derive(Clone, Debug)]

compiler/rustc_smir/src/stable_mir/visitor.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ impl Visitable for Ty {
3030
}
3131
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
3232
match self.kind() {
33-
super::ty::TyKind::RigidTy(ty) => ty.visit(visitor),
34-
super::ty::TyKind::Alias(_, alias) => alias.args.visit(visitor),
35-
super::ty::TyKind::Param(_) => todo!(),
36-
super::ty::TyKind::Bound(_, _) => todo!(),
33+
super::ty::TyKind::RigidTy(ty) => ty.visit(visitor)?,
34+
super::ty::TyKind::Alias(_, alias) => alias.args.visit(visitor)?,
35+
super::ty::TyKind::Param(_) => {}
36+
super::ty::TyKind::Bound(_, _) => {}
3737
}
38+
ControlFlow::Continue(())
3839
}
3940
}
4041

@@ -44,10 +45,10 @@ impl Visitable for Const {
4445
}
4546
fn super_visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break> {
4647
match &self.literal {
47-
super::ty::ConstantKind::Allocated(alloc) => alloc.visit(visitor),
48-
super::ty::ConstantKind::Unevaluated(uv) => uv.visit(visitor),
49-
super::ty::ConstantKind::ParamCt(param) => param.visit(visitor),
50-
}?;
48+
super::ty::ConstantKind::Allocated(alloc) => alloc.visit(visitor)?,
49+
super::ty::ConstantKind::Unevaluated(uv) => uv.visit(visitor)?,
50+
super::ty::ConstantKind::Param(_) => {}
51+
}
5152
self.ty.visit(visitor)
5253
}
5354
}

0 commit comments

Comments
 (0)