Skip to content

Commit 59dcd93

Browse files
committed
use correct span for assign in a replace op
1 parent 1245c0c commit 59dcd93

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

compiler/rustc_mir_build/src/build/expr/stmt.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
3939

4040
// Generate better code for things that don't need to be
4141
// dropped.
42-
4342
let needs_drop = lhs.ty.needs_drop(this.tcx, this.param_env);
4443
let rhs = unpack!(block = this.as_local_rvalue(block, rhs));
4544
let lhs = unpack!(block = this.as_place(block, lhs));
4645
if needs_drop {
47-
unpack!(block = this.build_drop_and_replace(block, lhs_span, lhs, rhs.clone()));
46+
unpack!(
47+
block = this.build_drop_and_replace(
48+
block,
49+
source_info,
50+
lhs_span,
51+
lhs,
52+
rhs.clone()
53+
)
54+
);
4855
}
4956
this.cfg.push_assign(block, source_info, lhs, rhs);
5057
this.block_context.pop();

compiler/rustc_mir_build/src/build/scope.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
11251125
pub(crate) fn build_drop_and_replace(
11261126
&mut self,
11271127
block: BasicBlock,
1128+
statement_source_info: SourceInfo,
11281129
span: Span,
11291130
place: Place<'tcx>,
11301131
value: Rvalue<'tcx>,
@@ -1133,8 +1134,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
11331134
let next_target = self.cfg.start_new_block();
11341135

11351136
let assign = self.cfg.start_new_cleanup_block();
1136-
self.cfg.push_assign(assign, source_info, place, value.clone());
1137-
self.cfg.terminate(assign, source_info, TerminatorKind::Goto { target: block });
1137+
self.cfg.push_assign(assign, statement_source_info, place, value.clone());
1138+
self.cfg.terminate(assign, statement_source_info, TerminatorKind::Goto { target: block });
11381139

11391140
self.cfg.terminate(
11401141
block,

0 commit comments

Comments
 (0)