From bbd7ce690452f28d459643d97fbae89109cf5808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 13 Apr 2022 22:18:28 +0200 Subject: [PATCH] couple of clippy::perf fixes --- .../src/debuginfo/metadata/enums/cpp_like.rs | 1 - compiler/rustc_errors/src/lib.rs | 2 +- compiler/rustc_expand/src/mbe/macro_parser.rs | 2 +- compiler/rustc_mir_build/src/thir/pattern/check_match.rs | 2 +- .../src/traits/error_reporting/suggestions.rs | 4 ++-- src/librustdoc/passes/html_tags.rs | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs index 31bb9ed3185..d6e2c8ccdf4 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs @@ -372,7 +372,6 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>( // Build the type node for each field. let variant_field_infos: SmallVec> = variant_range - .clone() .map(|variant_index| { let variant_struct_type_di_node = super::build_generator_variant_struct_type_di_node( cx, diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index c927fcb2109..4c1a3931864 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1208,7 +1208,7 @@ impl HandlerInner { (0, 0) => return, (0, _) => self.emitter.emit_diagnostic(&Diagnostic::new( Level::Warning, - DiagnosticMessage::Str(warnings.to_owned()), + DiagnosticMessage::Str(warnings), )), (_, 0) => { let _ = self.fatal(&errors); diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index b5f56d7d6dc..cda3d0fd2bf 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -589,7 +589,7 @@ impl TtParser { (_, 0) => { // Dump all possible `next_mps` into `cur_mps` for the next iteration. Then // process the next token. - self.cur_mps.extend(self.next_mps.drain(..)); + self.cur_mps.append(&mut self.next_mps); parser.to_mut().bump(); } diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 44caa2ac076..58e484e413d 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -844,7 +844,7 @@ fn non_exhaustive_match<'p, 'tcx>( format!( "{}{}{} => todo!()", comma, - snippet.strip_prefix(",").unwrap_or(&snippet), + snippet.strip_prefix(',').unwrap_or(&snippet), pattern ), )); diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index ead1f0126c4..7485c082f4e 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2724,9 +2724,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { &format!( "consider annotating `{}` with `#[derive({})]`", trait_pred.skip_binder().self_ty(), - diagnostic_name.to_string(), + diagnostic_name, ), - format!("#[derive({})]\n", diagnostic_name.to_string()), + format!("#[derive({})]\n", diagnostic_name), Applicability::MaybeIncorrect, ); } diff --git a/src/librustdoc/passes/html_tags.rs b/src/librustdoc/passes/html_tags.rs index 00e10c6d5a7..a620ffa9878 100644 --- a/src/librustdoc/passes/html_tags.rs +++ b/src/librustdoc/passes/html_tags.rs @@ -215,7 +215,7 @@ impl<'a, 'tcx> DocVisitor for InvalidHtmlTagsLinter<'a, 'tcx> { // We don't try to detect stuff `` because that's not valid HTML, // and we don't try to detect stuff `` because that's not valid Rust. if let Some(Some(generics_start)) = (is_open_tag - && dox[..range.end].ends_with(">")) + && dox[..range.end].ends_with('>')) .then(|| extract_path_backwards(&dox, range.start)) { let generics_sp = match super::source_span_for_markdown_range(