summary refs log tree commit diff
path: root/compiler/rustc_span/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-24 16:56:32 +0000
committerbors <bors@rust-lang.org>2022-08-24 16:56:32 +0000
commitebfc7aa53185617f14e1e15bef8ef5b4505b5397 (patch)
tree84e41374423ad00866a502792ba13bdfa7d3eb48 /compiler/rustc_span/src
parent4a24f08ba43166cfee86d868b3fe8612aec6faca (diff)
parentf6329485a83c1d241635e0dedbf62929e193b10a (diff)
downloadrust-ebfc7aa53185617f14e1e15bef8ef5b4505b5397.tar.gz
rust-ebfc7aa53185617f14e1e15bef8ef5b4505b5397.zip
Auto merge of #100803 - klensy:do-not-encode-preinterned-symbols, r=bjorn3
Symbols: do not write string values of preinterned symbols into compiled artifacts

r? `@bjorn3`

Followup for #98851

https://github.com/rust-lang/rust/pull/98851#issuecomment-1215606291
Diffstat (limited to 'compiler/rustc_span/src')
-rw-r--r--compiler/rustc_span/src/symbol.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index c8978845ffb..e4bbbbf83cb 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -1804,6 +1804,11 @@ impl Symbol {
         Symbol(SymbolIndex::from_u32(n))
     }
 
+    /// for use in Decoder only
+    pub fn new_from_decoded(n: u32) -> Self {
+        Self::new(n)
+    }
+
     /// Maps a string to its interned representation.
     pub fn intern(string: &str) -> Self {
         with_session_globals(|session_globals| session_globals.symbol_interner.intern(string))
@@ -2028,6 +2033,11 @@ impl Symbol {
     pub fn can_be_raw(self) -> bool {
         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 {