Skip to content

Commit

Permalink
Add Bound ty to SMIR
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Jul 26, 2023
1 parent 648cf07 commit 7af1697
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion compiler/rustc_smir/src/rustc_smir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,9 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
TyKind::Alias(alias_kind.stable(tables), alias_ty.stable(tables))
}
ty::Param(param_ty) => TyKind::Param(param_ty.stable(tables)),
ty::Bound(_, _) => todo!(),
ty::Bound(debruijn_idx, bound_ty) => {
TyKind::Bound(debruijn_idx.as_usize(), bound_ty.stable(tables))
}
ty::Placeholder(..)
| ty::GeneratorWitness(_)
| ty::GeneratorWitnessMIR(_, _)
Expand All @@ -845,3 +847,11 @@ impl<'tcx> Stable<'tcx> for rustc_middle::ty::ParamTy {
ParamTy { index: self.index, name: self.name.to_string() }
}
}

impl<'tcx> Stable<'tcx> for rustc_middle::ty::BoundTy {
type T = stable_mir::ty::BoundTy;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use stable_mir::ty::BoundTy;
BoundTy { var: self.var.as_usize(), kind: self.kind.stable(tables) }
}
}
7 changes: 7 additions & 0 deletions compiler/rustc_smir/src/stable_mir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub enum TyKind {
RigidTy(RigidTy),
Alias(AliasKind, AliasTy),
Param(ParamTy),
Bound(usize, BoundTy),
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -235,3 +236,9 @@ pub struct ParamTy {
pub index: u32,
pub name: String,
}

#[derive(Clone, Debug)]
pub struct BoundTy {
pub var: usize,
pub kind: BoundTyKind,
}

0 comments on commit 7af1697

Please sign in to comment.