|
4 | 4 | //! These checks should only depend on StableMIR APIs. See other modules for tests that compare
|
5 | 5 | //! the result between StableMIR and internal APIs.
|
6 | 6 | use crate::TestResult;
|
7 |
| -use rustc_smir::stable_mir; |
| 7 | +use stable_mir; |
8 | 8 | use std::fmt::Debug;
|
9 | 9 | use std::hint::black_box;
|
10 | 10 |
|
@@ -83,34 +83,32 @@ pub fn test_traits() -> TestResult {
|
83 | 83 |
|
84 | 84 | pub fn test_crates() -> TestResult {
|
85 | 85 | 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:?}"), |
90 | 89 | )?;
|
91 | 90 | }
|
92 | 91 |
|
93 | 92 | 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:?}"), |
98 | 96 | )
|
99 | 97 | }
|
100 | 98 |
|
101 | 99 | /// Visit all local types, statements and terminator to ensure nothing crashes.
|
102 | 100 | fn check_body(body: stable_mir::mir::Body) {
|
103 | 101 | 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(..))); |
106 | 104 | }
|
107 | 105 | black_box(matches!(
|
108 |
| - bb.terminator, |
109 |
| - stable_mir::mir::Terminator::Goto { .. } |
| 106 | + bb.terminator.kind, |
| 107 | + stable_mir::mir::TerminatorKind::Goto { .. } |
110 | 108 | ));
|
111 | 109 | }
|
112 | 110 |
|
113 | 111 | 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(..))); |
115 | 113 | }
|
116 | 114 | }
|
0 commit comments