From 284df9fc34ffb5d1e746c31902cbd1982144b45b Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 28 Jun 2023 11:31:28 -0300 Subject: [PATCH] Wrap SMIR bool and tuple into a Rigid variant --- compiler/rustc_smir/src/rustc_smir/mod.rs | 11 ++++++----- compiler/rustc_smir/src/stable_mir/ty.rs | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 874e34bef60..76cb8386618 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -7,7 +7,8 @@ //! //! For now, we are developing everything inside `rustc`, thus, we keep this module private. -use crate::stable_mir::{self, ty::TyKind, Context}; +use crate::stable_mir::ty::{RigidTy, TyKind}; +use crate::stable_mir::{self, Context}; use rustc_middle::mir; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE}; @@ -69,7 +70,7 @@ pub struct Tables<'tcx> { impl<'tcx> Tables<'tcx> { fn rustc_ty_to_ty(&mut self, ty: Ty<'tcx>) -> TyKind { match ty.kind() { - ty::Bool => TyKind::Bool, + ty::Bool => TyKind::RigidTy(RigidTy::Bool), ty::Char => todo!(), ty::Int(_) => todo!(), ty::Uint(_) => todo!(), @@ -90,9 +91,9 @@ fn rustc_ty_to_ty(&mut self, ty: Ty<'tcx>) -> TyKind { ty::GeneratorWitness(_) => todo!(), ty::GeneratorWitnessMIR(_, _) => todo!(), ty::Never => todo!(), - ty::Tuple(fields) => { - TyKind::Tuple(fields.iter().map(|ty| self.intern_ty(ty)).collect()) - } + ty::Tuple(fields) => TyKind::RigidTy(RigidTy::Tuple( + fields.iter().map(|ty| self.intern_ty(ty)).collect(), + )), ty::Alias(_, _) => todo!(), ty::Param(_) => todo!(), ty::Bound(_, _) => todo!(), diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index f27801b0f6c..d9d858ebe08 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -10,6 +10,10 @@ pub fn kind(&self) -> TyKind { } pub enum TyKind { + RigidTy(RigidTy), +} + +pub enum RigidTy { Bool, Tuple(Vec), }