Skip to content

Commit 1b154a3

Browse files
committed
Rename LocalInternedString as SymbolStr.
It makes the relationship with `Symbol` clearer. The `Str` suffix matches the existing `Symbol::as_str()` method nicely, and is also consistent with it being a wrapper of `&str`.
1 parent 87cbf0a commit 1b154a3

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

src/librustc/ich/impls_syntax.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::mem;
99
use syntax::ast;
1010
use syntax::feature_gate;
1111
use syntax::parse::token;
12-
use syntax::symbol::LocalInternedString;
12+
use syntax::symbol::SymbolStr;
1313
use syntax::tokenstream;
1414
use syntax_pos::SourceFile;
1515

@@ -18,21 +18,21 @@ use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
1818
use smallvec::SmallVec;
1919
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher};
2020

21-
impl<'a> HashStable<StableHashingContext<'a>> for LocalInternedString {
21+
impl<'a> HashStable<StableHashingContext<'a>> for SymbolStr {
2222
#[inline]
2323
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
2424
let str = self as &str;
2525
str.hash_stable(hcx, hasher)
2626
}
2727
}
2828

29-
impl<'a> ToStableHashKey<StableHashingContext<'a>> for LocalInternedString {
30-
type KeyType = LocalInternedString;
29+
impl<'a> ToStableHashKey<StableHashingContext<'a>> for SymbolStr {
30+
type KeyType = SymbolStr;
3131

3232
#[inline]
3333
fn to_stable_hash_key(&self,
3434
_: &StableHashingContext<'a>)
35-
-> LocalInternedString {
35+
-> SymbolStr {
3636
self.clone()
3737
}
3838
}
@@ -45,12 +45,12 @@ impl<'a> HashStable<StableHashingContext<'a>> for ast::Name {
4545
}
4646

4747
impl<'a> ToStableHashKey<StableHashingContext<'a>> for ast::Name {
48-
type KeyType = LocalInternedString;
48+
type KeyType = SymbolStr;
4949

5050
#[inline]
5151
fn to_stable_hash_key(&self,
5252
_: &StableHashingContext<'a>)
53-
-> LocalInternedString {
53+
-> SymbolStr {
5454
self.as_str()
5555
}
5656
}

src/libsyntax_pos/symbol.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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
11041104
where
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

Comments
 (0)