1
Fork 0

Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa

more clippy::complexity fixes

(also a couple of clippy::perf fixes)
This commit is contained in:
bors 2021-08-01 09:15:15 +00:00
commit aadd6189ad
32 changed files with 44 additions and 51 deletions

View file

@ -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,
);
}

View file

@ -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,
);

View file

@ -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 {}",

View file

@ -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(

View file

@ -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())

View file

@ -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

View file

@ -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 {

View file

@ -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);
}
}
}

View file

@ -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));
}