From e13d352aaff9ab76d912adc2c119f4019a1f8ead Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Thu, 11 Feb 2016 01:37:55 -0500 Subject: [PATCH 1/2] don't ICE on missing box_free lang item --- src/librustc_mir/build/scope.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 87c6e2a672750..592fe03a438f4 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -622,8 +622,8 @@ fn build_free<'tcx>(tcx: &ty::ctxt<'tcx>, unit_temp: Lvalue<'tcx>, data: &FreeData<'tcx>, target: BasicBlock) -> Terminator<'tcx> { - let free_func = tcx.lang_items.box_free_fn() - .expect("box_free language item is missing"); + let free_func = tcx.lang_items.require(lang_items::BoxFreeFnLangItem) + .unwrap_or_else(|e| tcx.sess.fatal(&e)); let substs = tcx.mk_substs(Substs::new( VecPerParamSpace::new(vec![], vec![], vec![data.item_ty]), VecPerParamSpace::new(vec![], vec![], vec![]) From 433f34799c5ccef2a10febb656d7568857bab2b6 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Thu, 11 Feb 2016 01:38:08 -0500 Subject: [PATCH 2/2] don't ICE on missing exchange_* lang items --- src/librustc_trans/trans/collector.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_trans/trans/collector.rs b/src/librustc_trans/trans/collector.rs index df86685e236bd..3c8d24206e7a0 100644 --- a/src/librustc_trans/trans/collector.rs +++ b/src/librustc_trans/trans/collector.rs @@ -501,7 +501,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { .tcx() .lang_items .require(ExchangeMallocFnLangItem) - .expect("Could not find ExchangeMallocFnLangItem"); + .unwrap_or_else(|e| self.ccx.sess().fatal(&e)); assert!(can_have_local_instance(self.ccx, exchange_malloc_fn_def_id)); let exchange_malloc_fn_trans_item = @@ -645,7 +645,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let exchange_free_fn_def_id = ccx.tcx() .lang_items .require(ExchangeFreeFnLangItem) - .expect("Could not find ExchangeFreeFnLangItem"); + .unwrap_or_else(|e| ccx.sess().fatal(&e)); assert!(can_have_local_instance(ccx, exchange_free_fn_def_id)); let exchange_free_fn_trans_item =