Fix false positive for unused_unit (#14962)
Given a type alias as follows, clippy would detect a false positive for `unused_unit`. ```rust type UnusedParensButNoUnit = Box<dyn (Fn())>; ``` changelog: [`unused_unit`]: fix false positive for `Fn` bounds
This commit is contained in:
commit
6bb0c97409
4 changed files with 22 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -143,4 +143,10 @@ mod issue14577 {
|
|||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod pr14962 {
|
||||
#[allow(unused_parens)]
|
||||
type UnusedParensButNoUnit = Box<dyn (Fn())>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,4 +143,10 @@ mod issue14577 {
|
|||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod pr14962 {
|
||||
#[allow(unused_parens)]
|
||||
type UnusedParensButNoUnit = Box<dyn (Fn())>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,4 +143,10 @@ mod issue14577 {
|
|||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod pr14962 {
|
||||
#[allow(unused_parens)]
|
||||
type UnusedParensButNoUnit = Box<dyn (Fn())>;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue