Skip to content

Commit e3abc3c

Browse files
Don't use dropflag hints when the type is dropless
1 parent 3246eae commit e3abc3c

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/librustc_trans/trans/base.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,7 @@ pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>,
15651565
// Create the drop-flag hints for every unfragmented path in the function.
15661566
let tcx = fcx.ccx.tcx();
15671567
let fn_did = tcx.map.local_def_id(fcx.id);
1568+
let tables = tcx.tables.borrow();
15681569
let mut hints = fcx.lldropflag_hints.borrow_mut();
15691570
let fragment_infos = tcx.fragment_infos.borrow();
15701571

@@ -1588,12 +1589,22 @@ pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>,
15881589
let (var, datum) = match info {
15891590
ty::FragmentInfo::Moved { var, .. } |
15901591
ty::FragmentInfo::Assigned { var, .. } => {
1591-
let datum = seen.get(&var).cloned().unwrap_or_else(|| {
1592-
let datum = make_datum(var);
1593-
seen.insert(var, datum.clone());
1594-
datum
1592+
let opt_datum = seen.get(&var).cloned().unwrap_or_else(|| {
1593+
let ty = tables.node_types[&var];
1594+
if fcx.type_needs_drop(ty) {
1595+
let datum = make_datum(var);
1596+
seen.insert(var, Some(datum.clone()));
1597+
Some(datum)
1598+
} else {
1599+
// No drop call needed, so we don't need a dropflag hint
1600+
None
1601+
}
15951602
});
1596-
(var, datum)
1603+
if let Some(datum) = opt_datum {
1604+
(var, datum)
1605+
} else {
1606+
continue
1607+
}
15971608
}
15981609
};
15991610
match info {

0 commit comments

Comments
 (0)