rust/compiler/rustc_hir/src/weak_lang_items.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
771 B
Rust
Raw Normal View History

//! Validity checking for weak lang items
2022-10-26 16:18:59 -05:00
use crate::LangItem;
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,
}
}
}
}
}
weak_lang_items! {
2022-10-26 16:18:59 -05:00
PanicImpl, rust_begin_unwind;
EhPersonality, rust_eh_personality;
EhCatchTypeinfo, rust_eh_catch_typeinfo;
}