Skip to content

Commit 1ab22d7

Browse files
committed
Auto merge of #31564 - durka:lang-item-icemelt, r=nikomatsakis
This changes three ICEs to fatal errors. I've grepped for `lang_item.*expect` and `\.expect.*lang` and didn't come up with any more. But, there could be more ICEs lurking. I wasn't sure about a test because there already _is_ a cfail test for missing lang items, but it only checks one. Relevant to (already closed) #31477 #31480 #31558. cc @LilRed
2 parents 5801991 + 433f347 commit 1ab22d7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/librustc_mir/build/scope.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,8 @@ fn build_free<'tcx>(tcx: &ty::ctxt<'tcx>,
622622
unit_temp: Lvalue<'tcx>,
623623
data: &FreeData<'tcx>,
624624
target: BasicBlock) -> Terminator<'tcx> {
625-
let free_func = tcx.lang_items.box_free_fn()
626-
.expect("box_free language item is missing");
625+
let free_func = tcx.lang_items.require(lang_items::BoxFreeFnLangItem)
626+
.unwrap_or_else(|e| tcx.sess.fatal(&e));
627627
let substs = tcx.mk_substs(Substs::new(
628628
VecPerParamSpace::new(vec![], vec![], vec![data.item_ty]),
629629
VecPerParamSpace::new(vec![], vec![], vec![])

src/librustc_trans/trans/collector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
501501
.tcx()
502502
.lang_items
503503
.require(ExchangeMallocFnLangItem)
504-
.expect("Could not find ExchangeMallocFnLangItem");
504+
.unwrap_or_else(|e| self.ccx.sess().fatal(&e));
505505

506506
assert!(can_have_local_instance(self.ccx, exchange_malloc_fn_def_id));
507507
let exchange_malloc_fn_trans_item =
@@ -645,7 +645,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
645645
let exchange_free_fn_def_id = ccx.tcx()
646646
.lang_items
647647
.require(ExchangeFreeFnLangItem)
648-
.expect("Could not find ExchangeFreeFnLangItem");
648+
.unwrap_or_else(|e| ccx.sess().fatal(&e));
649649

650650
assert!(can_have_local_instance(ccx, exchange_free_fn_def_id));
651651
let exchange_free_fn_trans_item =

0 commit comments

Comments
 (0)