diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 3a66eefdb79..d2b13c32cc2 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -7,7 +7,7 @@ //! //! For now, we are developing everything inside `rustc`, thus, we keep this module private. -use crate::stable_mir::ty::{RigidTy, TyKind}; +use crate::stable_mir::ty::{IntTy, RigidTy, TyKind}; use crate::stable_mir::{self, Context}; use rustc_middle::mir; use rustc_middle::ty::{self, Ty, TyCtxt}; @@ -72,7 +72,14 @@ impl<'tcx> Tables<'tcx> { match ty.kind() { ty::Bool => TyKind::RigidTy(RigidTy::Bool), ty::Char => TyKind::RigidTy(RigidTy::Char), - ty::Int(_) => todo!(), + ty::Int(int_ty) => match int_ty { + ty::IntTy::Isize => TyKind::RigidTy(RigidTy::Int(IntTy::Isize)), + ty::IntTy::I8 => TyKind::RigidTy(RigidTy::Int(IntTy::I8)), + ty::IntTy::I16 => TyKind::RigidTy(RigidTy::Int(IntTy::I16)), + ty::IntTy::I32 => TyKind::RigidTy(RigidTy::Int(IntTy::I32)), + ty::IntTy::I64 => TyKind::RigidTy(RigidTy::Int(IntTy::I64)), + ty::IntTy::I128 => TyKind::RigidTy(RigidTy::Int(IntTy::I128)), + }, ty::Uint(_) => todo!(), ty::Float(_) => todo!(), ty::Adt(_, _) => todo!(), diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index 936fb0d3e4f..f31c078b4ab 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -18,5 +18,16 @@ pub enum TyKind { pub enum RigidTy { Bool, Char, + Int(IntTy), Tuple(Vec), } + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum IntTy { + Isize, + I8, + I16, + I32, + I64, + I128, +} diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index e3b4f6e7df9..8ac32d23c6f 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -67,7 +67,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap(); let body = types.body(); - assert_eq!(body.locals.len(), 3); + assert_eq!(body.locals.len(), 4); assert_matches!( body.locals[0].kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) @@ -80,6 +80,10 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { body.locals[2].kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char) ); + assert_matches!( + body.locals[3].kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32)) + ); let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap(); let body = drop.body(); @@ -171,7 +175,7 @@ fn generate_input(path: &str) -> std::io::Result<()> { x_64.wrapping_add(y_64) }} - pub fn types(b: bool, _: char) -> bool {{ + pub fn types(b: bool, _: char, _: i32) -> bool {{ b }}