Skip to content

Commit ce841fe

Browse files
committed
Format with rustfmt_if_chain
1 parent 48d5494 commit ce841fe

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ fn check_addr_of_expr(
114114
parent.span,
115115
&format!("unnecessary use of `{}`", method_name),
116116
"use",
117-
format!("{:&>width$}{}", "", receiver_snippet, width = n_target_refs - n_receiver_refs),
117+
format!(
118+
"{:&>width$}{}",
119+
"",
120+
receiver_snippet,
121+
width = n_target_refs - n_receiver_refs
122+
),
118123
Applicability::MachineApplicable,
119124
);
120125
return true;
@@ -182,20 +187,10 @@ fn check_into_iter_call_arg(cx: &LateContext<'_>, expr: &Expr<'_>, method_name:
182187
if let Some(item_ty) = get_iterator_item_ty(cx, parent_ty);
183188
if let Some(receiver_snippet) = snippet_opt(cx, receiver.span);
184189
then {
185-
if unnecessary_iter_cloned::check_for_loop_iter(
186-
cx,
187-
parent,
188-
method_name,
189-
receiver,
190-
true,
191-
) {
190+
if unnecessary_iter_cloned::check_for_loop_iter(cx, parent, method_name, receiver, true) {
192191
return true;
193192
}
194-
let cloned_or_copied = if is_copy(cx, item_ty) {
195-
"copied"
196-
} else {
197-
"cloned"
198-
};
193+
let cloned_or_copied = if is_copy(cx, item_ty) { "copied" } else { "cloned" };
199194
// The next suggestion may be incorrect because the removal of the `to_owned`-like
200195
// function could cause the iterator to hold a reference to a resource that is used
201196
// mutably. See https://github.com/rust-lang/rust-clippy/issues/8148.
@@ -243,18 +238,19 @@ fn check_other_call_arg<'tcx>(
243238
if if trait_predicate.def_id() == deref_trait_id {
244239
if let [projection_predicate] = projection_predicates[..] {
245240
let normalized_ty =
246-
cx.tcx.subst_and_normalize_erasing_regions(call_substs, cx.param_env, projection_predicate.term);
241+
cx.tcx
242+
.subst_and_normalize_erasing_regions(call_substs, cx.param_env, projection_predicate.term);
247243
implements_trait(cx, receiver_ty, deref_trait_id, &[])
248-
&& get_associated_type(cx, receiver_ty, deref_trait_id,
249-
"Target").map_or(false, |ty| ty::Term::Ty(ty) == normalized_ty)
244+
&& get_associated_type(cx, receiver_ty, deref_trait_id, "Target")
245+
.map_or(false, |ty| ty::Term::Ty(ty) == normalized_ty)
250246
} else {
251247
false
252248
}
253249
} else if trait_predicate.def_id() == as_ref_trait_id {
254250
let composed_substs = compose_substs(
255251
cx,
256252
&trait_predicate.trait_ref.substs.iter().skip(1).collect::<Vec<_>>()[..],
257-
call_substs
253+
call_substs,
258254
);
259255
implements_trait(cx, receiver_ty, as_ref_trait_id, &composed_substs)
260256
} else {
@@ -339,11 +335,7 @@ fn get_input_traits_and_projections<'tcx>(
339335
if let Some(arg) = substs.iter().next();
340336
if let GenericArgKind::Type(arg_ty) = arg.unpack();
341337
if arg_ty == input;
342-
then {
343-
true
344-
} else {
345-
false
346-
}
338+
then { true } else { false }
347339
}
348340
};
349341
match predicate.kind().skip_binder() {

0 commit comments

Comments
 (0)