Skip to content

Commit 98d26d9

Browse files
committed
Deopaquify ParamConst
1 parent 627fa80 commit 98d26d9

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
@@ -1129,7 +1129,7 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
11291129
tables,
11301130
))
11311131
}
1132-
ty::ParamCt(param) => stable_mir::ty::ConstantKind::ParamCt(opaque(&param)),
1132+
ty::ParamCt(param) => stable_mir::ty::ConstantKind::Param(param.stable(tables)),
11331133
ty::ErrorCt(_) => unreachable!(),
11341134
ty::InferCt(_) => unreachable!(),
11351135
ty::BoundCt(_, _) => unimplemented!(),
@@ -1148,6 +1148,14 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
11481148
}
11491149
}
11501150

1151+
impl<'tcx> Stable<'tcx> for ty::ParamConst {
1152+
type T = stable_mir::ty::ParamConst;
1153+
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
1154+
use stable_mir::ty::ParamConst;
1155+
ParamConst { index: self.index, name: self.name.to_string() }
1156+
}
1157+
}
1158+
11511159
impl<'tcx> Stable<'tcx> for ty::ParamTy {
11521160
type T = stable_mir::ty::ParamTy;
11531161
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)