Skip to content

Commit 28ef416

Browse files
committed
clippy::perf fixes
1 parent 4961b10 commit 28ef416

File tree

9 files changed

+13
-13
lines changed

9 files changed

+13
-13
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
832832
// FIXME(rcvalle): Add support for generalized identifiers.
833833
// FIXME(rcvalle): Create distinct unnamed MDNodes for internal identifiers.
834834
let typeid = typeid_for_fnabi(bx.tcx(), fn_abi);
835-
let typeid_metadata = bx.typeid_metadata(typeid.clone());
835+
let typeid_metadata = bx.typeid_metadata(typeid);
836836

837837
// Test whether the function pointer is associated with the type identifier.
838838
let cond = bx.type_test(fn_ptr, typeid_metadata);

compiler/rustc_codegen_ssa/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
250250
// is associated with a type identifier).
251251
if cx.tcx().sess.is_sanitizer_cfi_enabled() {
252252
let typeid = typeid_for_fnabi(cx.tcx(), fn_abi);
253-
bx.type_metadata(llfn, typeid.clone());
253+
bx.type_metadata(llfn, typeid);
254254
}
255255
}
256256

compiler/rustc_middle/src/mir/spanview.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,11 @@ fn tooltip<'tcx>(
632632
for statement in statements {
633633
let source_range = source_range_no_file(tcx, &statement.source_info.span);
634634
text.push(format!(
635-
"\n{}{}: {}: {}",
635+
"\n{}{}: {}: {:?}",
636636
TOOLTIP_INDENT,
637637
source_range,
638638
statement_kind_name(&statement),
639-
format!("{:?}", statement)
639+
statement
640640
));
641641
}
642642
if let Some(term) = terminator {

compiler/rustc_monomorphize/src/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ crate fn dump_closure_profile(tcx: TyCtxt<'tcx>, closure_instance: Instance<'tcx
6767
src_file.prefer_local(),
6868
line_nos
6969
) {
70-
eprintln!("Error writting to file {}", e.to_string())
70+
eprintln!("Error writing to file {}", e)
7171
}
7272
}
7373
}

compiler/rustc_save_analysis/src/dump_visitor.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl<'tcx> DumpVisitor<'tcx> {
236236
id,
237237
span,
238238
name: ident.to_string(),
239-
qualname: format!("{}::{}", qualname, ident.to_string()),
239+
qualname: format!("{}::{}", qualname, ident),
240240
value: typ,
241241
parent: None,
242242
children: vec![],
@@ -889,7 +889,7 @@ impl<'tcx> DumpVisitor<'tcx> {
889889

890890
// Rust uses the id of the pattern for var lookups, so we'll use it too.
891891
if !self.span.filter_generated(ident.span) {
892-
let qualname = format!("{}${}", ident.to_string(), hir_id);
892+
let qualname = format!("{}${}", ident, hir_id);
893893
let id = id_from_hir_id(hir_id, &self.save_ctxt);
894894
let span = self.span_from_span(ident.span);
895895

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
18381838
post.iter().map(|p| format!("- {}", p)).take(4).collect::<Vec<_>>().join("\n"),
18391839
post.len() - 4,
18401840
)
1841-
} else if post.len() > 1 || (post.len() == 1 && post[0].contains("\n")) {
1841+
} else if post.len() > 1 || (post.len() == 1 && post[0].contains('\n')) {
18421842
format!(":\n{}", post.iter().map(|p| format!("- {}", p)).collect::<Vec<_>>().join("\n"),)
18431843
} else if post.len() == 1 {
18441844
format!(": `{}`", post[0])

compiler/rustc_typeck/src/astconv/generics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
344344
"reorder the arguments: {}: `<{}>`",
345345
param_types_present
346346
.into_iter()
347-
.map(|ord| format!("{}s", ord.to_string()))
347+
.map(|ord| format!("{}s", ord))
348348
.collect::<Vec<String>>()
349349
.join(", then "),
350350
ordered_params

compiler/rustc_typeck/src/collect/type_of.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ fn infer_placeholder_type<'a>(
772772
} else {
773773
err.span_note(
774774
tcx.hir().body(body_id).value.span,
775-
&format!("however, the inferred type `{}` cannot be named", ty.to_string()),
775+
&format!("however, the inferred type `{}` cannot be named", ty),
776776
);
777777
}
778778
}
@@ -796,7 +796,7 @@ fn infer_placeholder_type<'a>(
796796
} else {
797797
diag.span_note(
798798
tcx.hir().body(body_id).value.span,
799-
&format!("however, the inferred type `{}` cannot be named", ty.to_string()),
799+
&format!("however, the inferred type `{}` cannot be named", ty),
800800
);
801801
}
802802
}

library/test/src/formatters/junit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
5555
_stdout: &[u8],
5656
_state: &ConsoleTestState,
5757
) -> io::Result<()> {
58-
// Because the testsuit node holds some of the information as attributes, we can't write it
59-
// until all of the tests has ran. Instead of writting every result as they come in, we add
58+
// Because the testsuite node holds some of the information as attributes, we can't write it
59+
// until all of the tests have finished. Instead of writing every result as they come in, we add
6060
// them to a Vec and write them all at once when run is complete.
6161
let duration = exec_time.map(|t| t.0).unwrap_or_default();
6262
self.results.push((desc.clone(), result.clone(), duration));

0 commit comments

Comments
 (0)