@@ -18,7 +18,7 @@ use std::fmt::Write;
18
18
use std:: hash:: Hash ;
19
19
use syntax:: ast;
20
20
use syntax_expand:: hygiene:: ExpnId ;
21
- use syntax:: symbol:: { Symbol , sym, InternedString } ;
21
+ use syntax:: symbol:: { Symbol , sym} ;
22
22
use syntax_pos:: { Span , DUMMY_SP } ;
23
23
24
24
/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
@@ -136,7 +136,9 @@ impl DefKey {
136
136
137
137
:: std:: mem:: discriminant ( data) . hash ( & mut hasher) ;
138
138
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) ;
140
142
}
141
143
142
144
disambiguator. hash ( & mut hasher) ;
@@ -218,7 +220,7 @@ impl DefPath {
218
220
for component in & self . data {
219
221
write ! ( s,
220
222
"::{}[{}]" ,
221
- component. data. as_interned_str ( ) ,
223
+ component. data. as_symbol ( ) ,
222
224
component. disambiguator)
223
225
. unwrap ( ) ;
224
226
}
@@ -238,11 +240,11 @@ impl DefPath {
238
240
239
241
for component in & self . data {
240
242
if component. disambiguator == 0 {
241
- write ! ( s, "::{}" , component. data. as_interned_str ( ) ) . unwrap ( ) ;
243
+ write ! ( s, "::{}" , component. data. as_symbol ( ) ) . unwrap ( ) ;
242
244
} else {
243
245
write ! ( s,
244
246
"{}[{}]" ,
245
- component. data. as_interned_str ( ) ,
247
+ component. data. as_symbol ( ) ,
246
248
component. disambiguator)
247
249
. unwrap ( ) ;
248
250
}
@@ -262,11 +264,11 @@ impl DefPath {
262
264
opt_delimiter. map ( |d| s. push ( d) ) ;
263
265
opt_delimiter = Some ( '-' ) ;
264
266
if component. disambiguator == 0 {
265
- write ! ( s, "{}" , component. data. as_interned_str ( ) ) . unwrap ( ) ;
267
+ write ! ( s, "{}" , component. data. as_symbol ( ) ) . unwrap ( ) ;
266
268
} else {
267
269
write ! ( s,
268
270
"{}[{}]" ,
269
- component. data. as_interned_str ( ) ,
271
+ component. data. as_symbol ( ) ,
270
272
component. disambiguator)
271
273
. unwrap ( ) ;
272
274
}
@@ -290,13 +292,13 @@ pub enum DefPathData {
290
292
/// An impl.
291
293
Impl ,
292
294
/// Something in the type namespace.
293
- TypeNs ( InternedString ) ,
295
+ TypeNs ( Symbol ) ,
294
296
/// Something in the value namespace.
295
- ValueNs ( InternedString ) ,
297
+ ValueNs ( Symbol ) ,
296
298
/// Something in the macro namespace.
297
- MacroNs ( InternedString ) ,
299
+ MacroNs ( Symbol ) ,
298
300
/// Something in the lifetime namespace.
299
- LifetimeNs ( InternedString ) ,
301
+ LifetimeNs ( Symbol ) ,
300
302
/// A closure expression.
301
303
ClosureExpr ,
302
304
@@ -311,7 +313,7 @@ pub enum DefPathData {
311
313
/// Identifies a piece of crate metadata that is global to a whole crate
312
314
/// (as opposed to just one item). `GlobalMetaData` components are only
313
315
/// supposed to show up right below the crate root.
314
- GlobalMetaData ( InternedString ) ,
316
+ GlobalMetaData ( Symbol ) ,
315
317
}
316
318
317
319
#[ derive( Copy , Clone , Hash , PartialEq , Eq , PartialOrd , Ord , Debug ,
@@ -545,7 +547,7 @@ impl Definitions {
545
547
}
546
548
547
549
impl DefPathData {
548
- pub fn get_opt_name ( & self ) -> Option < InternedString > {
550
+ pub fn get_opt_name ( & self ) -> Option < Symbol > {
549
551
use self :: DefPathData :: * ;
550
552
match * self {
551
553
TypeNs ( name) |
@@ -564,15 +566,15 @@ impl DefPathData {
564
566
}
565
567
}
566
568
567
- pub fn as_interned_str ( & self ) -> InternedString {
569
+ pub fn as_symbol ( & self ) -> Symbol {
568
570
use self :: DefPathData :: * ;
569
- let s = match * self {
571
+ match * self {
570
572
TypeNs ( name) |
571
573
ValueNs ( name) |
572
574
MacroNs ( name) |
573
575
LifetimeNs ( name) |
574
576
GlobalMetaData ( name) => {
575
- return name
577
+ name
576
578
}
577
579
// Note that this does not show up in user print-outs.
578
580
CrateRoot => sym:: double_braced_crate,
@@ -582,13 +584,11 @@ impl DefPathData {
582
584
Ctor => sym:: double_braced_constructor,
583
585
AnonConst => sym:: double_braced_constant,
584
586
ImplTrait => sym:: double_braced_opaque,
585
- } ;
586
-
587
- s. as_interned_str ( )
587
+ }
588
588
}
589
589
590
590
pub fn to_string ( & self ) -> String {
591
- self . as_interned_str ( ) . to_string ( )
591
+ self . as_symbol ( ) . to_string ( )
592
592
}
593
593
}
594
594
@@ -610,7 +610,7 @@ macro_rules! define_global_metadata_kind {
610
610
definitions. create_def_with_parent(
611
611
CRATE_DEF_INDEX ,
612
612
ast:: DUMMY_NODE_ID ,
613
- DefPathData :: GlobalMetaData ( instance. name( ) . as_interned_str ( ) ) ,
613
+ DefPathData :: GlobalMetaData ( instance. name( ) ) ,
614
614
ExpnId :: root( ) ,
615
615
DUMMY_SP
616
616
) ;
@@ -624,7 +624,7 @@ macro_rules! define_global_metadata_kind {
624
624
let def_key = DefKey {
625
625
parent: Some ( CRATE_DEF_INDEX ) ,
626
626
disambiguated_data: DisambiguatedDefPathData {
627
- data: DefPathData :: GlobalMetaData ( self . name( ) . as_interned_str ( ) ) ,
627
+ data: DefPathData :: GlobalMetaData ( self . name( ) ) ,
628
628
disambiguator: 0 ,
629
629
}
630
630
} ;
0 commit comments