Fix unused_parens false positive
This commit is contained in:
@@ -1062,6 +1062,7 @@ pub(crate) struct UnusedParens {
|
||||
/// ```
|
||||
/// type Example = Box<dyn Fn() -> &'static dyn Send>;
|
||||
/// ```
|
||||
#[derive(Copy, Clone)]
|
||||
enum NoBoundsException {
|
||||
/// The type must be parenthesized.
|
||||
None,
|
||||
@@ -1340,7 +1341,11 @@ impl EarlyLintPass for UnusedParens {
|
||||
self.with_self_ty_parens = false;
|
||||
}
|
||||
ast::TyKind::Ref(_, mut_ty) | ast::TyKind::Ptr(mut_ty) => {
|
||||
self.in_no_bounds_pos.insert(mut_ty.ty.id, NoBoundsException::OneBound);
|
||||
// If this type itself appears in no-bounds position, we propagate its
|
||||
// potentially tighter constraint or risk a false posive (issue 143653).
|
||||
let own_constraint = self.in_no_bounds_pos.get(&ty.id).copied();
|
||||
let constraint = own_constraint.unwrap_or(NoBoundsException::OneBound);
|
||||
self.in_no_bounds_pos.insert(mut_ty.ty.id, constraint);
|
||||
}
|
||||
ast::TyKind::TraitObject(bounds, _) | ast::TyKind::ImplTrait(_, bounds) => {
|
||||
for i in 0..bounds.len() {
|
||||
|
||||
Reference in New Issue
Block a user