- if let ExprKind::Field(lhs1, _) = lhs1.kind {
- if let ExprKind::Field(lhs2, _) = lhs2.kind {
- if lhs1.hir_id.owner == lhs2.hir_id.owner {
- return;
- }
- }
- }
-
- let mut applicability = Applicability::MachineApplicable;
-
- let slice = check_for_slice(cx, lhs1, lhs2);
- let (replace, what, sugg) = if let Slice::NotSwappable = slice {
- return;
- } else if let Slice::Swappable(slice, idx1, idx2) = slice {
- if let Some(slice) = Sugg::hir_opt(cx, slice) {
- (
- false,
- format!(" elements of `{}`", slice),
- format!(
- "{}.swap({}, {})",
- slice.maybe_par(),
- snippet_with_applicability(cx, idx1.span, "..", &mut applicability),
- snippet_with_applicability(cx, idx2.span, "..", &mut applicability),
- ),
- )
- } 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()),
- )
- } else {
- (true, String::new(), String::new())
- };
-