@@ -1141,6 +1141,7 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
1141
1141
& mut self . scopes . unwind_drops ,
1142
1142
self . fn_span ,
1143
1143
should_abort,
1144
+ & mut None ,
1144
1145
) ;
1145
1146
}
1146
1147
}
@@ -1161,8 +1162,9 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
1161
1162
}
1162
1163
1163
1164
// Build the drop tree for unwinding in the normal control flow paths.
1164
- let resume_block =
1165
- Self :: build_unwind_tree ( cfg, & mut self . scopes . unwind_drops , fn_span, should_abort) ;
1165
+ let resume_block = & mut None ;
1166
+ let unwind_drops = & mut self . scopes . unwind_drops ;
1167
+ Self :: build_unwind_tree ( cfg, unwind_drops, fn_span, should_abort, resume_block) ;
1166
1168
1167
1169
// Build the drop tree for unwinding when dropping a suspended
1168
1170
// generator.
@@ -1176,39 +1178,28 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
1176
1178
drops. entry_points . push ( ( drop_data. 1 , blocks[ drop_idx] . unwrap ( ) ) ) ;
1177
1179
}
1178
1180
}
1179
- let mut blocks = IndexVec :: from_elem ( None , & drops. drops ) ;
1180
- blocks[ ROOT_NODE ] = resume_block;
1181
- drops. build_mir :: < Unwind > ( cfg, & mut blocks) ;
1182
- if let ( None , Some ( new_resume_block) ) = ( resume_block, blocks[ ROOT_NODE ] ) {
1183
- let terminator =
1184
- if should_abort { TerminatorKind :: Abort } else { TerminatorKind :: Resume } ;
1185
- cfg. terminate (
1186
- new_resume_block,
1187
- SourceInfo { scope : OUTERMOST_SOURCE_SCOPE , span : fn_span } ,
1188
- terminator,
1189
- ) ;
1190
- }
1181
+ Self :: build_unwind_tree ( cfg, drops, fn_span, should_abort, resume_block) ;
1191
1182
}
1192
1183
1193
1184
fn build_unwind_tree (
1194
1185
cfg : & mut CFG < ' tcx > ,
1195
1186
drops : & mut DropTree ,
1196
1187
fn_span : Span ,
1197
1188
should_abort : bool ,
1198
- ) -> Option < BasicBlock > {
1189
+ resume_block : & mut Option < BasicBlock > ,
1190
+ ) {
1199
1191
let mut blocks = IndexVec :: from_elem ( None , & drops. drops ) ;
1192
+ blocks[ ROOT_NODE ] = * resume_block;
1200
1193
drops. build_mir :: < Unwind > ( cfg, & mut blocks) ;
1201
- if let Some ( resume_block ) = blocks[ ROOT_NODE ] {
1194
+ if let ( None , Some ( resume ) ) = ( * resume_block , blocks[ ROOT_NODE ] ) {
1202
1195
let terminator =
1203
1196
if should_abort { TerminatorKind :: Abort } else { TerminatorKind :: Resume } ;
1204
1197
cfg. terminate (
1205
- resume_block ,
1198
+ resume ,
1206
1199
SourceInfo { scope : OUTERMOST_SOURCE_SCOPE , span : fn_span } ,
1207
1200
terminator,
1208
1201
) ;
1209
- Some ( resume_block)
1210
- } else {
1211
- None
1202
+ * resume_block = blocks[ ROOT_NODE ] ;
1212
1203
}
1213
1204
}
1214
1205
}
0 commit comments