1
Fork 0

clippy::perf fixes

This commit is contained in:
Matthias Krüger 2021-11-04 20:16:57 +01:00
parent 4961b107f2
commit 28ef4169cc
9 changed files with 13 additions and 13 deletions

View file

@ -832,7 +832,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// FIXME(rcvalle): Add support for generalized identifiers. // FIXME(rcvalle): Add support for generalized identifiers.
// FIXME(rcvalle): Create distinct unnamed MDNodes for internal identifiers. // FIXME(rcvalle): Create distinct unnamed MDNodes for internal identifiers.
let typeid = typeid_for_fnabi(bx.tcx(), fn_abi); 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. // Test whether the function pointer is associated with the type identifier.
let cond = bx.type_test(fn_ptr, typeid_metadata); let cond = bx.type_test(fn_ptr, typeid_metadata);

View file

@ -250,7 +250,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// is associated with a type identifier). // is associated with a type identifier).
if cx.tcx().sess.is_sanitizer_cfi_enabled() { if cx.tcx().sess.is_sanitizer_cfi_enabled() {
let typeid = typeid_for_fnabi(cx.tcx(), fn_abi); let typeid = typeid_for_fnabi(cx.tcx(), fn_abi);
bx.type_metadata(llfn, typeid.clone()); bx.type_metadata(llfn, typeid);
} }
} }

View file

@ -632,11 +632,11 @@ fn tooltip<'tcx>(
for statement in statements { for statement in statements {
let source_range = source_range_no_file(tcx, &statement.source_info.span); let source_range = source_range_no_file(tcx, &statement.source_info.span);
text.push(format!( text.push(format!(
"\n{}{}: {}: {}", "\n{}{}: {}: {:?}",
TOOLTIP_INDENT, TOOLTIP_INDENT,
source_range, source_range,
statement_kind_name(&statement), statement_kind_name(&statement),
format!("{:?}", statement) statement
)); ));
} }
if let Some(term) = terminator { if let Some(term) = terminator {

View file

@ -67,7 +67,7 @@ crate fn dump_closure_profile(tcx: TyCtxt<'tcx>, closure_instance: Instance<'tcx
src_file.prefer_local(), src_file.prefer_local(),
line_nos line_nos
) { ) {
eprintln!("Error writting to file {}", e.to_string()) eprintln!("Error writing to file {}", e)
} }
} }
} }

View file

@ -236,7 +236,7 @@ impl<'tcx> DumpVisitor<'tcx> {
id, id,
span, span,
name: ident.to_string(), name: ident.to_string(),
qualname: format!("{}::{}", qualname, ident.to_string()), qualname: format!("{}::{}", qualname, ident),
value: typ, value: typ,
parent: None, parent: None,
children: vec![], 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. // Rust uses the id of the pattern for var lookups, so we'll use it too.
if !self.span.filter_generated(ident.span) { 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 id = id_from_hir_id(hir_id, &self.save_ctxt);
let span = self.span_from_span(ident.span); let span = self.span_from_span(ident.span);

View file

@ -1838,7 +1838,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
post.iter().map(|p| format!("- {}", p)).take(4).collect::<Vec<_>>().join("\n"), post.iter().map(|p| format!("- {}", p)).take(4).collect::<Vec<_>>().join("\n"),
post.len() - 4, 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::<Vec<_>>().join("\n"),) format!(":\n{}", post.iter().map(|p| format!("- {}", p)).collect::<Vec<_>>().join("\n"),)
} else if post.len() == 1 { } else if post.len() == 1 {
format!(": `{}`", post[0]) format!(": `{}`", post[0])

View file

@ -344,7 +344,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
"reorder the arguments: {}: `<{}>`", "reorder the arguments: {}: `<{}>`",
param_types_present param_types_present
.into_iter() .into_iter()
.map(|ord| format!("{}s", ord.to_string())) .map(|ord| format!("{}s", ord))
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(", then "), .join(", then "),
ordered_params ordered_params

View file

@ -772,7 +772,7 @@ fn infer_placeholder_type<'a>(
} else { } else {
err.span_note( err.span_note(
tcx.hir().body(body_id).value.span, 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 { } else {
diag.span_note( diag.span_note(
tcx.hir().body(body_id).value.span, 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),
); );
} }
} }

View file

@ -55,8 +55,8 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
_stdout: &[u8], _stdout: &[u8],
_state: &ConsoleTestState, _state: &ConsoleTestState,
) -> io::Result<()> { ) -> io::Result<()> {
// Because the testsuit node holds some of the information as attributes, we can't write it // Because the testsuite 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 // 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. // 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(); let duration = exec_time.map(|t| t.0).unwrap_or_default();
self.results.push((desc.clone(), result.clone(), duration)); self.results.push((desc.clone(), result.clone(), duration));