@@ -18,7 +18,7 @@ use std::fmt::Write;
1818use std:: hash:: Hash ;
1919use syntax:: ast;
2020use syntax_expand:: hygiene:: ExpnId ;
21- use syntax:: symbol:: { Symbol , sym, InternedString } ;
21+ use syntax:: symbol:: { Symbol , sym} ;
2222use syntax_pos:: { Span , DUMMY_SP } ;
2323
2424/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
@@ -136,7 +136,9 @@ impl DefKey {
136136
137137 :: std:: mem:: discriminant ( data) . hash ( & mut hasher) ;
138138 if let Some ( name) = data. get_opt_name ( ) {
139- name. hash ( & mut hasher) ;
139+ // Get a stable hash by considering the symbol chars rather than
140+ // the symbol index.
141+ name. as_str ( ) . hash ( & mut hasher) ;
140142 }
141143
142144 disambiguator. hash ( & mut hasher) ;
@@ -218,7 +220,7 @@ impl DefPath {
218220 for component in & self . data {
219221 write ! ( s,
220222 "::{}[{}]" ,
221- component. data. as_interned_str ( ) ,
223+ component. data. as_symbol ( ) ,
222224 component. disambiguator)
223225 . unwrap ( ) ;
224226 }
@@ -238,11 +240,11 @@ impl DefPath {
238240
239241 for component in & self . data {
240242 if component. disambiguator == 0 {
241- write ! ( s, "::{}" , component. data. as_interned_str ( ) ) . unwrap ( ) ;
243+ write ! ( s, "::{}" , component. data. as_symbol ( ) ) . unwrap ( ) ;
242244 } else {
243245 write ! ( s,
244246 "{}[{}]" ,
245- component. data. as_interned_str ( ) ,
247+ component. data. as_symbol ( ) ,
246248 component. disambiguator)
247249 . unwrap ( ) ;
248250 }
@@ -262,11 +264,11 @@ impl DefPath {
262264 opt_delimiter. map ( |d| s. push ( d) ) ;
263265 opt_delimiter = Some ( '-' ) ;
264266 if component. disambiguator == 0 {
265- write ! ( s, "{}" , component. data. as_interned_str ( ) ) . unwrap ( ) ;
267+ write ! ( s, "{}" , component. data. as_symbol ( ) ) . unwrap ( ) ;
266268 } else {
267269 write ! ( s,
268270 "{}[{}]" ,
269- component. data. as_interned_str ( ) ,
271+ component. data. as_symbol ( ) ,
270272 component. disambiguator)
271273 . unwrap ( ) ;
272274 }
@@ -290,13 +292,13 @@ pub enum DefPathData {
290292 /// An impl.
291293 Impl ,
292294 /// Something in the type namespace.
293- TypeNs ( InternedString ) ,
295+ TypeNs ( Symbol ) ,
294296 /// Something in the value namespace.
295- ValueNs ( InternedString ) ,
297+ ValueNs ( Symbol ) ,
296298 /// Something in the macro namespace.
297- MacroNs ( InternedString ) ,
299+ MacroNs ( Symbol ) ,
298300 /// Something in the lifetime namespace.
299- LifetimeNs ( InternedString ) ,
301+ LifetimeNs ( Symbol ) ,
300302 /// A closure expression.
301303 ClosureExpr ,
302304
@@ -311,7 +313,7 @@ pub enum DefPathData {
311313 /// Identifies a piece of crate metadata that is global to a whole crate
312314 /// (as opposed to just one item). `GlobalMetaData` components are only
313315 /// supposed to show up right below the crate root.
314- GlobalMetaData ( InternedString ) ,
316+ GlobalMetaData ( Symbol ) ,
315317}
316318
317319#[ derive( Copy , Clone , Hash , PartialEq , Eq , PartialOrd , Ord , Debug ,
@@ -545,7 +547,7 @@ impl Definitions {
545547}
546548
547549impl DefPathData {
548- pub fn get_opt_name ( & self ) -> Option < InternedString > {
550+ pub fn get_opt_name ( & self ) -> Option < Symbol > {
549551 use self :: DefPathData :: * ;
550552 match * self {
551553 TypeNs ( name) |
@@ -564,15 +566,15 @@ impl DefPathData {
564566 }
565567 }
566568
567- pub fn as_interned_str ( & self ) -> InternedString {
569+ pub fn as_symbol ( & self ) -> Symbol {
568570 use self :: DefPathData :: * ;
569- let s = match * self {
571+ match * self {
570572 TypeNs ( name) |
571573 ValueNs ( name) |
572574 MacroNs ( name) |
573575 LifetimeNs ( name) |
574576 GlobalMetaData ( name) => {
575- return name
577+ name
576578 }
577579 // Note that this does not show up in user print-outs.
578580 CrateRoot => sym:: double_braced_crate,
@@ -582,13 +584,11 @@ impl DefPathData {
582584 Ctor => sym:: double_braced_constructor,
583585 AnonConst => sym:: double_braced_constant,
584586 ImplTrait => sym:: double_braced_opaque,
585- } ;
586-
587- s. as_interned_str ( )
587+ }
588588 }
589589
590590 pub fn to_string ( & self ) -> String {
591- self . as_interned_str ( ) . to_string ( )
591+ self . as_symbol ( ) . to_string ( )
592592 }
593593}
594594
@@ -611,7 +611,7 @@ macro_rules! define_global_metadata_kind {
611611 definitions. create_def_with_parent(
612612 CRATE_DEF_INDEX ,
613613 ast:: DUMMY_NODE_ID ,
614- DefPathData :: GlobalMetaData ( instance. name( ) . as_interned_str ( ) ) ,
614+ DefPathData :: GlobalMetaData ( instance. name( ) ) ,
615615 ExpnId :: root( ) ,
616616 DUMMY_SP
617617 ) ;
@@ -625,7 +625,7 @@ macro_rules! define_global_metadata_kind {
625625 let def_key = DefKey {
626626 parent: Some ( CRATE_DEF_INDEX ) ,
627627 disambiguated_data: DisambiguatedDefPathData {
628- data: DefPathData :: GlobalMetaData ( self . name( ) . as_interned_str ( ) ) ,
628+ data: DefPathData :: GlobalMetaData ( self . name( ) ) ,
629629 disambiguator: 0 ,
630630 }
631631 } ;
0 commit comments