Skip to content

Commit 42eccff

Browse files
committed
Add Uint ty to SMIR
1 parent 458ead4 commit 42eccff

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

compiler/rustc_smir/src/rustc_smir/mod.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//!
88
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
99
10-
use crate::stable_mir::ty::{IntTy, RigidTy, TyKind};
10+
use crate::stable_mir::ty::{IntTy, RigidTy, TyKind, UintTy};
1111
use crate::stable_mir::{self, Context};
1212
use rustc_middle::mir;
1313
use rustc_middle::ty::{self, Ty, TyCtxt};
@@ -80,7 +80,14 @@ impl<'tcx> Tables<'tcx> {
8080
ty::IntTy::I64 => TyKind::RigidTy(RigidTy::Int(IntTy::I64)),
8181
ty::IntTy::I128 => TyKind::RigidTy(RigidTy::Int(IntTy::I128)),
8282
},
83-
ty::Uint(_) => todo!(),
83+
ty::Uint(uint_ty) => match uint_ty {
84+
ty::UintTy::Usize => TyKind::RigidTy(RigidTy::Uint(stable_mir::ty::UintTy::Usize)),
85+
ty::UintTy::U8 => TyKind::RigidTy(RigidTy::Uint(UintTy::U8)),
86+
ty::UintTy::U16 => TyKind::RigidTy(RigidTy::Uint(UintTy::U16)),
87+
ty::UintTy::U32 => TyKind::RigidTy(RigidTy::Uint(UintTy::U32)),
88+
ty::UintTy::U64 => TyKind::RigidTy(RigidTy::Uint(UintTy::U64)),
89+
ty::UintTy::U128 => TyKind::RigidTy(RigidTy::Uint(UintTy::U128)),
90+
},
8491
ty::Float(_) => todo!(),
8592
ty::Adt(_, _) => todo!(),
8693
ty::Foreign(_) => todo!(),

compiler/rustc_smir/src/stable_mir/ty.rs

+11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub enum RigidTy {
1919
Bool,
2020
Char,
2121
Int(IntTy),
22+
Uint(UintTy),
2223
Tuple(Vec<Ty>),
2324
}
2425

@@ -31,3 +32,13 @@ pub enum IntTy {
3132
I64,
3233
I128,
3334
}
35+
36+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
37+
pub enum UintTy {
38+
Usize,
39+
U8,
40+
U16,
41+
U32,
42+
U64,
43+
U128,
44+
}

tests/ui-fulldeps/stable-mir/crate-info.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
6767

6868
let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap();
6969
let body = types.body();
70-
assert_eq!(body.locals.len(), 4);
70+
assert_eq!(body.locals.len(), 5);
7171
assert_matches!(
7272
body.locals[0].kind(),
7373
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
@@ -84,6 +84,10 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
8484
body.locals[3].kind(),
8585
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32))
8686
);
87+
assert_matches!(
88+
body.locals[4].kind(),
89+
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64))
90+
);
8791

8892
let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap();
8993
let body = drop.body();
@@ -175,7 +179,7 @@ fn generate_input(path: &str) -> std::io::Result<()> {
175179
x_64.wrapping_add(y_64)
176180
}}
177181
178-
pub fn types(b: bool, _: char, _: i32) -> bool {{
182+
pub fn types(b: bool, _: char, _: i32, _: u64) -> bool {{
179183
b
180184
}}
181185

0 commit comments

Comments
 (0)