Skip to content

Commit b1c934e

Browse files
committed
Remove unnecessary sigils around Ident::as_str() calls.
1 parent 056d48a commit b1c934e

File tree

31 files changed

+41
-42
lines changed

31 files changed

+41
-42
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,7 @@ impl<'a> AstValidator<'a> {
580580

581581
/// An item in `extern { ... }` cannot use non-ascii identifier.
582582
fn check_foreign_item_ascii_only(&self, ident: Ident) {
583-
let symbol_str = ident.as_str();
584-
if !symbol_str.is_ascii() {
583+
if !ident.as_str().is_ascii() {
585584
let n = 83942;
586585
self.err_handler()
587586
.struct_span_err(

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ enum VariantInfo<'a, 'tcx> {
19221922
impl<'tcx> VariantInfo<'_, 'tcx> {
19231923
fn map_struct_name<R>(&self, f: impl FnOnce(&str) -> R) -> R {
19241924
match self {
1925-
VariantInfo::Adt(variant) => f(&variant.ident.as_str()),
1925+
VariantInfo::Adt(variant) => f(variant.ident.as_str()),
19261926
VariantInfo::Generator { variant_index, .. } => {
19271927
f(&GeneratorSubsts::variant_name(*variant_index))
19281928
}

compiler/rustc_expand/src/module.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ crate fn mod_dir_path(
103103
if let DirOwnership::Owned { relative } = &mut dir_ownership {
104104
if let Some(ident) = relative.take() {
105105
// Remove the relative offset.
106-
dir_path.push(&*ident.as_str());
106+
dir_path.push(ident.as_str());
107107
}
108108
}
109-
dir_path.push(&*ident.as_str());
109+
dir_path.push(ident.as_str());
110110

111111
(dir_path, dir_ownership)
112112
}

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2444,7 +2444,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
24442444
CtorKind::Fictive => {
24452445
let mut struct_fmt = fmt.debug_struct(&name);
24462446
for (field, place) in iter::zip(&variant_def.fields, places) {
2447-
struct_fmt.field(&field.ident.as_str(), place);
2447+
struct_fmt.field(field.ident.as_str(), place);
24482448
}
24492449
struct_fmt.finish()
24502450
}

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ impl<'a> Resolver<'a> {
11851185
("", " from prelude")
11861186
} else if b.is_extern_crate()
11871187
&& !b.is_import()
1188-
&& self.session.opts.externs.get(&ident.as_str()).is_some()
1188+
&& self.session.opts.externs.get(ident.as_str()).is_some()
11891189
{
11901190
("", " passed with `--extern`")
11911191
} else if add_built_in {

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
231231

232232
let is_assoc_fn = self.self_type_is_available(span);
233233
// Emit help message for fake-self from other languages (e.g., `this` in Javascript).
234-
if ["this", "my"].contains(&&*item_str.as_str()) && is_assoc_fn {
234+
if ["this", "my"].contains(&item_str.as_str()) && is_assoc_fn {
235235
err.span_suggestion_short(
236236
span,
237237
"you might have meant to use `self` here instead",
@@ -1372,7 +1372,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
13721372
fn likely_rust_type(path: &[Segment]) -> Option<Symbol> {
13731373
let name = path[path.len() - 1].ident.as_str();
13741374
// Common Java types
1375-
Some(match &*name {
1375+
Some(match name {
13761376
"byte" => sym::u8, // In Java, bytes are signed, but in practice one almost always wants unsigned bytes.
13771377
"short" => sym::i16,
13781378
"boolean" => sym::bool,

compiler/rustc_resolve/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn fast_print_path(path: &ast::Path) -> Symbol {
105105
path_str.push_str("::");
106106
}
107107
if segment.ident.name != kw::PathRoot {
108-
path_str.push_str(&segment.ident.as_str())
108+
path_str.push_str(segment.ident.as_str())
109109
}
110110
}
111111
Symbol::intern(&path_str)

compiler/rustc_save_analysis/src/sig.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ impl<'hir> Sig for hir::Generics<'hir> {
616616
if let hir::GenericParamKind::Const { .. } = param.kind {
617617
param_text.push_str("const ");
618618
}
619-
param_text.push_str(&param.name.ident().as_str());
619+
param_text.push_str(param.name.ident().as_str());
620620
defs.push(SigElement {
621621
id: id_from_hir_id(param.hir_id, scx),
622622
start: offset + text.len(),

compiler/rustc_symbol_mangling/src/v0.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ impl Printer<'tcx> for &mut SymbolMangler<'tcx> {
560560
ty::ExistentialPredicate::Projection(projection) => {
561561
let name = cx.tcx.associated_item(projection.item_def_id).ident;
562562
cx.push("p");
563-
cx.push_ident(&name.as_str());
563+
cx.push_ident(name.as_str());
564564
cx = projection.ty.print(cx)?;
565565
}
566566
ty::ExistentialPredicate::AutoTrait(def_id) => {

compiler/rustc_typeck/src/check/method/probe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
19081908
.associated_items(def_id)
19091909
.in_definition_order()
19101910
.filter(|x| {
1911-
let dist = lev_distance(&*name.as_str(), &x.ident.as_str());
1911+
let dist = lev_distance(name.as_str(), x.ident.as_str());
19121912
x.kind.namespace() == Namespace::ValueNS && dist > 0 && dist <= max_dist
19131913
})
19141914
.copied()

0 commit comments

Comments
 (0)