Skip to content

Commit a0b4b4d

Browse files
authored
Rollup merge of rust-lang#65776 - nnethercote:rename-LocalInternedString-and-more, r=estebank
Rename `LocalInternedString` and more This PR renames `LocalInternedString` as `SymbolStr`, removes an unnecessary `impl` from it, improves comments, and cleans up some `SymbolStr` uses. r? @estebank
2 parents e4931ea + d0db290 commit a0b4b4d

File tree

41 files changed

+103
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+103
-114
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ impl<'tcx> DepNodeParams<'tcx> for CrateNum {
525525
}
526526

527527
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
528-
tcx.crate_name(*self).as_str().to_string()
528+
tcx.crate_name(*self).to_string()
529529
}
530530
}
531531

src/librustc/hir/lowering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3382,7 +3382,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
33823382
// either in std or core, i.e. has either a `::std::ops::Range` or
33833383
// `::core::ops::Range` prefix.
33843384
fn is_range_path(path: &Path) -> bool {
3385-
let segs: Vec<_> = path.segments.iter().map(|seg| seg.ident.as_str().to_string()).collect();
3385+
let segs: Vec<_> = path.segments.iter().map(|seg| seg.ident.to_string()).collect();
33863386
let segs: Vec<_> = segs.iter().map(|seg| &**seg).collect();
33873387

33883388
// "{{root}}" is the equivalent of `::` prefix in `Path`.
@@ -3423,7 +3423,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
34233423
ExprKind::Call(ref func, _) => {
34243424
if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.kind {
34253425
if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.kind {
3426-
let new_call = segment.ident.as_str() == "new";
3426+
let new_call = segment.ident.name == sym::new;
34273427
return is_range_path(&path) && is_lit(sess, &expr.span) && new_call;
34283428
}
34293429
}

src/librustc/hir/print.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ impl<'a> State<'a> {
564564
}
565565
hir::ItemKind::GlobalAsm(ref ga) => {
566566
self.head(visibility_qualified(&item.vis, "global asm"));
567-
self.s.word(ga.asm.as_str().to_string());
567+
self.s.word(ga.asm.to_string());
568568
self.end()
569569
}
570570
hir::ItemKind::TyAlias(ref ty, ref generics) => {
@@ -1855,7 +1855,7 @@ impl<'a> State<'a> {
18551855
self.commasep(Inconsistent, &decl.inputs, |s, ty| {
18561856
s.ibox(INDENT_UNIT);
18571857
if let Some(arg_name) = arg_names.get(i) {
1858-
s.s.word(arg_name.as_str().to_string());
1858+
s.s.word(arg_name.to_string());
18591859
s.s.word(":");
18601860
s.s.space();
18611861
} else if let Some(body_id) = body_id {

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/librustc/mir/mono.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ impl CodegenUnitNameBuilder<'tcx> {
486486
if self.tcx.sess.opts.debugging_opts.human_readable_cgu_names {
487487
cgu_name
488488
} else {
489-
let cgu_name = &cgu_name.as_str()[..];
489+
let cgu_name = &cgu_name.as_str();
490490
Symbol::intern(&CodegenUnit::mangle_name(cgu_name))
491491
}
492492
}

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11301130
let restrict_msg = "consider further restricting this bound";
11311131
let param_name = self_ty.to_string();
11321132
for param in generics.params.iter().filter(|p| {
1133-
&param_name == std::convert::AsRef::<str>::as_ref(&p.name.ident().as_str())
1133+
p.name.ident().as_str() == param_name
11341134
}) {
11351135
if param_name.starts_with("impl ") {
11361136
// `impl Trait` in argument:

src/librustc/traits/on_unimplemented.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl<'tcx> OnUnimplementedDirective {
180180
c.ident().map_or(false, |ident| {
181181
options.contains(&(
182182
ident.name,
183-
c.value_str().map(|s| s.as_str().to_string())
183+
c.value_str().map(|s| s.to_string())
184184
))
185185
})
186186
}) {

src/librustc/ty/query/on_disk_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl<'sess> OnDiskCache<'sess> {
264264
let sorted_cnums = sorted_cnums_including_local_crate(tcx);
265265
let prev_cnums: Vec<_> = sorted_cnums.iter()
266266
.map(|&cnum| {
267-
let crate_name = tcx.original_crate_name(cnum).as_str().to_string();
267+
let crate_name = tcx.original_crate_name(cnum).to_string();
268268
let crate_disambiguator = tcx.crate_disambiguator(cnum);
269269
(cnum.as_u32(), crate_name, crate_disambiguator)
270270
})

src/librustc_codegen_llvm/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ pub fn from_fn_attrs(
314314
codegen_fn_attrs.target_features
315315
.iter()
316316
.map(|f| {
317-
let feature = &*f.as_str();
317+
let feature = &f.as_str();
318318
format!("+{}", llvm_util::to_llvm_feature(cx.tcx.sess, feature))
319319
})
320320
)

src/librustc_codegen_llvm/debuginfo/namespace.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ pub fn item_namespace(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope {
3434
});
3535

3636
let namespace_name = match def_key.disambiguated_data.data {
37-
DefPathData::CrateRoot => cx.tcx.crate_name(def_id.krate).as_str(),
38-
data => data.as_symbol().as_str()
37+
DefPathData::CrateRoot => cx.tcx.crate_name(def_id.krate),
38+
data => data.as_symbol()
3939
};
4040

41-
let namespace_name = SmallCStr::new(&namespace_name);
41+
let namespace_name = SmallCStr::new(&namespace_name.as_str());
4242

4343
let scope = unsafe {
4444
llvm::LLVMRustDIBuilderCreateNameSpace(

0 commit comments

Comments
 (0)