Skip to content

Commit

Permalink
instantiate closures on demand
Browse files Browse the repository at this point in the history
this should fix compilation with `-C codegen-units=4` - tested locally
with `RUSTFLAGS='-C codegen-units=4' ../x.py test`
  • Loading branch information
arielb1 committed Nov 18, 2016
1 parent 509d14f commit 4fc02f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/librustc_trans/common.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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 changes: 2 additions & 0 deletions src/librustc_trans/trans_item.rs
Expand Up @@ -18,6 +18,7 @@ use attributes;
use base;
use consts;
use context::{CrateContext, SharedCrateContext};
use common;
use declare;
use glue::DropGlueKind;
use llvm;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4fc02f6

Please sign in to comment.