@@ -101,31 +101,37 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
101101 ) ,
102102 ExprKind :: Become { value } => {
103103 let v = & this. thir [ value] ;
104- let ExprKind :: Scope { value, .. } = v. kind
104+ let ExprKind :: Scope { region_scope , lint_level , value, .. } = v. kind
105105 else { span_bug ! ( v. span, "`thir_check_tail_calls` should have disallowed this {v:?}" ) } ;
106106
107107 let v = & this. thir [ value] ;
108108 let ExprKind :: Call { ref args, fun, fn_span, .. } = v. kind
109109 else { span_bug ! ( v. span, "`thir_check_tail_calls` should have disallowed this {v:?}" ) } ;
110110
111- let fun = unpack ! ( block = this. as_local_operand( block, & this. thir[ fun] ) ) ;
112- let args: Vec < _ > = args
113- . into_iter ( )
114- . copied ( )
115- . map ( |arg| unpack ! ( block = this. as_local_call_operand( block, & this. thir[ arg] ) ) )
116- . collect ( ) ;
111+ this. in_scope ( ( region_scope, source_info) , lint_level, |this| {
112+ let fun = unpack ! ( block = this. as_local_operand( block, & this. thir[ fun] ) ) ;
113+ let args: Vec < _ > = args
114+ . into_iter ( )
115+ . copied ( )
116+ . map ( |arg| {
117+ unpack ! ( block = this. as_local_call_operand( block, & this. thir[ arg] ) )
118+ } )
119+ . collect ( ) ;
117120
118- this. record_operands_moved ( & args) ;
121+ this. record_operands_moved ( & args) ;
119122
120- debug ! ( "expr_into_dest: fn_span={:?}" , fn_span) ;
123+ debug ! ( "expr_into_dest: fn_span={:?}" , fn_span) ;
121124
122- this. cfg . terminate (
123- block,
124- source_info,
125- TerminatorKind :: TailCall { func : fun, args, fn_span } ,
126- ) ;
125+ unpack ! ( block = this. break_for_tail_call( block) ) ;
127126
128- this. cfg . start_new_block ( ) . unit ( )
127+ this. cfg . terminate (
128+ block,
129+ source_info,
130+ TerminatorKind :: TailCall { func : fun, args, fn_span } ,
131+ ) ;
132+
133+ this. cfg . start_new_block ( ) . unit ( )
134+ } )
129135 }
130136 _ => {
131137 assert ! (
0 commit comments