Skip to content

Commit 056d48a

Browse files
committed
Remove unnecessary sigils around Symbol::as_str() calls.
1 parent 8cddcd3 commit 056d48a

File tree

104 files changed

+189
-192
lines changed

Some content is hidden

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

104 files changed

+189
-192
lines changed

Diff for: compiler/rustc_ast/src/util/literal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ impl LitKind {
3535
LitKind::Bool(symbol == kw::True)
3636
}
3737
token::Byte => {
38-
return unescape_byte(&symbol.as_str())
38+
return unescape_byte(symbol.as_str())
3939
.map(LitKind::Byte)
4040
.map_err(|_| LitError::LexerError);
4141
}
4242
token::Char => {
43-
return unescape_char(&symbol.as_str())
43+
return unescape_char(symbol.as_str())
4444
.map(LitKind::Char)
4545
.map_err(|_| LitError::LexerError);
4646
}

Diff for: compiler/rustc_ast_lowering/src/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12781278
}
12791279

12801280
pub(super) fn lower_abi(&mut self, abi: StrLit) -> abi::Abi {
1281-
abi::lookup(&abi.symbol_unescaped.as_str()).unwrap_or_else(|| {
1281+
abi::lookup(abi.symbol_unescaped.as_str()).unwrap_or_else(|| {
12821282
self.error_on_invalid_abi(abi);
12831283
abi::Abi::Rust
12841284
})

Diff for: compiler/rustc_ast_passes/src/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'a> PostExpansionVisitor<'a> {
6161
fn check_abi(&self, abi: ast::StrLit) {
6262
let ast::StrLit { symbol_unescaped, span, .. } = abi;
6363

64-
match &*symbol_unescaped.as_str() {
64+
match symbol_unescaped.as_str() {
6565
// Stable
6666
"Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
6767
| "system" => {}

Diff for: compiler/rustc_ast_pretty/src/pprust/state.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub fn literal_to_string(lit: token::Lit) -> String {
204204
};
205205

206206
if let Some(suffix) = suffix {
207-
out.push_str(&suffix.as_str())
207+
out.push_str(suffix.as_str())
208208
}
209209

210210
out
@@ -384,7 +384,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
384384
}
385385

386386
fn print_symbol(&mut self, sym: Symbol, style: ast::StrStyle) {
387-
self.print_string(&sym.as_str(), style);
387+
self.print_string(sym.as_str(), style);
388388
}
389389

390390
fn print_inner_attributes(&mut self, attrs: &[ast::Attribute]) {

Diff for: compiler/rustc_attr/src/builtin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ where
236236

237237
// These unwraps are safe because `get` ensures the meta item
238238
// is a name/value pair string literal.
239-
issue_num = match &*issue.unwrap().as_str() {
239+
issue_num = match issue.unwrap().as_str() {
240240
"none" => None,
241241
issue => {
242242
let emit_diag = |msg: &str| {
@@ -301,7 +301,7 @@ where
301301

302302
match (feature, reason, issue) {
303303
(Some(feature), reason, Some(_)) => {
304-
if !rustc_lexer::is_ident(&feature.as_str()) {
304+
if !rustc_lexer::is_ident(feature.as_str()) {
305305
handle_errors(
306306
&sess.parse_sess,
307307
attr.span,
@@ -535,7 +535,7 @@ pub fn eval_condition(
535535
return false;
536536
}
537537
};
538-
let min_version = match parse_version(&min_version.as_str(), false) {
538+
let min_version = match parse_version(min_version.as_str(), false) {
539539
Some(ver) => ver,
540540
None => {
541541
sess.span_diagnostic

Diff for: compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
416416
tcx,
417417
generics,
418418
&mut err,
419-
&param.name.as_str(),
419+
param.name.as_str(),
420420
"Copy",
421421
None,
422422
);

Diff for: compiler/rustc_borrowck/src/diagnostics/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
206206
{
207207
let local_info = &self.body.local_decls[local].local_info;
208208
if let Some(box LocalInfo::StaticRef { def_id, .. }) = *local_info {
209-
buf.push_str(&self.infcx.tcx.item_name(def_id).as_str());
209+
buf.push_str(self.infcx.tcx.item_name(def_id).as_str());
210210
} else {
211211
unreachable!();
212212
}
@@ -318,7 +318,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
318318
let decl = &self.body.local_decls[local];
319319
match self.local_names[local] {
320320
Some(name) if !decl.from_compiler_desugaring() => {
321-
buf.push_str(&name.as_str());
321+
buf.push_str(name.as_str());
322322
Ok(())
323323
}
324324
_ => Err(()),

Diff for: compiler/rustc_builtin_macros/src/asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
572572
template_snippet.as_ref().map(|s| Symbol::intern(s)),
573573
template_sp,
574574
));
575-
let template_str = &template_str.as_str();
575+
let template_str = template_str.as_str();
576576

577577
if let Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) = ecx.sess.asm_arch {
578578
let find_span = |needle: &str| -> Span {

Diff for: compiler/rustc_builtin_macros/src/concat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn expand_concat(
2121
match e.kind {
2222
ast::ExprKind::Lit(ref lit) => match lit.kind {
2323
ast::LitKind::Str(ref s, _) | ast::LitKind::Float(ref s, _) => {
24-
accumulator.push_str(&s.as_str());
24+
accumulator.push_str(s.as_str());
2525
}
2626
ast::LitKind::Char(c) => {
2727
accumulator.push(c);

Diff for: compiler/rustc_builtin_macros/src/concat_idents.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn expand_concat_idents<'cx>(
2929
} else {
3030
if let TokenTree::Token(token) = e {
3131
if let Some((ident, _)) = token.ident() {
32-
res_str.push_str(&ident.name.as_str());
32+
res_str.push_str(ident.name.as_str());
3333
continue;
3434
}
3535
}

Diff for: compiler/rustc_builtin_macros/src/derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn report_bad_target(sess: &Session, item: &Annotatable, span: Span) -> bool {
121121

122122
fn report_unexpected_literal(sess: &Session, lit: &ast::Lit) {
123123
let help_msg = match lit.token.kind {
124-
token::Str if rustc_lexer::is_ident(&lit.token.symbol.as_str()) => {
124+
token::Str if rustc_lexer::is_ident(lit.token.symbol.as_str()) => {
125125
format!("try using `#[derive({})]`", lit.token.symbol)
126126
}
127127
_ => "for example, write `#[derive(Debug)]` for `Debug`".to_string(),

Diff for: compiler/rustc_builtin_macros/src/env.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ pub fn expand_env<'cx>(
8080
}
8181

8282
let sp = cx.with_def_site_ctxt(sp);
83-
let value = env::var(&*var.as_str()).ok().as_deref().map(Symbol::intern);
83+
let value = env::var(var.as_str()).ok().as_deref().map(Symbol::intern);
8484
cx.sess.parse_sess.env_depinfo.borrow_mut().insert((var, value));
8585
let e = match value {
8686
None => {
87-
cx.span_err(sp, &msg.as_str());
87+
cx.span_err(sp, msg.as_str());
8888
return DummyResult::any(sp);
8989
}
9090
Some(value) => cx.expr_str(sp, value),

Diff for: compiler/rustc_builtin_macros/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ pub fn expand_preparsed_format_args(
955955
ast::StrStyle::Raw(raw) => Some(raw as usize),
956956
};
957957

958-
let fmt_str = &fmt_str.as_str(); // for the suggestions below
958+
let fmt_str = fmt_str.as_str(); // for the suggestions below
959959
let fmt_snippet = ecx.source_map().span_to_snippet(fmt_sp).ok();
960960
let mut parser = parse::Parser::new(
961961
fmt_str,

Diff for: compiler/rustc_codegen_cranelift/src/driver/aot.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn reuse_workproduct_for_cgu(
8484
let work_product = cgu.work_product(tcx);
8585
if let Some(saved_file) = &work_product.saved_file {
8686
let obj_out =
87-
tcx.output_filenames(()).temp_path(OutputType::Object, Some(&cgu.name().as_str()));
87+
tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
8888
object = Some(obj_out.clone());
8989
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &saved_file);
9090
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
@@ -176,7 +176,7 @@ fn module_codegen(
176176
)
177177
});
178178

179-
codegen_global_asm(tcx, &cgu.name().as_str(), &cx.global_asm);
179+
codegen_global_asm(tcx, cgu.name().as_str(), &cx.global_asm);
180180

181181
codegen_result
182182
}
@@ -207,7 +207,7 @@ pub(crate) fn run_aot(
207207
cgus.iter()
208208
.map(|cgu| {
209209
let cgu_reuse = determine_cgu_reuse(tcx, cgu);
210-
tcx.sess.cgu_reuse_tracker.set_actual_reuse(&cgu.name().as_str(), cgu_reuse);
210+
tcx.sess.cgu_reuse_tracker.set_actual_reuse(cgu.name().as_str(), cgu_reuse);
211211

212212
match cgu_reuse {
213213
_ if backend_config.disable_incr_cache => {}

Diff for: compiler/rustc_codegen_gcc/src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
3333
return value;
3434
}
3535

36-
let global = self.global_string(&*symbol.as_str());
36+
let global = self.global_string(symbol.as_str());
3737

3838
self.const_cstr_cache.borrow_mut().insert(symbol, global);
3939
global

Diff for: compiler/rustc_codegen_gcc/src/declare.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
1717
global.set_tls_model(self.tls_model);
1818
}
1919
if let Some(link_section) = link_section {
20-
global.set_link_section(&link_section.as_str());
20+
global.set_link_section(link_section.as_str());
2121
}
2222
global
2323
}
@@ -53,7 +53,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
5353
global.set_tls_model(self.tls_model);
5454
}
5555
if let Some(link_section) = link_section {
56-
global.set_link_section(&link_section.as_str());
56+
global.set_link_section(link_section.as_str());
5757
}
5858
let global_address = global.get_address(None);
5959
self.globals.borrow_mut().insert(name.to_string(), global_address);

Diff for: compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
8888
let arg_tys = sig.inputs();
8989
let ret_ty = sig.output();
9090
let name = tcx.item_name(def_id);
91-
let name_str = &*name.as_str();
91+
let name_str = name.as_str();
9292

9393
let llret_ty = self.layout_of(ret_ty).gcc_type(self, true);
9494
let result = PlaceRef::new_sized(llresult, fn_abi.ret.layout);

Diff for: compiler/rustc_codegen_gcc/src/intrinsic/simd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>,
5252
let sig =
5353
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), callee_ty.fn_sig(tcx));
5454
let arg_tys = sig.inputs();
55-
let name_str = &*name.as_str();
55+
let name_str = name.as_str();
5656

5757
// every intrinsic below takes a SIMD vector as its first argument
5858
require_simd!(arg_tys[0], "input");

Diff for: compiler/rustc_codegen_llvm/src/attributes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
322322
.target_features
323323
.iter()
324324
.flat_map(|f| {
325-
let feature = &f.as_str();
325+
let feature = f.as_str();
326326
llvm_util::to_llvm_feature(cx.tcx.sess, feature)
327327
.into_iter()
328328
.map(|f| format!("+{}", f))
@@ -347,7 +347,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
347347

348348
let name =
349349
codegen_fn_attrs.link_name.unwrap_or_else(|| cx.tcx.item_name(instance.def_id()));
350-
let name = CString::new(&name.as_str()[..]).unwrap();
350+
let name = CString::new(name.as_str()).unwrap();
351351
llvm::AddFunctionAttrStringValue(
352352
llfn,
353353
llvm::AttributePlace::Function,

Diff for: compiler/rustc_codegen_llvm/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn compile_codegen_unit(
8282
&[cgu_name.to_string(), cgu.size_estimate().to_string()],
8383
);
8484
// Instantiate monomorphizations without filling out definitions yet...
85-
let llvm_module = ModuleLlvm::new(tcx, &cgu_name.as_str());
85+
let llvm_module = ModuleLlvm::new(tcx, cgu_name.as_str());
8686
{
8787
let cx = CodegenCx::new(tcx, cgu, &llvm_module);
8888
let mono_items = cx.codegen_unit.items_in_deterministic_order(cx.tcx);
@@ -146,7 +146,7 @@ pub fn set_link_section(llval: &Value, attrs: &CodegenFnAttrs) {
146146
None => return,
147147
};
148148
unsafe {
149-
let buf = SmallCStr::new(&sect.as_str());
149+
let buf = SmallCStr::new(sect.as_str());
150150
llvm::LLVMSetSection(llval, buf.as_ptr());
151151
}
152152
}

Diff for: compiler/rustc_codegen_llvm/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
320320

321321
let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None {
322322
let dctx = debuginfo::CrateDebugContext::new(llmod);
323-
debuginfo::metadata::compile_unit_metadata(tcx, &codegen_unit.name().as_str(), &dctx);
323+
debuginfo::metadata::compile_unit_metadata(tcx, codegen_unit.name().as_str(), &dctx);
324324
Some(dctx)
325325
} else {
326326
None

Diff for: compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ pub fn compile_unit_metadata(
10331033
) -> &'ll DIDescriptor {
10341034
let mut name_in_debuginfo = match tcx.sess.local_crate_source_file {
10351035
Some(ref path) => path.clone(),
1036-
None => PathBuf::from(&*tcx.crate_name(LOCAL_CRATE).as_str()),
1036+
None => PathBuf::from(tcx.crate_name(LOCAL_CRATE).as_str()),
10371037
};
10381038

10391039
// The OSX linker has an idiosyncrasy where it will ignore some debuginfo
@@ -1353,7 +1353,7 @@ fn closure_saved_names_of_captured_variables(tcx: TyCtxt<'tcx>, def_id: DefId) -
13531353
_ => return None,
13541354
};
13551355
let prefix = if is_ref { "_ref__" } else { "" };
1356-
Some(prefix.to_owned() + &var.name.as_str())
1356+
Some(prefix.to_owned() + var.name.as_str())
13571357
})
13581358
.collect::<Vec<_>>()
13591359
}
@@ -2421,7 +2421,7 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> &'ll DIAr
24212421
cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty);
24222422
let actual_type_metadata =
24232423
type_metadata(cx, actual_type, rustc_span::DUMMY_SP);
2424-
let name = &name.as_str();
2424+
let name = name.as_str();
24252425
Some(unsafe {
24262426
Some(llvm::LLVMRustDIBuilderCreateTemplateTypeParameter(
24272427
DIB(cx),

Diff for: compiler/rustc_codegen_ssa/src/back/command.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Command {
4848
}
4949

5050
pub fn sym_arg(&mut self, arg: Symbol) -> &mut Command {
51-
self.arg(&*arg.as_str());
51+
self.arg(arg.as_str());
5252
self
5353
}
5454

Diff for: compiler/rustc_codegen_ssa/src/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
8888
sess,
8989
crate_type,
9090
outputs,
91-
&codegen_results.crate_info.local_crate_name.as_str(),
91+
codegen_results.crate_info.local_crate_name.as_str(),
9292
);
9393
match crate_type {
9494
CrateType::Rlib => {

Diff for: compiler/rustc_codegen_ssa/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
672672
}
673673

674674
let cgu_reuse = cgu_reuse[i];
675-
tcx.sess.cgu_reuse_tracker.set_actual_reuse(&cgu.name().as_str(), cgu_reuse);
675+
tcx.sess.cgu_reuse_tracker.set_actual_reuse(cgu.name().as_str(), cgu_reuse);
676676

677677
match cgu_reuse {
678678
CguReuse::No => {

Diff for: compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ fn push_unqualified_item_name(
516516
) {
517517
match disambiguated_data.data {
518518
DefPathData::CrateRoot => {
519-
output.push_str(&tcx.crate_name(def_id.krate).as_str());
519+
output.push_str(tcx.crate_name(def_id.krate).as_str());
520520
}
521521
DefPathData::ClosureExpr if tcx.generator_kind(def_id).is_some() => {
522522
// Generators look like closures, but we want to treat them differently
@@ -529,7 +529,7 @@ fn push_unqualified_item_name(
529529
}
530530
_ => match disambiguated_data.data.name() {
531531
DefPathDataName::Named(name) => {
532-
output.push_str(&name.as_str());
532+
output.push_str(name.as_str());
533533
}
534534
DefPathDataName::Anon { namespace } => {
535535
if cpp_like_names(tcx) {

Diff for: compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
6868
let arg_tys = sig.inputs();
6969
let ret_ty = sig.output();
7070
let name = bx.tcx().item_name(def_id);
71-
let name_str = &*name.as_str();
71+
let name_str = name.as_str();
7272

7373
let llret_ty = bx.backend_type(bx.layout_of(ret_ty));
7474
let result = PlaceRef::new_sized(llresult, fn_abi.ret.layout);
@@ -375,7 +375,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
375375
use crate::common::AtomicOrdering::*;
376376
use crate::common::{AtomicRmwBinOp, SynchronizationScope};
377377

378-
let split: Vec<&str> = name_str.split('_').collect();
378+
let split: Vec<_> = name_str.split('_').collect();
379379

380380
let is_cxchg = split[1] == "cxchg" || split[1] == "cxchgweak";
381381
let (order, failorder) = match split.len() {

Diff for: compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
8282
) -> MPlaceTy<'tcx, M::PointerTag> {
8383
let loc_details = &self.tcx.sess.opts.debugging_opts.location_detail;
8484
let file = if loc_details.file {
85-
self.allocate_str(&filename.as_str(), MemoryKind::CallerLocation, Mutability::Not)
85+
self.allocate_str(filename.as_str(), MemoryKind::CallerLocation, Mutability::Not)
8686
} else {
8787
// FIXME: This creates a new allocation each time. It might be preferable to
8888
// perform this allocation only once, and re-use the `MPlaceTy`.

Diff for: compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
8888
}
8989

9090
fn path_crate(mut self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {
91-
self.path.push_str(&self.tcx.crate_name(cnum).as_str());
91+
self.path.push_str(self.tcx.crate_name(cnum).as_str());
9292
Ok(self)
9393
}
9494

Diff for: compiler/rustc_expand/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fn get_features(
171171
}
172172

173173
if let Some(allowed) = sess.opts.debugging_opts.allow_features.as_ref() {
174-
if allowed.iter().all(|f| name.as_str() != *f) {
174+
if allowed.iter().all(|f| name.as_str() != f) {
175175
struct_span_err!(
176176
span_handler,
177177
mi.span(),

0 commit comments

Comments
 (0)