Skip to content

Commit 61adcaf

Browse files
committed
Add rustc_ty_to_ty basic tests
1 parent 284df9f commit 61adcaf

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

compiler/rustc_smir/src/stable_mir/ty.rs

+2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ impl Ty {
99
}
1010
}
1111

12+
#[derive(Clone, Debug)]
1213
pub enum TyKind {
1314
RigidTy(RigidTy),
1415
}
1516

17+
#[derive(Clone, Debug)]
1618
pub enum RigidTy {
1719
Bool,
1820
Tuple(Vec<Ty>),

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

+18
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// edition: 2021
88

99
#![feature(rustc_private)]
10+
#![feature(assert_matches)]
1011

1112
extern crate rustc_driver;
1213
extern crate rustc_hir;
@@ -19,6 +20,7 @@ use rustc_hir::def::DefKind;
1920
use rustc_interface::{interface, Queries};
2021
use rustc_middle::ty::TyCtxt;
2122
use rustc_smir::{rustc_internal, stable_mir};
23+
use std::assert_matches::assert_matches;
2224
use std::io::Write;
2325

2426
const CRATE_NAME: &str = "input";
@@ -63,6 +65,18 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
6365
other => panic!("{other:?}"),
6466
}
6567

68+
let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap();
69+
let body = types.body();
70+
assert_eq!(body.locals.len(), 2);
71+
assert_matches!(
72+
body.locals[0].kind(),
73+
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
74+
);
75+
assert_matches!(
76+
body.locals[1].kind(),
77+
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
78+
);
79+
6680
let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap();
6781
let body = drop.body();
6882
assert_eq!(body.blocks.len(), 2);
@@ -153,6 +167,10 @@ fn generate_input(path: &str) -> std::io::Result<()> {
153167
x_64.wrapping_add(y_64)
154168
}}
155169
170+
pub fn types(b: bool) -> bool {{
171+
b
172+
}}
173+
156174
pub fn drop(_: String) {{}}
157175
158176
pub fn assert(x: i32) -> i32 {{

0 commit comments

Comments
 (0)