about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-08-01 09:15:15 +0000
committerbors <bors@rust-lang.org>2021-08-01 09:15:15 +0000
commitaadd6189ad5c81f50d942c584ed1c1b49892765f (patch)
tree0dbe207064f82de546fcbe6f63bb12b40f7c322e /compiler/rustc_mir/src
parentf381e77d3590bc36f09b0d48cffb504f92febf5e (diff)
parent3fd8cbb404666e0b979efa9a886674b4a9f58868 (diff)
downloadrust-aadd6189ad5c81f50d942c584ed1c1b49892765f.tar.gz
rust-aadd6189ad5c81f50d942c584ed1c1b49892765f.zip
Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa
more clippy::complexity fixes

(also a couple of clippy::perf fixes)
Diffstat (limited to 'compiler/rustc_mir/src')
-rw-r--r--compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs2
-rw-r--r--compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs2
-rw-r--r--compiler/rustc_mir/src/monomorphize/partitioning/merging.rs2
-rw-r--r--compiler/rustc_mir/src/transform/check_consts/ops.rs2
-rw-r--r--compiler/rustc_mir/src/transform/coverage/debug.rs4
-rw-r--r--compiler/rustc_mir/src/transform/coverage/graph.rs4
-rw-r--r--compiler/rustc_mir/src/transform/inline.rs4
-rw-r--r--compiler/rustc_mir/src/transform/lower_intrinsics.rs4
-rw-r--r--compiler/rustc_mir/src/util/pretty.rs2
9 files changed, 13 insertions, 13 deletions
diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs
index a9bfbb51573..a3ea1700634 100644
--- a/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs
@@ -320,7 +320,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
                                         .map(|n| format!("`{}`", n))
                                         .unwrap_or_else(|| "the mutable reference".to_string()),
                                 ),
-                                format!("&mut *"),
+                                "&mut *".to_string(),
                                 Applicability::MachineApplicable,
                             );
                         }
diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs
index f08208a1214..5932cb9e775 100644
--- a/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs
+++ b/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs
@@ -731,7 +731,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
                     if suggestions.peek().is_some() {
                         err.span_suggestions(
                             path_segment.ident.span,
-                            &format!("use mutable method"),
+                            "use mutable method",
                             suggestions,
                             Applicability::MaybeIncorrect,
                         );
diff --git a/compiler/rustc_mir/src/monomorphize/partitioning/merging.rs b/compiler/rustc_mir/src/monomorphize/partitioning/merging.rs
index 5107e697263..cbe36665790 100644
--- a/compiler/rustc_mir/src/monomorphize/partitioning/merging.rs
+++ b/compiler/rustc_mir/src/monomorphize/partitioning/merging.rs
@@ -46,7 +46,7 @@ pub fn merge_codegen_units<'tcx>(
         // Record that `second_smallest` now contains all the stuff that was in
         // `smallest` before.
         let mut consumed_cgu_names = cgu_contents.remove(&smallest.name()).unwrap();
-        cgu_contents.get_mut(&second_smallest.name()).unwrap().extend(consumed_cgu_names.drain(..));
+        cgu_contents.get_mut(&second_smallest.name()).unwrap().append(&mut consumed_cgu_names);
 
         debug!(
             "CodegenUnit {} merged into CodegenUnit {}",
diff --git a/compiler/rustc_mir/src/transform/check_consts/ops.rs b/compiler/rustc_mir/src/transform/check_consts/ops.rs
index 8de11fda7d7..ddca22aebd2 100644
--- a/compiler/rustc_mir/src/transform/check_consts/ops.rs
+++ b/compiler/rustc_mir/src/transform/check_consts/ops.rs
@@ -255,7 +255,7 @@ impl NonConstOp for CellBorrow {
         );
         err.span_label(
             span,
-            format!("this borrow of an interior mutable value may end up in the final value"),
+            "this borrow of an interior mutable value may end up in the final value",
         );
         if let hir::ConstContext::Static(_) = ccx.const_kind() {
             err.help(
diff --git a/compiler/rustc_mir/src/transform/coverage/debug.rs b/compiler/rustc_mir/src/transform/coverage/debug.rs
index f6672335cb1..6fd7d29d777 100644
--- a/compiler/rustc_mir/src/transform/coverage/debug.rs
+++ b/compiler/rustc_mir/src/transform/coverage/debug.rs
@@ -344,7 +344,7 @@ impl DebugCounters {
                 return if counter_format.id {
                     format!("{}#{}", block_label, id.index())
                 } else {
-                    format!("{}", block_label)
+                    block_label.to_string()
                 };
             }
         }
@@ -369,7 +369,7 @@ impl DebugCounters {
                     }
                     return format!("({})", self.format_counter_kind(counter_kind));
                 }
-                return format!("{}", self.format_counter_kind(counter_kind));
+                return self.format_counter_kind(counter_kind).to_string();
             }
         }
         format!("#{}", operand.index().to_string())
