Format with rustfmt_if_chain
This commit is contained in:
parent
48d54942f5
commit
ce841fe73b
@ -114,7 +114,12 @@ fn check_addr_of_expr(
|
|||||||
parent.span,
|
parent.span,
|
||||||
&format!("unnecessary use of `{}`", method_name),
|
&format!("unnecessary use of `{}`", method_name),
|
||||||
"use",
|
"use",
|
||||||
format!("{:&>width$}{}", "", receiver_snippet, width = n_target_refs - n_receiver_refs),
|
format!(
|
||||||
|
"{:&>width$}{}",
|
||||||
|
"",
|
||||||
|
receiver_snippet,
|
||||||
|
width = n_target_refs - n_receiver_refs
|
||||||
|
),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
@ -182,20 +187,10 @@ fn check_into_iter_call_arg(cx: &LateContext<'_>, expr: &Expr<'_>, method_name:
|
|||||||
if let Some(item_ty) = get_iterator_item_ty(cx, parent_ty);
|
if let Some(item_ty) = get_iterator_item_ty(cx, parent_ty);
|
||||||
if let Some(receiver_snippet) = snippet_opt(cx, receiver.span);
|
if let Some(receiver_snippet) = snippet_opt(cx, receiver.span);
|
||||||
then {
|
then {
|
||||||
if unnecessary_iter_cloned::check_for_loop_iter(
|
if unnecessary_iter_cloned::check_for_loop_iter(cx, parent, method_name, receiver, true) {
|
||||||
cx,
|
|
||||||
parent,
|
|
||||||
method_name,
|
|
||||||
receiver,
|
|
||||||
true,
|
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let cloned_or_copied = if is_copy(cx, item_ty) {
|
let cloned_or_copied = if is_copy(cx, item_ty) { "copied" } else { "cloned" };
|
||||||
"copied"
|
|
||||||
} else {
|
|
||||||
"cloned"
|
|
||||||
};
|
|
||||||
// The next suggestion may be incorrect because the removal of the `to_owned`-like
|
// The next suggestion may be incorrect because the removal of the `to_owned`-like
|
||||||
// function could cause the iterator to hold a reference to a resource that is used
|
// function could cause the iterator to hold a reference to a resource that is used
|
||||||
// mutably. See https://github.com/rust-lang/rust-clippy/issues/8148.
|
// mutably. See https://github.com/rust-lang/rust-clippy/issues/8148.
|
||||||
@ -243,10 +238,11 @@ fn check_other_call_arg<'tcx>(
|
|||||||
if if trait_predicate.def_id() == deref_trait_id {
|
if if trait_predicate.def_id() == deref_trait_id {
|
||||||
if let [projection_predicate] = projection_predicates[..] {
|
if let [projection_predicate] = projection_predicates[..] {
|
||||||
let normalized_ty =
|
let normalized_ty =
|
||||||
cx.tcx.subst_and_normalize_erasing_regions(call_substs, cx.param_env, projection_predicate.term);
|
cx.tcx
|
||||||
|
.subst_and_normalize_erasing_regions(call_substs, cx.param_env, projection_predicate.term);
|
||||||
implements_trait(cx, receiver_ty, deref_trait_id, &[])
|
implements_trait(cx, receiver_ty, deref_trait_id, &[])
|
||||||
&& get_associated_type(cx, receiver_ty, deref_trait_id,
|
&& get_associated_type(cx, receiver_ty, deref_trait_id, "Target")
|
||||||
"Target").map_or(false, |ty| ty::Term::Ty(ty) == normalized_ty)
|
.map_or(false, |ty| ty::Term::Ty(ty) == normalized_ty)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@ -254,7 +250,7 @@ fn check_other_call_arg<'tcx>(
|
|||||||
let composed_substs = compose_substs(
|
let composed_substs = compose_substs(
|
||||||
cx,
|
cx,
|
||||||
&trait_predicate.trait_ref.substs.iter().skip(1).collect::<Vec<_>>()[..],
|
&trait_predicate.trait_ref.substs.iter().skip(1).collect::<Vec<_>>()[..],
|
||||||
call_substs
|
call_substs,
|
||||||
);
|
);
|
||||||
implements_trait(cx, receiver_ty, as_ref_trait_id, &composed_substs)
|
implements_trait(cx, receiver_ty, as_ref_trait_id, &composed_substs)
|
||||||
} else {
|
} else {
|
||||||
@ -339,11 +335,7 @@ fn get_input_traits_and_projections<'tcx>(
|
|||||||
if let Some(arg) = substs.iter().next();
|
if let Some(arg) = substs.iter().next();
|
||||||
if let GenericArgKind::Type(arg_ty) = arg.unpack();
|
if let GenericArgKind::Type(arg_ty) = arg.unpack();
|
||||||
if arg_ty == input;
|
if arg_ty == input;
|
||||||
then {
|
then { true } else { false }
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
|
Loading…
Reference in New Issue
Block a user