@@ -44,6 +44,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4444 self . then_else_break_inner (
4545 block,
4646 expr,
47+ None ,
4748 temp_scope_override,
4849 break_scope,
4950 variable_source_info,
@@ -54,6 +55,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
5455 & mut self ,
5556 mut block : BasicBlock ,
5657 expr : & Expr < ' tcx > ,
58+ enclosing_not_expr : Option < & Expr < ' tcx > > , // Only used by coverage instrumentation
5759 temp_scope_override : Option < region:: Scope > ,
5860 break_scope : region:: Scope ,
5961 variable_source_info : SourceInfo ,
@@ -107,9 +109,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
107109 let local_scope = this. local_scope ( ) ;
108110 let ( success_block, failure_block) =
109111 this. in_if_then_scope ( local_scope, expr_span, |this| {
110- this. then_else_break (
112+ this. then_else_break_inner (
111113 block,
112114 & this. thir [ arg] ,
115+ Some ( expr) ,
113116 temp_scope_override,
114117 local_scope,
115118 variable_source_info,
@@ -121,9 +124,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
121124 ExprKind :: Scope { region_scope, lint_level, value } => {
122125 let region_scope = ( region_scope, this. source_info ( expr_span) ) ;
123126 this. in_scope ( region_scope, lint_level, |this| {
124- this. then_else_break (
127+ this. then_else_break_inner (
125128 block,
126129 & this. thir [ value] ,
130+ enclosing_not_expr,
127131 temp_scope_override,
128132 break_scope,
129133 variable_source_info,
@@ -162,7 +166,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
162166 if let Some ( coverage) = & this. coverage
163167 && coverage. branch_coverage_enabled
164168 {
165- this. coverage_add_branch ( source_info, & mut then_block, & mut else_block) ;
169+ this. coverage_add_branch (
170+ source_info,
171+ enclosing_not_expr,
172+ & mut then_block,
173+ & mut else_block,
174+ ) ;
166175 }
167176
168177 this. cfg . terminate ( block, source_info, term) ;
0 commit comments