]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | //! Validity checking for weak lang items |
2 | ||
487cf647 | 3 | use crate::LangItem; |
74b04a01 | 4 | |
74b04a01 XL |
5 | use rustc_span::symbol::{sym, Symbol}; |
6 | ||
74b04a01 | 7 | macro_rules! weak_lang_items { |
487cf647 FG |
8 | ($($item:ident, $sym:ident;)*) => { |
9 | pub static WEAK_LANG_ITEMS: &[LangItem] = &[$(LangItem::$item,)*]; | |
10 | ||
11 | impl LangItem { | |
12 | pub fn is_weak(self) -> bool { | |
13 | matches!(self, $(LangItem::$item)|*) | |
14 | } | |
15 | ||
16 | pub fn link_name(self) -> Option<Symbol> { | |
17 | match self { | |
18 | $( LangItem::$item => Some(sym::$sym),)* | |
19 | _ => None, | |
20 | } | |
21 | } | |
74b04a01 | 22 | } |
74b04a01 XL |
23 | } |
24 | } | |
25 | ||
74b04a01 | 26 | weak_lang_items! { |
487cf647 FG |
27 | PanicImpl, rust_begin_unwind; |
28 | EhPersonality, rust_eh_personality; | |
29 | EhCatchTypeinfo, rust_eh_catch_typeinfo; | |
74b04a01 | 30 | } |