Fix clippy::needless_borrow
in the compiler
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
This commit is contained in:
parent
0ff8610964
commit
21a870515b
304 changed files with 1101 additions and 1174 deletions
|
@ -481,12 +481,8 @@ where
|
|||
) -> (BasicBlock, Unwind) {
|
||||
let (succ, unwind) = self.drop_ladder_bottom();
|
||||
if !adt.is_enum() {
|
||||
let fields = self.move_paths_for_fields(
|
||||
self.place,
|
||||
self.path,
|
||||
&adt.variant(FIRST_VARIANT),
|
||||
args,
|
||||
);
|
||||
let fields =
|
||||
self.move_paths_for_fields(self.place, self.path, adt.variant(FIRST_VARIANT), args);
|
||||
self.drop_ladder(fields, succ, unwind)
|
||||
} else {
|
||||
self.open_drop_for_multivariant(adt, args, succ, unwind)
|
||||
|
@ -518,7 +514,7 @@ where
|
|||
self.place,
|
||||
ProjectionElem::Downcast(Some(variant.name), variant_index),
|
||||
);
|
||||
let fields = self.move_paths_for_fields(base_place, variant_path, &variant, args);
|
||||
let fields = self.move_paths_for_fields(base_place, variant_path, variant, args);
|
||||
values.push(discr.val);
|
||||
if let Unwind::To(unwind) = unwind {
|
||||
// We can't use the half-ladder from the original
|
||||
|
@ -859,14 +855,14 @@ where
|
|||
fn open_drop(&mut self) -> BasicBlock {
|
||||
let ty = self.place_ty(self.place);
|
||||
match ty.kind() {
|
||||
ty::Closure(_, args) => self.open_drop_for_tuple(&args.as_closure().upvar_tys()),
|
||||
ty::Closure(_, args) => self.open_drop_for_tuple(args.as_closure().upvar_tys()),
|
||||
// Note that `elaborate_drops` only drops the upvars of a coroutine,
|
||||
// and this is ok because `open_drop` here can only be reached
|
||||
// within that own coroutine's resume function.
|
||||
// This should only happen for the self argument on the resume function.
|
||||
// It effectively only contains upvars until the coroutine transformation runs.
|
||||
// See librustc_body/transform/coroutine.rs for more details.
|
||||
ty::Coroutine(_, args, _) => self.open_drop_for_tuple(&args.as_coroutine().upvar_tys()),
|
||||
ty::Coroutine(_, args, _) => self.open_drop_for_tuple(args.as_coroutine().upvar_tys()),
|
||||
ty::Tuple(fields) => self.open_drop_for_tuple(fields),
|
||||
ty::Adt(def, args) => self.open_drop_for_adt(*def, args),
|
||||
ty::Dynamic(..) => self.complete_drop(self.succ, self.unwind),
|
||||
|
|
|
@ -196,7 +196,7 @@ impl Direction for Backward {
|
|||
{
|
||||
results.reset_to_block_entry(state, block);
|
||||
|
||||
vis.visit_block_end(results, &state, block_data, block);
|
||||
vis.visit_block_end(results, state, block_data, block);
|
||||
|
||||
// Terminator
|
||||
let loc = Location { block, statement_index: block_data.statements.len() };
|
||||
|
|
|
@ -295,7 +295,7 @@ where
|
|||
let mut results = Results { analysis, entry_sets, _marker: PhantomData };
|
||||
|
||||
if tcx.sess.opts.unstable_opts.dump_mir_dataflow {
|
||||
let res = write_graphviz_results(tcx, &body, &mut results, pass_name);
|
||||
let res = write_graphviz_results(tcx, body, &mut results, pass_name);
|
||||
if let Err(e) = res {
|
||||
error!("Failed to write graphviz dataflow results: {}", e);
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ impl<V: Clone> Clone for MaybeReachable<V> {
|
|||
fn clone_from(&mut self, source: &Self) {
|
||||
match (&mut *self, source) {
|
||||
(MaybeReachable::Reachable(x), MaybeReachable::Reachable(y)) => {
|
||||
x.clone_from(&y);
|
||||
x.clone_from(y);
|
||||
}
|
||||
_ => *self = source.clone(),
|
||||
}
|
||||
|
|
|
@ -409,7 +409,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
|
|||
}
|
||||
|
||||
let enum_ = discr.place().and_then(|discr| {
|
||||
switch_on_enum_discriminant(self.tcx, &self.body, &self.body[block], discr)
|
||||
switch_on_enum_discriminant(self.tcx, self.body, &self.body[block], discr)
|
||||
});
|
||||
|
||||
let Some((enum_place, enum_def)) = enum_ else {
|
||||
|
@ -540,7 +540,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
|
|||
}
|
||||
|
||||
let enum_ = discr.place().and_then(|discr| {
|
||||
switch_on_enum_discriminant(self.tcx, &self.body, &self.body[block], discr)
|
||||
switch_on_enum_discriminant(self.tcx, self.body, &self.body[block], discr)
|
||||
});
|
||||
|
||||
let Some((enum_place, enum_def)) = enum_ else {
|
||||
|
|
|
@ -34,7 +34,7 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
|
|||
}
|
||||
|
||||
let param_env = tcx.param_env(def_id);
|
||||
let move_data = MoveData::gather_moves(&body, tcx, param_env, |_| true);
|
||||
let move_data = MoveData::gather_moves(body, tcx, param_env, |_| true);
|
||||
let mdpe = MoveDataParamEnv { move_data, param_env };
|
||||
|
||||
if has_rustc_mir_with(tcx, def_id, sym::rustc_peek_maybe_init).is_some() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue