use rustc::mir::visit::{Visitor, LvalueContext};
use rustc::mir::traversal;
use common::{self, Block, BlockAndBuilder};
+use glue;
use super::rvalue;
pub fn lvalue_temps<'bcx,'tcx>(bcx: Block<'bcx,'tcx>,
LvalueContext::Consume => {
}
LvalueContext::Store |
- LvalueContext::Drop |
LvalueContext::Inspect |
LvalueContext::Borrow { .. } |
LvalueContext::Slice { .. } |
LvalueContext::Projection => {
self.mark_as_lvalue(temp.index());
}
+ LvalueContext::Drop => {
+ let ty = self.mir.temp_decls[index as usize].ty;
+ let ty = self.bcx.monomorphize(&ty);
+
+ // Only need the lvalue if we're actually dropping it.
+ if glue::type_needs_drop(self.bcx.tcx(), ty) {
+ self.mark_as_lvalue(index as usize);
+ }
+ }
}
}
_ => {
}
mir::TerminatorKind::Drop { ref location, target, unwind } => {
- let lvalue = self.trans_lvalue(&bcx, location);
- let ty = lvalue.ty.to_ty(bcx.tcx());
+ let ty = mir.lvalue_ty(bcx.tcx(), location).to_ty(bcx.tcx());
+ let ty = bcx.monomorphize(&ty);
+
// Double check for necessity to drop
if !glue::type_needs_drop(bcx.tcx(), ty) {
funclet_br(self, bcx, target);
return;
}
+
+ let lvalue = self.trans_lvalue(&bcx, location);
let drop_fn = glue::get_drop_glue(bcx.ccx(), ty);
let drop_ty = glue::get_drop_glue_type(bcx.tcx(), ty);
let llvalue = if drop_ty != ty {