mir: Call set_operand_dropped in more places, specifically Unsize casts.
This commit is contained in:
parent
3e98220a1c
commit
82fad1dfc7
@ -54,7 +54,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||||||
bcx
|
bcx
|
||||||
}
|
}
|
||||||
|
|
||||||
mir::Rvalue::Cast(mir::CastKind::Unsize, ref operand, cast_ty) => {
|
mir::Rvalue::Cast(mir::CastKind::Unsize, ref source, cast_ty) => {
|
||||||
if common::type_is_fat_ptr(bcx.tcx(), cast_ty) {
|
if common::type_is_fat_ptr(bcx.tcx(), cast_ty) {
|
||||||
// into-coerce of a thin pointer to a fat pointer - just
|
// into-coerce of a thin pointer to a fat pointer - just
|
||||||
// use the operand path.
|
// use the operand path.
|
||||||
@ -67,7 +67,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||||||
// this to be eliminated by MIR translation, but
|
// this to be eliminated by MIR translation, but
|
||||||
// `CoerceUnsized` can be passed by a where-clause,
|
// `CoerceUnsized` can be passed by a where-clause,
|
||||||
// so the (generic) MIR may not be able to expand it.
|
// so the (generic) MIR may not be able to expand it.
|
||||||
let operand = self.trans_operand(&bcx, operand);
|
let operand = self.trans_operand(&bcx, source);
|
||||||
bcx.with_block(|bcx| {
|
bcx.with_block(|bcx| {
|
||||||
match operand.val {
|
match operand.val {
|
||||||
OperandValue::FatPtr(..) => unreachable!(),
|
OperandValue::FatPtr(..) => unreachable!(),
|
||||||
@ -92,6 +92,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
self.set_operand_dropped(&bcx, source);
|
||||||
bcx
|
bcx
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +128,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||||||
adt::trans_field_ptr(bcx, &repr, val, disr, i)
|
adt::trans_field_ptr(bcx, &repr, val, disr, i)
|
||||||
});
|
});
|
||||||
self.store_operand(&bcx, lldest_i, op);
|
self.store_operand(&bcx, lldest_i, op);
|
||||||
self.set_operand_dropped(&bcx, operand);
|
|
||||||
}
|
}
|
||||||
|
self.set_operand_dropped(&bcx, operand);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
@ -166,8 +167,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||||||
// not be structs but arrays.
|
// not be structs but arrays.
|
||||||
let dest = bcx.gepi(dest.llval, &[0, i]);
|
let dest = bcx.gepi(dest.llval, &[0, i]);
|
||||||
self.store_operand(&bcx, dest, op);
|
self.store_operand(&bcx, dest, op);
|
||||||
self.set_operand_dropped(&bcx, operand);
|
|
||||||
}
|
}
|
||||||
|
self.set_operand_dropped(&bcx, operand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,8 +217,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||||||
assert!(rvalue_creates_operand(rvalue), "cannot trans {:?} to operand", rvalue);
|
assert!(rvalue_creates_operand(rvalue), "cannot trans {:?} to operand", rvalue);
|
||||||
|
|
||||||
match *rvalue {
|
match *rvalue {
|
||||||
mir::Rvalue::Cast(ref kind, ref operand, cast_ty) => {
|
mir::Rvalue::Cast(ref kind, ref source, cast_ty) => {
|
||||||
let operand = self.trans_operand(&bcx, operand);
|
let operand = self.trans_operand(&bcx, source);
|
||||||
debug!("cast operand is {:?}", operand);
|
debug!("cast operand is {:?}", operand);
|
||||||
let cast_ty = bcx.monomorphize(&cast_ty);
|
let cast_ty = bcx.monomorphize(&cast_ty);
|
||||||
|
|
||||||
@ -250,6 +251,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||||||
// example,
|
// example,
|
||||||
// &'a fmt::Debug+Send => &'a fmt::Debug,
|
// &'a fmt::Debug+Send => &'a fmt::Debug,
|
||||||
// and is a no-op at the LLVM level
|
// and is a no-op at the LLVM level
|
||||||
|
self.set_operand_dropped(&bcx, source);
|
||||||
operand.val
|
operand.val
|
||||||
}
|
}
|
||||||
OperandValue::Immediate(lldata) => {
|
OperandValue::Immediate(lldata) => {
|
||||||
@ -258,6 +260,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||||||
base::unsize_thin_ptr(bcx, lldata,
|
base::unsize_thin_ptr(bcx, lldata,
|
||||||
operand.ty, cast_ty)
|
operand.ty, cast_ty)
|
||||||
});
|
});
|
||||||
|
self.set_operand_dropped(&bcx, source);
|
||||||
OperandValue::FatPtr(lldata, llextra)
|
OperandValue::FatPtr(lldata, llextra)
|
||||||
}
|
}
|
||||||
OperandValue::Ref(_) => {
|
OperandValue::Ref(_) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user