Skip to content

Commit bf00d20

Browse files
committed
mir: Call set_operand_dropped in more places, specifically Unsize casts.
1 parent db5490a commit bf00d20

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/librustc_trans/trans/mir/rvalue.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
5252
bcx
5353
}
5454

55-
mir::Rvalue::Cast(mir::CastKind::Unsize, ref operand, cast_ty) => {
55+
mir::Rvalue::Cast(mir::CastKind::Unsize, ref source, cast_ty) => {
5656
if common::type_is_fat_ptr(bcx.tcx(), cast_ty) {
5757
// into-coerce of a thin pointer to a fat pointer - just
5858
// use the operand path.
@@ -65,7 +65,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
6565
// this to be eliminated by MIR translation, but
6666
// `CoerceUnsized` can be passed by a where-clause,
6767
// so the (generic) MIR may not be able to expand it.
68-
let operand = self.trans_operand(&bcx, operand);
68+
let operand = self.trans_operand(&bcx, source);
6969
bcx.with_block(|bcx| {
7070
match operand.val {
7171
OperandValue::FatPtr(..) => unreachable!(),
@@ -90,6 +90,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
9090
}
9191
}
9292
});
93+
self.set_operand_dropped(&bcx, source);
9394
bcx
9495
}
9596

@@ -124,8 +125,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
124125
adt::trans_field_ptr(bcx, &repr, val, disr, i)
125126
});
126127
self.store_operand(&bcx, lldest_i, op);
127-
self.set_operand_dropped(&bcx, operand);
128128
}
129+
self.set_operand_dropped(&bcx, operand);
129130
}
130131
},
131132
_ => {
@@ -163,8 +164,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
163164
// not be structs but arrays.
164165
let dest = bcx.gepi(dest.llval, &[0, i]);
165166
self.store_operand(&bcx, dest, op);
166-
self.set_operand_dropped(&bcx, operand);
167167
}
168+
self.set_operand_dropped(&bcx, operand);
168169
}
169170
}
170171
}
@@ -213,8 +214,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
213214
assert!(rvalue_creates_operand(rvalue), "cannot trans {:?} to operand", rvalue);
214215

215216
match *rvalue {
216-
mir::Rvalue::Cast(ref kind, ref operand, cast_ty) => {
217-
let operand = self.trans_operand(&bcx, operand);
217+
mir::Rvalue::Cast(ref kind, ref source, cast_ty) => {
218+
let operand = self.trans_operand(&bcx, source);
218219
debug!("cast operand is {:?}", operand);
219220
let cast_ty = bcx.monomorphize(&cast_ty);
220221

@@ -247,6 +248,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
247248
// example,
248249
// &'a fmt::Debug+Send => &'a fmt::Debug,
249250
// and is a no-op at the LLVM level
251+
self.set_operand_dropped(&bcx, source);
250252
operand.val
251253
}
252254
OperandValue::Immediate(lldata) => {
@@ -255,6 +257,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
255257
base::unsize_thin_ptr(bcx, lldata,
256258
operand.ty, cast_ty)
257259
});
260+
self.set_operand_dropped(&bcx, source);
258261
OperandValue::FatPtr(lldata, llextra)
259262
}
260263
OperandValue::Ref(_) => {

0 commit comments

Comments
 (0)