use tcx.require_lang_item() instead

This commit is contained in:
SparrowLii 2022-04-28 20:18:01 +08:00
parent d735aa6810
commit cf00142b4d
2 changed files with 5 additions and 12 deletions

View file

@ -119,17 +119,10 @@ mod temp_stable_hash_impls {
pub fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &Bx,
span: Option<Span>,
msg: &str,
li: LangItem,
) -> (Bx::FnAbiOfResult, Bx::Value) {
let tcx = bx.tcx();
let def_id = tcx.lang_items().require(li).unwrap_or_else(|s| {
let msg = format!("{} {}", msg, s);
match span {
Some(span) => tcx.sess.span_fatal(span, &msg),
None => tcx.sess.fatal(&msg),
}
});
let def_id = tcx.require_lang_item(li, span);
let instance = ty::Instance::mono(tcx, def_id);
(bx.fn_abi_of_instance(instance, ty::List::empty()), bx.get_fn_addr(instance))
}