diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 80c9a33c06a8..79ff183c9ca3 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -118,6 +118,14 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { None } + if let ExprKind::Field(ref lhs1, _) = lhs1.node { + if let ExprKind::Field(ref lhs2, _) = lhs2.node { + if lhs1.hir_id.owner_def_id() == lhs2.hir_id.owner_def_id() { + return; + } + } + } + let (replace, what, sugg) = if let Some((slice, idx1, idx2)) = check_for_slice(cx, lhs1, lhs2) { if let Some(slice) = Sugg::hir_opt(cx, slice) { (false,