mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Add rustc_ty_to_ty basic tests
This commit is contained in:
parent
284df9fc34
commit
61adcaf87b
@ -9,10 +9,12 @@ impl Ty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
pub enum TyKind {
|
pub enum TyKind {
|
||||||
RigidTy(RigidTy),
|
RigidTy(RigidTy),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
pub enum RigidTy {
|
pub enum RigidTy {
|
||||||
Bool,
|
Bool,
|
||||||
Tuple(Vec<Ty>),
|
Tuple(Vec<Ty>),
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
// edition: 2021
|
// edition: 2021
|
||||||
|
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
|
#![feature(assert_matches)]
|
||||||
|
|
||||||
extern crate rustc_driver;
|
extern crate rustc_driver;
|
||||||
extern crate rustc_hir;
|
extern crate rustc_hir;
|
||||||
@ -19,6 +20,7 @@ use rustc_hir::def::DefKind;
|
|||||||
use rustc_interface::{interface, Queries};
|
use rustc_interface::{interface, Queries};
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_smir::{rustc_internal, stable_mir};
|
use rustc_smir::{rustc_internal, stable_mir};
|
||||||
|
use std::assert_matches::assert_matches;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
const CRATE_NAME: &str = "input";
|
const CRATE_NAME: &str = "input";
|
||||||
@ -63,6 +65,18 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
|
|||||||
other => panic!("{other:?}"),
|
other => panic!("{other:?}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap();
|
||||||
|
let body = types.body();
|
||||||
|
assert_eq!(body.locals.len(), 2);
|
||||||
|
assert_matches!(
|
||||||
|
body.locals[0].kind(),
|
||||||
|
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
|
||||||
|
);
|
||||||
|
assert_matches!(
|
||||||
|
body.locals[1].kind(),
|
||||||
|
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
|
||||||
|
);
|
||||||
|
|
||||||
let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap();
|
let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap();
|
||||||
let body = drop.body();
|
let body = drop.body();
|
||||||
assert_eq!(body.blocks.len(), 2);
|
assert_eq!(body.blocks.len(), 2);
|
||||||
@ -153,6 +167,10 @@ fn generate_input(path: &str) -> std::io::Result<()> {
|
|||||||
x_64.wrapping_add(y_64)
|
x_64.wrapping_add(y_64)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
pub fn types(b: bool) -> bool {{
|
||||||
|
b
|
||||||
|
}}
|
||||||
|
|
||||||
pub fn drop(_: String) {{}}
|
pub fn drop(_: String) {{}}
|
||||||
|
|
||||||
pub fn assert(x: i32) -> i32 {{
|
pub fn assert(x: i32) -> i32 {{
|
||||||
|
Loading…
Reference in New Issue
Block a user