Skip to content

Commit d910e7d

Browse files
authored
Rollup merge of #113930 - spastorino:smir-types-6, r=oli-obk
Add Param and Bound ty to SMIR r? ``@oli-obk``
2 parents 26d791b + 7af1697 commit d910e7d

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

compiler/rustc_smir/src/rustc_smir/mod.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,10 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
825825
ty::Alias(alias_kind, alias_ty) => {
826826
TyKind::Alias(alias_kind.stable(tables), alias_ty.stable(tables))
827827
}
828-
ty::Param(_) => todo!(),
829-
ty::Bound(_, _) => todo!(),
828+
ty::Param(param_ty) => TyKind::Param(param_ty.stable(tables)),
829+
ty::Bound(debruijn_idx, bound_ty) => {
830+
TyKind::Bound(debruijn_idx.as_usize(), bound_ty.stable(tables))
831+
}
830832
ty::Placeholder(..)
831833
| ty::GeneratorWitness(_)
832834
| ty::GeneratorWitnessMIR(_, _)
@@ -837,3 +839,19 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
837839
}
838840
}
839841
}
842+
843+
impl<'tcx> Stable<'tcx> for rustc_middle::ty::ParamTy {
844+
type T = stable_mir::ty::ParamTy;
845+
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
846+
use stable_mir::ty::ParamTy;
847+
ParamTy { index: self.index, name: self.name.to_string() }
848+
}
849+
}
850+
851+
impl<'tcx> Stable<'tcx> for rustc_middle::ty::BoundTy {
852+
type T = stable_mir::ty::BoundTy;
853+
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
854+
use stable_mir::ty::BoundTy;
855+
BoundTy { var: self.var.as_usize(), kind: self.kind.stable(tables) }
856+
}
857+
}

compiler/rustc_smir/src/stable_mir/ty.rs

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type Span = Opaque;
1818
pub enum TyKind {
1919
RigidTy(RigidTy),
2020
Alias(AliasKind, AliasTy),
21+
Param(ParamTy),
22+
Bound(usize, BoundTy),
2123
}
2224

2325
#[derive(Clone, Debug)]
@@ -228,3 +230,15 @@ pub struct ExistentialProjection {
228230
pub generic_args: GenericArgs,
229231
pub term: TermKind,
230232
}
233+
234+
#[derive(Clone, Debug)]
235+
pub struct ParamTy {
236+
pub index: u32,
237+
pub name: String,
238+
}
239+
240+
#[derive(Clone, Debug)]
241+
pub struct BoundTy {
242+
pub var: usize,
243+
pub kind: BoundTyKind,
244+
}

0 commit comments

Comments
 (0)