mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-27 11:05:06 +00:00
`rustc_span::symbol` defines some things that are re-exported from
`rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some
closely related things such as `Ident` and `kw`. So you can do `use
rustc_span::{Symbol, sym}` but you have to do `use
rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good
reason.
This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`,
and changes many `rustc_span::symbol::` qualifiers in `compiler/` to
`rustc_span::`. This is a 200+ net line of code reduction, mostly
because many files with two `use rustc_span` items can be reduced to
one.
31 lines
763 B
Rust
31 lines
763 B
Rust
//! Validity checking for weak lang items
|
|
|
|
use rustc_span::{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;
|
|
}
|