Skip to content

Commit 16849ae

Browse files
celinvaloli-obk
authored andcommitted
Adjust test driver due to breaking changes
1 parent fd9ce75 commit 16849ae

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

tools/test-drive/src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
mod sanity_checks;
88

9+
extern crate rustc_driver;
10+
extern crate rustc_interface;
911
extern crate rustc_middle;
1012
extern crate rustc_smir;
1113
extern crate stable_mir;
1214

1315
use rustc_middle::ty::TyCtxt;
14-
use rustc_smir::rustc_internal;
16+
use rustc_smir::{run, rustc_internal};
1517
use stable_mir::CompilerError;
1618
use std::ops::ControlFlow;
1719
use std::panic::{catch_unwind, AssertUnwindSafe};
@@ -39,7 +41,7 @@ type TestResult = Result<(), String>;
3941
fn main() -> ExitCode {
4042
let args = std::env::args();
4143
let (smir_args, rustc_args): (Vec<String>, _) = args.partition(|arg| arg.starts_with("--smir"));
42-
let callback = if smir_args.contains(&CHECK_ARG.to_string()) {
44+
let result = if smir_args.contains(&CHECK_ARG.to_string()) {
4345
VERBOSE.store(
4446
smir_args.contains(&VERBOSE_ARG.to_string()),
4547
Ordering::Relaxed,
@@ -48,11 +50,10 @@ fn main() -> ExitCode {
4850
smir_args.contains(&FIXME_ARG.to_string()),
4951
Ordering::Relaxed,
5052
);
51-
test_stable_mir
53+
run!(rustc_args, tcx, test_stable_mir(tcx))
5254
} else {
53-
|_: TyCtxt| ControlFlow::<()>::Continue(())
55+
run!(rustc_args, ControlFlow::<()>::Continue(()))
5456
};
55-
let result = rustc_internal::StableMir::new(rustc_args, callback).run();
5657
if result.is_ok() || matches!(result, Err(CompilerError::Skipped)) {
5758
ExitCode::SUCCESS
5859
} else {

tools/test-drive/src/sanity_checks.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ pub fn test_crates() -> TestResult {
9898

9999
/// Visit all local types, statements and terminator to ensure nothing crashes.
100100
fn check_body(body: stable_mir::mir::Body) {
101-
for bb in body.blocks {
102-
for stable_mir::mir::Statement { kind, .. } in bb.statements {
101+
for bb in &body.blocks {
102+
for stable_mir::mir::Statement { kind, .. } in &bb.statements {
103103
black_box(matches!(kind, stable_mir::mir::StatementKind::Assign(..)));
104104
}
105105
black_box(matches!(
@@ -108,7 +108,7 @@ fn check_body(body: stable_mir::mir::Body) {
108108
));
109109
}
110110

111-
for local in body.locals {
111+
for local in body.locals() {
112112
black_box(matches!(local.ty.kind(), stable_mir::ty::TyKind::Alias(..)));
113113
}
114114
}

0 commit comments

Comments
 (0)