From ed226d2c6b45f76437e417f47f6315b0f3c5b976 Mon Sep 17 00:00:00 2001 From: Benjamin Schulz Date: Tue, 3 Jun 2025 19:25:43 +0200 Subject: [PATCH 1/2] Fix false positive for unused_unit --- clippy_lints/src/unused_unit.rs | 1 + tests/ui/unused_unit.edition2021.fixed | 8 +++++++- tests/ui/unused_unit.edition2024.fixed | 8 +++++++- tests/ui/unused_unit.rs | 8 +++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/unused_unit.rs b/clippy_lints/src/unused_unit.rs index 9859ddfdf7bd..8ebfa3bf69b3 100644 --- a/clippy_lints/src/unused_unit.rs +++ b/clippy_lints/src/unused_unit.rs @@ -109,6 +109,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedUnit { && let AssocItemConstraintKind::Equality { term: Term::Ty(hir_ty) } = constraints[0].kind && args.span_ext.hi() != poly.span.hi() && !hir_ty.span.from_expansion() + && args.span_ext.hi() != hir_ty.span.hi() && is_unit_ty(hir_ty) { lint_unneeded_unit_return(cx, hir_ty.span, poly.span); diff --git a/tests/ui/unused_unit.edition2021.fixed b/tests/ui/unused_unit.edition2021.fixed index 93dd58b8e9d7..cb29688988ae 100644 --- a/tests/ui/unused_unit.edition2021.fixed +++ b/tests/ui/unused_unit.edition2021.fixed @@ -143,4 +143,10 @@ mod issue14577 { todo!() } } -} \ No newline at end of file +} + +mod pr_to_be_determined { + #[allow(unused_parens)] + type UnusedParensButNoUnit = Box; +} + diff --git a/tests/ui/unused_unit.edition2024.fixed b/tests/ui/unused_unit.edition2024.fixed index 987d901b97df..9870561ff034 100644 --- a/tests/ui/unused_unit.edition2024.fixed +++ b/tests/ui/unused_unit.edition2024.fixed @@ -143,4 +143,10 @@ mod issue14577 { todo!() } } -} \ No newline at end of file +} + +mod pr_to_be_determined { + #[allow(unused_parens)] + type UnusedParensButNoUnit = Box; +} + diff --git a/tests/ui/unused_unit.rs b/tests/ui/unused_unit.rs index b7645f7b6a26..23421764b35c 100644 --- a/tests/ui/unused_unit.rs +++ b/tests/ui/unused_unit.rs @@ -143,4 +143,10 @@ mod issue14577 { todo!() } } -} \ No newline at end of file +} + +mod pr_to_be_determined { + #[allow(unused_parens)] + type UnusedParensButNoUnit = Box; +} + From 1e96456b84bd22dd5140dd4feb9108fc87e17da9 Mon Sep 17 00:00:00 2001 From: Benjamin Schulz Date: Tue, 3 Jun 2025 19:35:39 +0200 Subject: [PATCH 2/2] Reference correct PR --- tests/ui/unused_unit.edition2021.fixed | 2 +- tests/ui/unused_unit.edition2024.fixed | 2 +- tests/ui/unused_unit.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ui/unused_unit.edition2021.fixed b/tests/ui/unused_unit.edition2021.fixed index cb29688988ae..def8ef86e3c5 100644 --- a/tests/ui/unused_unit.edition2021.fixed +++ b/tests/ui/unused_unit.edition2021.fixed @@ -145,7 +145,7 @@ mod issue14577 { } } -mod pr_to_be_determined { +mod pr14962 { #[allow(unused_parens)] type UnusedParensButNoUnit = Box; } diff --git a/tests/ui/unused_unit.edition2024.fixed b/tests/ui/unused_unit.edition2024.fixed index 9870561ff034..f908b958b191 100644 --- a/tests/ui/unused_unit.edition2024.fixed +++ b/tests/ui/unused_unit.edition2024.fixed @@ -145,7 +145,7 @@ mod issue14577 { } } -mod pr_to_be_determined { +mod pr14962 { #[allow(unused_parens)] type UnusedParensButNoUnit = Box; } diff --git a/tests/ui/unused_unit.rs b/tests/ui/unused_unit.rs index 23421764b35c..7298ec40cc28 100644 --- a/tests/ui/unused_unit.rs +++ b/tests/ui/unused_unit.rs @@ -145,7 +145,7 @@ mod issue14577 { } } -mod pr_to_be_determined { +mod pr14962 { #[allow(unused_parens)] type UnusedParensButNoUnit = Box; }