From 28ef4169ccc62f3f1a35b6b002c29ea9bc6b2334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 4 Nov 2021 20:16:57 +0100 Subject: [PATCH] clippy::perf fixes --- compiler/rustc_codegen_ssa/src/mir/block.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/mod.rs | 2 +- compiler/rustc_middle/src/mir/spanview.rs | 4 ++-- compiler/rustc_monomorphize/src/util.rs | 2 +- compiler/rustc_save_analysis/src/dump_visitor.rs | 4 ++-- .../rustc_trait_selection/src/traits/error_reporting/mod.rs | 2 +- compiler/rustc_typeck/src/astconv/generics.rs | 2 +- compiler/rustc_typeck/src/collect/type_of.rs | 4 ++-- library/test/src/formatters/junit.rs | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 297dcde99b3..a9471f7b771 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -832,7 +832,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // FIXME(rcvalle): Add support for generalized identifiers. // FIXME(rcvalle): Create distinct unnamed MDNodes for internal identifiers. let typeid = typeid_for_fnabi(bx.tcx(), fn_abi); - let typeid_metadata = bx.typeid_metadata(typeid.clone()); + let typeid_metadata = bx.typeid_metadata(typeid); // Test whether the function pointer is associated with the type identifier. let cond = bx.type_test(fn_ptr, typeid_metadata); diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index 1cd400eecfb..1ef863e84af 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -250,7 +250,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( // is associated with a type identifier). if cx.tcx().sess.is_sanitizer_cfi_enabled() { let typeid = typeid_for_fnabi(cx.tcx(), fn_abi); - bx.type_metadata(llfn, typeid.clone()); + bx.type_metadata(llfn, typeid); } } diff --git a/compiler/rustc_middle/src/mir/spanview.rs b/compiler/rustc_middle/src/mir/spanview.rs index 42683dac426..1260c691e78 100644 --- a/compiler/rustc_middle/src/mir/spanview.rs +++ b/compiler/rustc_middle/src/mir/spanview.rs @@ -632,11 +632,11 @@ fn tooltip<'tcx>( for statement in statements { let source_range = source_range_no_file(tcx, &statement.source_info.span); text.push(format!( - "\n{}{}: {}: {}", + "\n{}{}: {}: {:?}", TOOLTIP_INDENT, source_range, statement_kind_name(&statement), - format!("{:?}", statement) + statement )); } if let Some(term) = terminator { diff --git a/compiler/rustc_monomorphize/src/util.rs b/compiler/rustc_monomorphize/src/util.rs index 799b4e18c24..4392c02f874 100644 --- a/compiler/rustc_monomorphize/src/util.rs +++ b/compiler/rustc_monomorphize/src/util.rs @@ -67,7 +67,7 @@ crate fn dump_closure_profile(tcx: TyCtxt<'tcx>, closure_instance: Instance<'tcx src_file.prefer_local(), line_nos ) { - eprintln!("Error writting to file {}", e.to_string()) + eprintln!("Error writing to file {}", e) } } } diff --git a/compiler/rustc_save_analysis/src/dump_visitor.rs b/compiler/rustc_save_analysis/src/dump_visitor.rs index f4567b33483..f1a5282b088 100644 --- a/compiler/rustc_save_analysis/src/dump_visitor.rs +++ b/compiler/rustc_save_analysis/src/dump_visitor.rs @@ -236,7 +236,7 @@ impl<'tcx> DumpVisitor<'tcx> { id, span, name: ident.to_string(), - qualname: format!("{}::{}", qualname, ident.to_string()), + qualname: format!("{}::{}", qualname, ident), value: typ, parent: None, children: vec![], @@ -889,7 +889,7 @@ impl<'tcx> DumpVisitor<'tcx> { // Rust uses the id of the pattern for var lookups, so we'll use it too. if !self.span.filter_generated(ident.span) { - let qualname = format!("{}${}", ident.to_string(), hir_id); + let qualname = format!("{}${}", ident, hir_id); let id = id_from_hir_id(hir_id, &self.save_ctxt); let span = self.span_from_span(ident.span); diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 5d17693dc08..a9125b9fd22 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1838,7 +1838,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { post.iter().map(|p| format!("- {}", p)).take(4).collect::>().join("\n"), post.len() - 4, ) - } else if post.len() > 1 || (post.len() == 1 && post[0].contains("\n")) { + } else if post.len() > 1 || (post.len() == 1 && post[0].contains('\n')) { format!(":\n{}", post.iter().map(|p| format!("- {}", p)).collect::>().join("\n"),) } else if post.len() == 1 { format!(": `{}`", post[0]) diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index 5befe44802f..84327a2880e 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -344,7 +344,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { "reorder the arguments: {}: `<{}>`", param_types_present .into_iter() - .map(|ord| format!("{}s", ord.to_string())) + .map(|ord| format!("{}s", ord)) .collect::>() .join(", then "), ordered_params diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index 96211be8cdc..a6ea8abdf3f 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -772,7 +772,7 @@ fn infer_placeholder_type<'a>( } else { err.span_note( tcx.hir().body(body_id).value.span, - &format!("however, the inferred type `{}` cannot be named", ty.to_string()), + &format!("however, the inferred type `{}` cannot be named", ty), ); } } @@ -796,7 +796,7 @@ fn infer_placeholder_type<'a>( } else { diag.span_note( tcx.hir().body(body_id).value.span, - &format!("however, the inferred type `{}` cannot be named", ty.to_string()), + &format!("however, the inferred type `{}` cannot be named", ty), ); } } diff --git a/library/test/src/formatters/junit.rs b/library/test/src/formatters/junit.rs index e2aebee916d..fa23cf26896 100644 --- a/library/test/src/formatters/junit.rs +++ b/library/test/src/formatters/junit.rs @@ -55,8 +55,8 @@ impl OutputFormatter for JunitFormatter { _stdout: &[u8], _state: &ConsoleTestState, ) -> io::Result<()> { - // Because the testsuit node holds some of the information as attributes, we can't write it - // until all of the tests has ran. Instead of writting every result as they come in, we add + // Because the testsuite node holds some of the information as attributes, we can't write it + // until all of the tests have finished. Instead of writing every result as they come in, we add // them to a Vec and write them all at once when run is complete. let duration = exec_time.map(|t| t.0).unwrap_or_default(); self.results.push((desc.clone(), result.clone(), duration));