Skip to content

Commit ed226d2

Browse files
author
Benjamin Schulz
committed
Fix false positive for unused_unit
1 parent 9b8c42c commit ed226d2

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

clippy_lints/src/unused_unit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedUnit {
109109
&& let AssocItemConstraintKind::Equality { term: Term::Ty(hir_ty) } = constraints[0].kind
110110
&& args.span_ext.hi() != poly.span.hi()
111111
&& !hir_ty.span.from_expansion()
112+
&& args.span_ext.hi() != hir_ty.span.hi()
112113
&& is_unit_ty(hir_ty)
113114
{
114115
lint_unneeded_unit_return(cx, hir_ty.span, poly.span);

tests/ui/unused_unit.edition2021.fixed

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,10 @@ mod issue14577 {
143143
todo!()
144144
}
145145
}
146-
}
146+
}
147+
148+
mod pr_to_be_determined {
149+
#[allow(unused_parens)]
150+
type UnusedParensButNoUnit = Box<dyn (Fn())>;
151+
}
152+

tests/ui/unused_unit.edition2024.fixed

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,10 @@ mod issue14577 {
143143
todo!()
144144
}
145145
}
146-
}
146+
}
147+
148+
mod pr_to_be_determined {
149+
#[allow(unused_parens)]
150+
type UnusedParensButNoUnit = Box<dyn (Fn())>;
151+
}
152+

tests/ui/unused_unit.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,10 @@ mod issue14577 {
143143
todo!()
144144
}
145145
}
146-
}
146+
}
147+
148+
mod pr_to_be_determined {
149+
#[allow(unused_parens)]
150+
type UnusedParensButNoUnit = Box<dyn (Fn())>;
151+
}
152+

0 commit comments

Comments
 (0)