@@ -45,7 +45,7 @@ fn test_stable_mir() -> ControlFlow<()> {
45
45
assert ! ( stable_mir:: find_crates( "std" ) . len( ) == 1 ) ;
46
46
47
47
let bar = get_item ( & items, ( DefKind :: Fn , "bar" ) ) . unwrap ( ) ;
48
- let body = bar. body ( ) ;
48
+ let body = bar. expect_body ( ) ;
49
49
assert_eq ! ( body. locals( ) . len( ) , 2 ) ;
50
50
assert_eq ! ( body. blocks. len( ) , 1 ) ;
51
51
let block = & body. blocks [ 0 ] ;
@@ -60,7 +60,7 @@ fn test_stable_mir() -> ControlFlow<()> {
60
60
}
61
61
62
62
let foo_bar = get_item ( & items, ( DefKind :: Fn , "foo_bar" ) ) . unwrap ( ) ;
63
- let body = foo_bar. body ( ) ;
63
+ let body = foo_bar. expect_body ( ) ;
64
64
assert_eq ! ( body. locals( ) . len( ) , 5 ) ;
65
65
assert_eq ! ( body. blocks. len( ) , 4 ) ;
66
66
let block = & body. blocks [ 0 ] ;
@@ -70,7 +70,7 @@ fn test_stable_mir() -> ControlFlow<()> {
70
70
}
71
71
72
72
let types = get_item ( & items, ( DefKind :: Fn , "types" ) ) . unwrap ( ) ;
73
- let body = types. body ( ) ;
73
+ let body = types. expect_body ( ) ;
74
74
assert_eq ! ( body. locals( ) . len( ) , 6 ) ;
75
75
assert_matches ! (
76
76
body. locals( ) [ 0 ] . ty. kind( ) ,
@@ -100,7 +100,7 @@ fn test_stable_mir() -> ControlFlow<()> {
100
100
) ;
101
101
102
102
let drop = get_item ( & items, ( DefKind :: Fn , "drop" ) ) . unwrap ( ) ;
103
- let body = drop. body ( ) ;
103
+ let body = drop. expect_body ( ) ;
104
104
assert_eq ! ( body. blocks. len( ) , 2 ) ;
105
105
let block = & body. blocks [ 0 ] ;
106
106
match & block. terminator . kind {
@@ -109,7 +109,7 @@ fn test_stable_mir() -> ControlFlow<()> {
109
109
}
110
110
111
111
let assert = get_item ( & items, ( DefKind :: Fn , "assert" ) ) . unwrap ( ) ;
112
- let body = assert. body ( ) ;
112
+ let body = assert. expect_body ( ) ;
113
113
assert_eq ! ( body. blocks. len( ) , 2 ) ;
114
114
let block = & body. blocks [ 0 ] ;
115
115
match & block. terminator . kind {
@@ -123,7 +123,8 @@ fn test_stable_mir() -> ControlFlow<()> {
123
123
match & block. terminator . kind {
124
124
stable_mir:: mir:: TerminatorKind :: Call { func, .. } => {
125
125
let TyKind :: RigidTy ( ty) = func. ty ( & body. locals ( ) ) . unwrap ( ) . kind ( ) else {
126
- unreachable ! ( ) } ;
126
+ unreachable ! ( )
127
+ } ;
127
128
let RigidTy :: FnDef ( def, args) = ty else { unreachable ! ( ) } ;
128
129
let next_func = Instance :: resolve ( def, & args) . unwrap ( ) ;
129
130
match next_func. body ( ) . unwrap ( ) . locals ( ) [ 1 ] . ty . kind ( ) {
@@ -138,10 +139,10 @@ fn test_stable_mir() -> ControlFlow<()> {
138
139
139
140
let foo_const = get_item ( & items, ( DefKind :: Const , "FOO" ) ) . unwrap ( ) ;
140
141
// Ensure we don't panic trying to get the body of a constant.
141
- foo_const. body ( ) ;
142
+ foo_const. expect_body ( ) ;
142
143
143
144
let locals_fn = get_item ( & items, ( DefKind :: Fn , "locals" ) ) . unwrap ( ) ;
144
- let body = locals_fn. body ( ) ;
145
+ let body = locals_fn. expect_body ( ) ;
145
146
assert_eq ! ( body. locals( ) . len( ) , 4 ) ;
146
147
assert_matches ! (
147
148
body. ret_local( ) . ty. kind( ) ,
@@ -172,8 +173,10 @@ fn get_item<'a>(
172
173
item : ( DefKind , & str ) ,
173
174
) -> Option < & ' a stable_mir:: CrateItem > {
174
175
items. iter ( ) . find ( |crate_item| {
175
- matches ! ( ( item. 0 , crate_item. kind( ) ) , ( DefKind :: Fn , ItemKind :: Fn ) | ( DefKind :: Const ,
176
- ItemKind :: Const ) ) && crate_item. name ( ) == item. 1
176
+ matches ! (
177
+ ( item. 0 , crate_item. kind( ) ) ,
178
+ ( DefKind :: Fn , ItemKind :: Fn ) | ( DefKind :: Const , ItemKind :: Const )
179
+ ) && crate_item. name ( ) == item. 1
177
180
} )
178
181
}
179
182
0 commit comments