Formatting

This commit is contained in:
flip1995 2019-12-03 13:21:00 +01:00
parent d1d5f790f5
commit bd39a608a8
No known key found for this signature in database
GPG Key ID: 693086869D506637

View File

@ -111,25 +111,33 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) {
return;
} else if let Slice::Swappable(slice, idx1, idx2) = slice {
if let Some(slice) = Sugg::hir_opt(cx, slice) {
(false,
(
false,
format!(" elements of `{}`", slice),
format!("{}.swap({}, {})",
format!(
"{}.swap({}, {})",
slice.maybe_par(),
snippet(cx, idx1.span, ".."),
snippet(cx, idx2.span, "..")))
snippet(cx, idx2.span, ".."),
),
)
} else {
(false, String::new(), String::new())
}
} else if let (Some(first), Some(second)) = (Sugg::hir_opt(cx, lhs1), Sugg::hir_opt(cx, rhs1)) {
(true, format!(" `{}` and `{}`", first, second),
format!("std::mem::swap({}, {})", first.mut_addr(), second.mut_addr()))
(
true,
format!(" `{}` and `{}`", first, second),
format!("std::mem::swap({}, {})", first.mut_addr(), second.mut_addr()),
)
} else {
(true, String::new(), String::new())
};
let span = w[0].span.to(second.span);
span_lint_and_then(cx,
span_lint_and_then(
cx,
MANUAL_SWAP,
span,
&format!("this looks like you are swapping{} manually", what),
@ -146,7 +154,8 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) {
db.note("or maybe you should use `std::mem::replace`?");
}
}
});
}
);
}
}
}