Skip to content

Commit 3fe0e24

Browse files
committed
only extract lang items once
1 parent 1d589c8 commit 3fe0e24

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,14 @@ fn handle_lang_items(
527527
attrs: &[Attribute],
528528
codegen_fn_attrs: &mut CodegenFnAttrs,
529529
) {
530+
let lang_item = lang_items::extract(attrs).and_then(|(name, _)| LangItem::from_name(name));
531+
530532
// Weak lang items have the same semantics as "std internal" symbols in the
531533
// sense that they're preserved through all our LTO passes and only
532534
// strippable by the linker.
533535
//
534536
// Additionally weak lang items have predetermined symbol names.
535-
if let Some((name, _)) = lang_items::extract(attrs)
536-
&& let Some(lang_item) = LangItem::from_name(name)
537-
{
537+
if let Some(lang_item) = lang_item {
538538
if WEAK_LANG_ITEMS.contains(&lang_item) {
539539
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
540540
}
@@ -548,8 +548,6 @@ fn handle_lang_items(
548548
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)
549549
&& codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE)
550550
{
551-
let lang_item =
552-
lang_items::extract(attrs).map_or(None, |(name, _span)| LangItem::from_name(name));
553551
let mut err = tcx
554552
.dcx()
555553
.struct_span_err(

0 commit comments

Comments
 (0)