Skip to content

Commit aa97daf

Browse files
authored
Auto merge of rust-lang#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
2 parents 2f4368b + 4fc02f6 commit aa97daf

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/librustc_trans/common.rs

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use llvm::{ValueRef, BasicBlockRef, BuilderRef, ContextRef, TypeKind};
1818
use llvm::{True, False, Bool, OperandBundleDef};
1919
use rustc::hir::def::Def;
2020
use rustc::hir::def_id::DefId;
21+
use rustc::hir::map::DefPathData;
2122
use rustc::infer::TransNormalize;
2223
use rustc::mir::Mir;
2324
use rustc::util::common::MemoizationMap;
@@ -1100,3 +1101,7 @@ pub fn ty_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
11001101
_ => bug!("unexpected type {:?} to ty_fn_sig", ty)
11011102
}
11021103
}
1104+
1105+
pub fn is_closure(tcx: TyCtxt, def_id: DefId) -> bool {
1106+
tcx.def_key(def_id).disambiguated_data.data == DefPathData::ClosureExpr
1107+
}

src/librustc_trans/trans_item.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use attributes;
1818
use base;
1919
use consts;
2020
use context::{CrateContext, SharedCrateContext};
21+
use common;
2122
use declare;
2223
use glue::DropGlueKind;
2324
use llvm;
@@ -245,6 +246,7 @@ impl<'a, 'tcx> TransItem<'tcx> {
245246
TransItem::Fn(ref instance) => {
246247
!instance.def.is_local() ||
247248
instance.substs.types().next().is_some() ||
249+
common::is_closure(tcx, instance.def) ||
248250
attr::requests_inline(&tcx.get_attrs(instance.def)[..])
249251
}
250252
TransItem::DropGlue(..) => true,

0 commit comments

Comments
 (0)