]> git.lizzy.rs Git - rust.git/commitdiff
instantiate closures on demand
authorAriel Ben-Yehuda <ariel.byd@gmail.com>
Wed, 16 Nov 2016 10:27:43 +0000 (12:27 +0200)
committerAriel Ben-Yehuda <ariel.byd@gmail.com>
Fri, 18 Nov 2016 10:25:00 +0000 (12:25 +0200)
this should fix compilation with `-C codegen-units=4` - tested locally
with `RUSTFLAGS='-C codegen-units=4' ../x.py test`

src/librustc_trans/common.rs
src/librustc_trans/trans_item.rs

index a0fac9cc6599eeaa9e98761e0e1360c3066c519d..df70a6e81166b8113d9b4a0b15785c6a3b90a6d9 100644 (file)
@@ -18,6 +18,7 @@
 use llvm::{True, False, Bool, OperandBundleDef};
 use rustc::hir::def::Def;
 use rustc::hir::def_id::DefId;
+use rustc::hir::map::DefPathData;
 use rustc::infer::TransNormalize;
 use rustc::mir::Mir;
 use rustc::util::common::MemoizationMap;
@@ -1100,3 +1101,7 @@ pub fn ty_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         _ => bug!("unexpected type {:?} to ty_fn_sig", ty)
     }
 }
+
+pub fn is_closure(tcx: TyCtxt, def_id: DefId) -> bool {
+    tcx.def_key(def_id).disambiguated_data.data == DefPathData::ClosureExpr
+}
index 94a68de7f8670efd1017a0cf2511b3f0e9c868b1..7fa59127704dc2c7e59504ff7eb6986f6605ef01 100644 (file)
@@ -18,6 +18,7 @@
 use base;
 use consts;
 use context::{CrateContext, SharedCrateContext};
+use common;
 use declare;
 use glue::DropGlueKind;
 use llvm;
@@ -245,6 +246,7 @@ pub fn is_instantiated_only_on_demand(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> boo
             TransItem::Fn(ref instance) => {
                 !instance.def.is_local() ||
                 instance.substs.types().next().is_some() ||
+                common::is_closure(tcx, instance.def) ||
                 attr::requests_inline(&tcx.get_attrs(instance.def)[..])
             }
             TransItem::DropGlue(..) => true,