about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBenjamin Schulz <benjamin.schulz@sap.com>2025-06-03 19:25:43 +0200
committerBenjamin Schulz <benjamin.schulz@sap.com>2025-06-03 19:25:43 +0200
commited226d2c6b45f76437e417f47f6315b0f3c5b976 (patch)
tree298a34ff333b4d2f98729e190cd772557c5ff067
parent9b8c42cbb1493c5e0c089f73a8a9118a0894d231 (diff)
downloadrust-ed226d2c6b45f76437e417f47f6315b0f3c5b976.tar.gz
rust-ed226d2c6b45f76437e417f47f6315b0f3c5b976.zip
Fix false positive for unused_unit
-rw-r--r--clippy_lints/src/unused_unit.rs1
-rw-r--r--tests/ui/unused_unit.edition2021.fixed8
-rw-r--r--tests/ui/unused_unit.edition2024.fixed8
-rw-r--r--tests/ui/unused_unit.rs8
4 files changed, 22 insertions, 3 deletions
diff --git a/clippy_lints/src/unused_unit.rs b/clippy_lints/src/unused_unit.rs
index 9859ddfdf7b..8ebfa3bf69b 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 93dd58b8e9d..cb29688988a 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<dyn (Fn())>;
+}
+
diff --git a/tests/ui/unused_unit.edition2024.fixed b/tests/ui/unused_unit.edition2024.fixed
index 987d901b97d..9870561ff03 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<dyn (Fn())>;
+}
+
diff --git a/tests/ui/unused_unit.rs b/tests/ui/unused_unit.rs
index b7645f7b6a2..23421764b35 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<dyn (Fn())>;
+}
+