diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 4a8b1e8b1c1e4..6f5f5ca4fb5c6 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -20,6 +20,7 @@ use serialize::{Decodable, Decoder, Encodable, Encoder}; use std::fmt; use std::cmp::{PartialEq, Ordering, PartialOrd, Ord}; use std::hash::{Hash, Hasher}; +use std::rc::Rc; #[derive(Copy, Clone, Eq)] pub struct Ident { @@ -200,11 +201,16 @@ impl> PartialEq for Symbol { #[derive(Default)] pub struct Interner { - names: FxHashMap, Symbol>, - strings: Vec>, + names: FxHashMap, Symbol>, + strings: Vec>, gensyms: Vec, } +// The impl is safe because the ref counts are only modified by one thread at a +// time, during insertion and during destruction. These may happen on different +// threads, but are mutually excluded. +unsafe impl Send for Interner {} + impl Interner { pub fn new() -> Self { Interner::default() @@ -224,7 +230,7 @@ impl Interner { } let name = Symbol(self.strings.len() as u32); - let string = string.to_string().into_boxed_str(); + let string: Rc = Rc::from(string); self.strings.push(string.clone()); self.names.insert(string, name); name