Skip to content

Commit cf00142

Browse files
committed
use tcx.require_lang_item() instead
1 parent d735aa6 commit cf00142

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

compiler/rustc_codegen_ssa/src/common.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,10 @@ mod temp_stable_hash_impls {
119119
pub fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
120120
bx: &Bx,
121121
span: Option<Span>,
122-
msg: &str,
123122
li: LangItem,
124123
) -> (Bx::FnAbiOfResult, Bx::Value) {
125124
let tcx = bx.tcx();
126-
let def_id = tcx.lang_items().require(li).unwrap_or_else(|s| {
127-
let msg = format!("{} {}", msg, s);
128-
match span {
129-
Some(span) => tcx.sess.span_fatal(span, &msg),
130-
None => tcx.sess.fatal(&msg),
131-
}
132-
});
125+
let def_id = tcx.require_lang_item(li, span);
133126
let instance = ty::Instance::mono(tcx, def_id);
134127
(bx.fn_abi_of_instance(instance, ty::List::empty()), bx.get_fn_addr(instance))
135128
}

compiler/rustc_codegen_ssa/src/mir/block.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
489489
}
490490
};
491491

492-
let (fn_abi, llfn) = common::build_langcall(&bx, Some(span), "", lang_item);
492+
let (fn_abi, llfn) = common::build_langcall(&bx, Some(span), lang_item);
493493

494494
// Codegen the actual panic invoke/call.
495495
helper.do_call(self, &mut bx, fn_abi, llfn, &args, None, cleanup);
@@ -505,7 +505,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
505505
self.set_debug_loc(&mut bx, terminator.source_info);
506506

507507
// Obtain the panic entry point.
508-
let (fn_abi, llfn) = common::build_langcall(&bx, Some(span), "", LangItem::PanicNoUnwind);
508+
let (fn_abi, llfn) = common::build_langcall(&bx, Some(span), LangItem::PanicNoUnwind);
509509

510510
// Codegen the actual panic invoke/call.
511511
helper.do_call(self, &mut bx, fn_abi, llfn, &[], None, None);
@@ -567,7 +567,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
567567

568568
// Obtain the panic entry point.
569569
let (fn_abi, llfn) =
570-
common::build_langcall(bx, Some(source_info.span), "", LangItem::Panic);
570+
common::build_langcall(bx, Some(source_info.span), LangItem::Panic);
571571

572572
// Codegen the actual panic invoke/call.
573573
helper.do_call(
@@ -1429,7 +1429,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14291429
let llretty = self.landing_pad_type();
14301430
bx.cleanup_landing_pad(llretty, llpersonality);
14311431

1432-
let (fn_abi, fn_ptr) = common::build_langcall(&bx, None, "", LangItem::PanicNoUnwind);
1432+
let (fn_abi, fn_ptr) = common::build_langcall(&bx, None, LangItem::PanicNoUnwind);
14331433
let fn_ty = bx.fn_decl_backend_type(&fn_abi);
14341434

14351435
let llret = bx.call(fn_ty, fn_ptr, &[], None);

0 commit comments

Comments
 (0)