summaryrefslogtreecommitdiffstats
path: root/tests/ui-fulldeps/stable-mir
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui-fulldeps/stable-mir')
-rw-r--r--tests/ui-fulldeps/stable-mir/crate-info.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs
index a3db2e9ef..f55d7d599 100644
--- a/tests/ui-fulldeps/stable-mir/crate-info.rs
+++ b/tests/ui-fulldeps/stable-mir/crate-info.rs
@@ -7,18 +7,22 @@
// edition: 2021
#![feature(rustc_private)]
+#![feature(assert_matches)]
extern crate rustc_driver;
extern crate rustc_hir;
extern crate rustc_interface;
extern crate rustc_middle;
+extern crate rustc_session;
extern crate rustc_smir;
use rustc_driver::{Callbacks, Compilation, RunCompiler};
use rustc_hir::def::DefKind;
use rustc_interface::{interface, Queries};
use rustc_middle::ty::TyCtxt;
+use rustc_session::EarlyErrorHandler;
use rustc_smir::{rustc_internal, stable_mir};
+use std::assert_matches::assert_matches;
use std::io::Write;
const CRATE_NAME: &str = "input";
@@ -63,6 +67,36 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
other => panic!("{other:?}"),
}
+ let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap();
+ let body = types.body();
+ assert_eq!(body.locals.len(), 6);
+ 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)
+ );
+ assert_matches!(
+ 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))
+ );
+ assert_matches!(
+ body.locals[4].kind(),
+ stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64))
+ );
+ assert_matches!(
+ body.locals[5].kind(),
+ stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Float(
+ stable_mir::ty::FloatTy::F64
+ ))
+ );
+
let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap();
let body = drop.body();
assert_eq!(body.blocks.len(), 2);
@@ -121,6 +155,7 @@ impl Callbacks for SMirCalls {
/// continue the compilation afterwards (defaults to `Compilation::Continue`)
fn after_analysis<'tcx>(
&mut self,
+ _handler: &EarlyErrorHandler,
_compiler: &interface::Compiler,
queries: &'tcx Queries<'tcx>,
) -> Compilation {
@@ -153,6 +188,10 @@ fn generate_input(path: &str) -> std::io::Result<()> {
x_64.wrapping_add(y_64)
}}
+ pub fn types(b: bool, _: char, _: i32, _: u64, _: f64) -> bool {{
+ b
+ }}
+
pub fn drop(_: String) {{}}
pub fn assert(x: i32) -> i32 {{