@@ -101,7 +101,8 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
101
101
. iter ( )
102
102
. flat_map ( |x| x. switch_targets . iter ( ) . map ( |x| ( x. 0 , x. 1 ) ) ) ;
103
103
104
- let targets = SwitchTargets :: new ( new_targets, first_switch_info. otherwise_bb ) ;
104
+ let targets =
105
+ SwitchTargets :: new ( new_targets, first_switch_info. switch_targets . otherwise ( ) ) ;
105
106
106
107
// new block that jumps to the correct discriminant case. This block is switched to if the discriminants are equal
107
108
let new_switch_data = BasicBlockData :: new ( Some ( Terminator {
@@ -118,7 +119,7 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
118
119
119
120
// switch on the NotEqual. If true, then jump to the `otherwise` case.
120
121
// If false, then jump to a basic block that then jumps to the correct disciminant case
121
- let true_case = first_switch_info. otherwise_bb ;
122
+ let true_case = first_switch_info. switch_targets . otherwise ( ) ;
122
123
let false_case = new_switch_bb;
123
124
patch. patch_terminator (
124
125
opt_to_apply. basic_block_first_switch ,
@@ -171,8 +172,6 @@ struct Helper<'a, 'tcx> {
171
172
struct SwitchDiscriminantInfo < ' tcx > {
172
173
/// Type of the discriminant being switched on
173
174
discr_ty : Ty < ' tcx > ,
174
- /// The basic block that the otherwise branch points to
175
- otherwise_bb : BasicBlock ,
176
175
/// Targets and values for the switch
177
176
switch_targets : SwitchTargets ,
178
177
discr_source_info : SourceInfo ,
@@ -232,7 +231,9 @@ impl<'a, 'tcx> Helper<'a, 'tcx> {
232
231
let this_bb_discr_info = self . find_switch_discriminant_info ( bb, terminator) ?;
233
232
234
233
// The otherwise branch of the two switches have to point to the same bb
235
- if discr_info. otherwise_bb != this_bb_discr_info. otherwise_bb {
234
+ if discr_info. switch_targets . otherwise ( )
235
+ != this_bb_discr_info. switch_targets . otherwise ( )
236
+ {
236
237
trace ! ( "NO: otherwise target is not the same" ) ;
237
238
return None ;
238
239
}
@@ -287,7 +288,6 @@ impl<'a, 'tcx> Helper<'a, 'tcx> {
287
288
// the declaration of the discriminant read. Place of this read is being used in the switch
288
289
let discr_decl = & self . body . local_decls ( ) [ discr_local] ;
289
290
let discr_ty = discr_decl. ty ;
290
- let otherwise_bb = targets. otherwise ( ) ;
291
291
let targets_with_values = targets. clone ( ) ;
292
292
293
293
// find the place of the adt where the discriminant is being read from
@@ -304,7 +304,6 @@ impl<'a, 'tcx> Helper<'a, 'tcx> {
304
304
Some ( SwitchDiscriminantInfo {
305
305
discr_used_in_switch : discr. place ( ) ?,
306
306
discr_ty,
307
- otherwise_bb,
308
307
switch_targets : targets_with_values,
309
308
discr_source_info : discr_decl. source_info ,
310
309
place_of_adt_discr_read,
0 commit comments