about summary refs log tree commit diff
path: root/compiler/rustc_span/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-09-15 12:34:31 +0000
committerbors <bors@rust-lang.org>2021-09-15 12:34:31 +0000
commit2c7bc5e33c25e29058cbafefe680da8d5e9220e9 (patch)
treeaac5c14d47fc781a748b72a525b80f26d557c978 /compiler/rustc_span/src
parente846f9c44f1e17cac66d7b75e2ca099c87a2dfcb (diff)
parent8c7840e8cb700870854efa02cca817c7dd610698 (diff)
Auto merge of #87867 - bjorn3:unique_type_id_interner, r=wesleywiser
Use a separate interner type for UniqueTypeId

Using symbol::Interner makes it very easy to mixup UniqueTypeId symbols
with the global interner. In fact the Debug implementation of
UniqueTypeId did exactly this.

Using a separate interner type also avoids prefilling the interner with
unused symbols and allow for optimizing the symbol interner for parallel
access without negatively affecting the single threaded module codegen.
Diffstat (limited to 'compiler/rustc_span/src')
-rw-r--r--compiler/rustc_span/src/symbol.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index c816d060456..1df5b8cd2cc 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -1701,8 +1701,11 @@ impl<CTX> ToStableHashKey<CTX> for Symbol {
 // The `FxHashMap`+`Vec` pair could be replaced by `FxIndexSet`, but #75278
 // found that to regress performance up to 2% in some cases. This might be
 // revisited after further improvements to `indexmap`.
+//
+// This type is private to prevent accidentally constructing more than one `Interner` on the same
+// thread, which makes it easy to mixup `Symbol`s between `Interner`s.
 #[derive(Default)]
-pub struct Interner {
+pub(crate) struct Interner {
     arena: DroplessArena,
     names: FxHashMap<&'static str, Symbol>,
     strings: Vec<&'static str>,