2020-01-26 13:16:02 +01:00
|
|
|
//! Validity checking for weak lang items
|
|
|
|
|
2022-10-26 16:18:59 -05:00
|
|
|
use crate::LangItem;
|
2020-01-26 13:16:02 +01:00
|
|
|
|
|
|
|
use rustc_span::symbol::{sym, Symbol};
|
|
|
|
|
|
|
|
macro_rules! weak_lang_items {
|
2022-10-26 16:18:59 -05:00
|
|
|
($($item:ident, $sym:ident;)*) => {
|
|
|
|
pub static WEAK_LANG_ITEMS: &[LangItem] = &[$(LangItem::$item,)*];
|
|
|
|
|
|
|
|
impl LangItem {
|
|
|
|
pub fn is_weak(self) -> bool {
|
|
|
|
matches!(self, $(LangItem::$item)|*)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn link_name(self) -> Option<Symbol> {
|
|
|
|
match self {
|
|
|
|
$( LangItem::$item => Some(sym::$sym),)*
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2020-01-26 13:16:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
weak_lang_items! {
|
2022-10-26 16:18:59 -05:00
|
|
|
PanicImpl, rust_begin_unwind;
|
|
|
|
EhPersonality, rust_eh_personality;
|
|
|
|
EhCatchTypeinfo, rust_eh_catch_typeinfo;
|
2020-01-26 13:16:02 +01:00
|
|
|
}
|