@@ -806,9 +806,9 @@ impl Ident {
806806 Ident :: new ( self . name , self . span . modern_and_legacy ( ) )
807807 }
808808
809- /// Convert the name to a `LocalInternedString `. This is a slowish
810- /// operation because it requires locking the symbol interner.
811- pub fn as_str ( self ) -> LocalInternedString {
809+ /// Convert the name to a `SymbolStr `. This is a slowish operation because
810+ /// it requires locking the symbol interner.
811+ pub fn as_str ( self ) -> SymbolStr {
812812 self . name . as_str ( )
813813 }
814814}
@@ -896,11 +896,11 @@ impl Symbol {
896896 } )
897897 }
898898
899- /// Convert to a `LocalInternedString `. This is a slowish operation because
900- /// it requires locking the symbol interner.
901- pub fn as_str ( self ) -> LocalInternedString {
899+ /// Convert to a `SymbolStr `. This is a slowish operation because it
900+ /// requires locking the symbol interner.
901+ pub fn as_str ( self ) -> SymbolStr {
902902 with_interner ( |interner| unsafe {
903- LocalInternedString {
903+ SymbolStr {
904904 string : std:: mem:: transmute :: < & str , & str > ( interner. get ( self ) )
905905 }
906906 } )
@@ -973,6 +973,7 @@ impl Interner {
973973 self . names . insert ( string, name) ;
974974 name
975975 }
976+
976977 // Get the symbol as a string. `Symbol::as_str()` should be used in
977978 // preference to this function.
978979 pub fn get ( & self , symbol : Symbol ) -> & str {
@@ -1092,15 +1093,14 @@ fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
10921093/// safely treat `string` which points to interner data, as an immortal string,
10931094/// as long as this type never crosses between threads.
10941095//
1095- // FIXME: ensure that the interner outlives any thread which uses
1096- // `LocalInternedString`, by creating a new thread right after constructing the
1097- // interner.
1096+ // FIXME: ensure that the interner outlives any thread which uses `SymbolStr`,
1097+ // by creating a new thread right after constructing the interner.
10981098#[ derive( Clone , Eq , PartialOrd , Ord ) ]
1099- pub struct LocalInternedString {
1099+ pub struct SymbolStr {
11001100 string : & ' static str ,
11011101}
11021102
1103- impl < U : ?Sized > std:: convert:: AsRef < U > for LocalInternedString
1103+ impl < U : ?Sized > std:: convert:: AsRef < U > for SymbolStr
11041104where
11051105 str : std:: convert:: AsRef < U >
11061106{
@@ -1110,28 +1110,28 @@ where
11101110 }
11111111}
11121112
1113- impl < T : std:: ops:: Deref < Target = str > > std:: cmp:: PartialEq < T > for LocalInternedString {
1113+ impl < T : std:: ops:: Deref < Target = str > > std:: cmp:: PartialEq < T > for SymbolStr {
11141114 fn eq ( & self , other : & T ) -> bool {
11151115 self . string == other. deref ( )
11161116 }
11171117}
11181118
1119- impl !Send for LocalInternedString { }
1120- impl !Sync for LocalInternedString { }
1119+ impl !Send for SymbolStr { }
1120+ impl !Sync for SymbolStr { }
11211121
1122- impl std:: ops:: Deref for LocalInternedString {
1122+ impl std:: ops:: Deref for SymbolStr {
11231123 type Target = str ;
11241124 #[ inline]
11251125 fn deref ( & self ) -> & str { self . string }
11261126}
11271127
1128- impl fmt:: Debug for LocalInternedString {
1128+ impl fmt:: Debug for SymbolStr {
11291129 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
11301130 fmt:: Debug :: fmt ( self . string , f)
11311131 }
11321132}
11331133
1134- impl fmt:: Display for LocalInternedString {
1134+ impl fmt:: Display for SymbolStr {
11351135 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
11361136 fmt:: Display :: fmt ( self . string , f)
11371137 }
0 commit comments