mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
symbols: add is_preinterned
fn to check if symbol was preinterned in compiler
This commit is contained in:
parent
36e530cb08
commit
0016356f2b
@ -195,10 +195,10 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
|
|||||||
#n,
|
#n,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let _ = counter; // for future use
|
|
||||||
|
|
||||||
let output = quote! {
|
let output = quote! {
|
||||||
const SYMBOL_DIGITS_BASE: u32 = #digits_base;
|
const SYMBOL_DIGITS_BASE: u32 = #digits_base;
|
||||||
|
const PREINTERNED_SYMBOLS_COUNT: u32 = #counter;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
|
@ -2027,6 +2027,11 @@ impl Symbol {
|
|||||||
pub fn can_be_raw(self) -> bool {
|
pub fn can_be_raw(self) -> bool {
|
||||||
self != kw::Empty && self != kw::Underscore && !self.is_path_segment_keyword()
|
self != kw::Empty && self != kw::Underscore && !self.is_path_segment_keyword()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Is this symbol was interned in compiler's `symbols!` macro
|
||||||
|
pub fn is_preinterned(self) -> bool {
|
||||||
|
self.as_u32() < PREINTERNED_SYMBOLS_COUNT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ident {
|
impl Ident {
|
||||||
|
Loading…
Reference in New Issue
Block a user