Skip to content

Commit bad1ac2

Browse files
celinvaloli-obk
authored andcommitted
Fix tests after nightly breaking changes
1 parent f0f892f commit bad1ac2

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-->
88
![project group status: active](https://img.shields.io/badge/status-active-brightgreen.svg)
99
[![project group documentation](https://img.shields.io/badge/MDBook-View%20Documentation-blue)][gh-pages]
10+
[![Run compiler tests](https://github.com/rust-lang/project-stable-mir/actions/workflows/nightly.yml/badge.svg)](https://github.com/rust-lang/project-stable-mir/actions/workflows/nightly.yml)
1011

1112

1213
<!--
@@ -47,4 +48,3 @@ yourself over there and ask us any questions you have.
4748
[open issues]: https://github.com/rust-lang/project-stable-mir/issues
4849
[chat-link]: https://rust-lang.zulipchat.com/#narrow/stream/320896-project-stable-mir
4950
[team-toml]: https://github.com/rust-lang/team/blob/master/teams/project-stable-mir.toml
50-

tools/test-drive/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ mod sanity_checks;
88

99
extern crate rustc_middle;
1010
extern crate rustc_smir;
11+
extern crate stable_mir;
1112

1213
use rustc_middle::ty::TyCtxt;
1314
use rustc_smir::rustc_internal;
14-
use rustc_smir::stable_mir::CompilerError;
15+
use stable_mir::CompilerError;
1516
use std::ops::ControlFlow;
1617
use std::panic::{catch_unwind, AssertUnwindSafe};
1718
use std::process::ExitCode;

tools/test-drive/src/sanity_checks.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! These checks should only depend on StableMIR APIs. See other modules for tests that compare
55
//! the result between StableMIR and internal APIs.
66
use crate::TestResult;
7-
use rustc_smir::stable_mir;
7+
use stable_mir;
88
use std::fmt::Debug;
99
use std::hint::black_box;
1010

@@ -83,34 +83,32 @@ pub fn test_traits() -> TestResult {
8383

8484
pub fn test_crates() -> TestResult {
8585
for krate in stable_mir::external_crates() {
86-
check_equal(
87-
stable_mir::find_crate(&krate.name.as_str()),
88-
Some(krate),
89-
"external crate mismatch",
86+
check(
87+
stable_mir::find_crates(&krate.name.as_str()).contains(&krate),
88+
format!("Cannot find {krate:?}"),
9089
)?;
9190
}
9291

9392
let local = stable_mir::local_crate();
94-
check_equal(
95-
stable_mir::find_crate(&local.name.as_str()),
96-
Some(local),
97-
"local crate mismatch",
93+
check(
94+
stable_mir::find_crates(&local.name.as_str()).contains(&local),
95+
format!("Cannot find {local:?}"),
9896
)
9997
}
10098

10199
/// Visit all local types, statements and terminator to ensure nothing crashes.
102100
fn check_body(body: stable_mir::mir::Body) {
103101
for bb in body.blocks {
104-
for stmt in bb.statements {
105-
black_box(matches!(stmt, stable_mir::mir::Statement::Assign(..)));
102+
for stable_mir::mir::Statement { kind, .. } in bb.statements {
103+
black_box(matches!(kind, stable_mir::mir::StatementKind::Assign(..)));
106104
}
107105
black_box(matches!(
108-
bb.terminator,
109-
stable_mir::mir::Terminator::Goto { .. }
106+
bb.terminator.kind,
107+
stable_mir::mir::TerminatorKind::Goto { .. }
110108
));
111109
}
112110

113111
for local in body.locals {
114-
black_box(matches!(local.kind(), stable_mir::ty::TyKind::Alias(..)));
112+
black_box(matches!(local.ty.kind(), stable_mir::ty::TyKind::Alias(..)));
115113
}
116114
}

0 commit comments

Comments
 (0)