1 //! Validity checking for weak lang items
3 use crate::def_id::DefId;
4 use crate::{lang_items, LangItem, LanguageItems};
7 use rustc_data_structures::fx::FxHashMap;
8 use rustc_span::symbol::{sym, Symbol};
10 use lazy_static::lazy_static;
12 macro_rules! weak_lang_items {
13 ($($name:ident, $item:ident, $sym:ident;)*) => (
16 pub static ref WEAK_ITEMS_REFS: FxHashMap<Symbol, LangItem> = {
17 let mut map = FxHashMap::default();
18 $(map.insert(sym::$name, lang_items::$item);)*
23 pub fn link_name(attrs: &[ast::Attribute]) -> Option<Symbol> {
24 lang_items::extract(attrs).and_then(|(name, _)| {
25 $(if name == sym::$name {
34 pub fn is_weak_lang_item(&self, item_def_id: DefId) -> bool {
35 let did = Some(item_def_id);
37 $(self.$name() == did)||*
44 panic_impl, PanicImplLangItem, rust_begin_unwind;
45 eh_personality, EhPersonalityLangItem, rust_eh_personality;
46 oom, OomLangItem, rust_oom;