instantiate closures on demand

this should fix compilation with `-C codegen-units=4` - tested locally
with `RUSTFLAGS='-C codegen-units=4' ../x.py test`
This commit is contained in:
Ariel Ben-Yehuda
2016-11-16 12:27:43 +02:00
parent 509d14fc70
commit 4fc02f6893
2 changed files with 7 additions and 0 deletions
+5
View 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
}
+2
View 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,