diff --git a/compiler/rustc_mir/src/transform/coverage/graph.rs b/compiler/rustc_mir/src/transform/coverage/graph.rs
index 0521f507ec7..32febcec7af 100644
--- a/compiler/rustc_mir/src/transform/coverage/graph.rs
+++ b/compiler/rustc_mir/src/transform/coverage/graph.rs
@@ -526,8 +526,8 @@ impl TraverseCoverageGraphWithLoops {
     pub fn new(basic_coverage_blocks: &CoverageGraph) -> Self {
         let start_bcb = basic_coverage_blocks.start_node();
         let backedges = find_loop_backedges(basic_coverage_blocks);
-        let mut context_stack = Vec::new();
-        context_stack.push(TraversalContext { loop_backedges: None, worklist: vec![start_bcb] });
+        let context_stack =
+            vec![TraversalContext { loop_backedges: None, worklist: vec![start_bcb] }];
         // `context_stack` starts with a `TraversalContext` for the main function context (beginning
         // with the `start` BasicCoverageBlock of the function). New worklists are pushed to the top
         // of the stack as loops are entered, and popped off of the stack when a loop's worklist is
diff --git a/compiler/rustc_mir/src/transform/inline.rs b/compiler/rustc_mir/src/transform/inline.rs
index 7d765cec575..8e6654cb2da 100644
--- a/compiler/rustc_mir/src/transform/inline.rs
+++ b/compiler/rustc_mir/src/transform/inline.rs
@@ -614,8 +614,8 @@ impl Inliner<'tcx> {
                         .vars_and_temps_iter()
                         .map(|local| callee_body.local_decls[local].clone()),
                 );
-                caller_body.source_scopes.extend(callee_body.source_scopes.drain(..));
-                caller_body.var_debug_info.extend(callee_body.var_debug_info.drain(..));
+                caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..));
+                caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
                 caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..));
 
                 caller_body[callsite.block].terminator = Some(Terminator {
diff --git a/compiler/rustc_mir/src/transform/lower_intrinsics.rs b/compiler/rustc_mir/src/transform/lower_intrinsics.rs
index 6d7e4cdb1c6..aff2df31b1c 100644
--- a/compiler/rustc_mir/src/transform/lower_intrinsics.rs
+++ b/compiler/rustc_mir/src/transform/lower_intrinsics.rs
@@ -147,8 +147,8 @@ fn validate_simd_shuffle(tcx: TyCtxt<'tcx>, args: &[Operand<'tcx>], span: Span)
     match &args[2] {
         Operand::Constant(_) => {} // all good
         _ => {
-            let msg = format!("last argument of `simd_shuffle` is required to be a `const` item");
-            tcx.sess.span_err(span, &msg);
+            let msg = "last argument of `simd_shuffle` is required to be a `const` item";
+            tcx.sess.span_err(span, msg);
         }
     }
 }
diff --git a/compiler/rustc_mir/src/util/pretty.rs b/compiler/rustc_mir/src/util/pretty.rs
index d0b1bc47ea8..7598a011bb6 100644
--- a/compiler/rustc_mir/src/util/pretty.rs
+++ b/compiler/rustc_mir/src/util/pretty.rs
@@ -479,7 +479,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
                     uv.promoted
                 ),
                 ty::ConstKind::Value(val) => format!("Value({:?})", val),
-                ty::ConstKind::Error(_) => format!("Error"),
+                ty::ConstKind::Error(_) => "Error".to_string(),
             };
             self.push(&format!("+ val: {}", val));
         }