mirror of
https://github.com/rust-lang/rust.git
synced 2025-12-03 00:49:18 +00:00
31 lines
771 B
Rust
31 lines
771 B
Rust
//! Validity checking for weak lang items
|
|
|
|
use rustc_span::symbol::{Symbol, sym};
|
|
|
|
use crate::LangItem;
|
|
|
|
macro_rules! weak_lang_items {
|
|
($($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! {
|
|
PanicImpl, rust_begin_unwind;
|
|
EhPersonality, rust_eh_personality;
|
|
EhCatchTypeinfo, rust_eh_catch_typeinfo;
|
|
}
|