diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-08-08 17:24:30 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2021-09-13 14:42:06 +0200 |
| commit | 8c7840e8cb700870854efa02cca817c7dd610698 (patch) | |
| tree | 2cdf751a832fb5ae2999e0d63a0ed0bae507de92 /compiler/rustc_span/src | |
| parent | c7dbe7a830100c70d59994fd940bf75bb6e39b39 (diff) | |
| download | rust-8c7840e8cb700870854efa02cca817c7dd610698.tar.gz rust-8c7840e8cb700870854efa02cca817c7dd610698.zip | |
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.rs | 5 |
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>, |
