Skip to content

Commit

Permalink
Don't use dropflag hints when the type is dropless
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Jan 12, 2016
1 parent 3246eae commit e3abc3c
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/librustc_trans/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,7 @@ pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>,
// Create the drop-flag hints for every unfragmented path in the function.
let tcx = fcx.ccx.tcx();
let fn_did = tcx.map.local_def_id(fcx.id);
let tables = tcx.tables.borrow();
let mut hints = fcx.lldropflag_hints.borrow_mut();
let fragment_infos = tcx.fragment_infos.borrow();

Expand All @@ -1588,12 +1589,22 @@ pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>,
let (var, datum) = match info {
ty::FragmentInfo::Moved { var, .. } |
ty::FragmentInfo::Assigned { var, .. } => {
let datum = seen.get(&var).cloned().unwrap_or_else(|| {
let datum = make_datum(var);
seen.insert(var, datum.clone());
datum
let opt_datum = seen.get(&var).cloned().unwrap_or_else(|| {
let ty = tables.node_types[&var];
if fcx.type_needs_drop(ty) {
let datum = make_datum(var);
seen.insert(var, Some(datum.clone()));
Some(datum)
} else {
// No drop call needed, so we don't need a dropflag hint
None
}
});
(var, datum)
if let Some(datum) = opt_datum {
(var, datum)
} else {
continue
}
}
};
match info {
Expand Down

0 comments on commit e3abc3c

Please # to comment.