Auto merge of #37797 - arielb1:inline-closure, r=michaelwoerister

instantiate closures on demand

this should fix compilation with `-C codegen-units=4` - tested locally
with `RUSTFLAGS='-C codegen-units=4' ../x.py test`

r? @michaelwoerister
This commit is contained in:
bors 2016-11-19 01:49:07 -08:00 committed by GitHub
commit aa97dafe01
2 changed files with 7 additions and 0 deletions

View File

@ -18,6 +18,7 @@ use llvm::{ValueRef, BasicBlockRef, BuilderRef, ContextRef, TypeKind};
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
}

View File

@ -18,6 +18,7 @@ use attributes;
use base;
use consts;
use context::{CrateContext, SharedCrateContext};
use common;
use declare;
use glue::DropGlueKind;
use llvm;
@ -245,6 +246,7 @@ impl<'a, 'tcx> TransItem<'tcx> {
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,