1
Fork 0

fix #105061, Fix unused_parens issue for higher ranked function pointers

This commit is contained in:
yukang 2022-12-24 02:41:06 +08:00
parent 44a500c8c1
commit 7d99866bfc
4 changed files with 43 additions and 1 deletions

View file

@ -248,6 +248,12 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
}
fn visit_where_predicate(&mut self, p: &'a ast::WherePredicate) {
use rustc_ast::{WhereBoundPredicate, WherePredicate};
if let WherePredicate::BoundPredicate(WhereBoundPredicate { bounded_ty, .. }) = p &&
let ast::TyKind::BareFn(b) = &bounded_ty.kind &&
b.generic_params.len() > 0 {
return;
}
ast_visit::walk_where_predicate(self, p);
}

View file

@ -1002,7 +1002,6 @@ impl EarlyLintPass for UnusedParens {
if let ast::TyKind::Paren(r) = &ty.kind {
match &r.kind {
ast::TyKind::TraitObject(..) => {}
ast::TyKind::BareFn(b) if b.generic_params.len() > 0 => {}
ast::TyKind::ImplTrait(_, bounds) if bounds.len() > 1 => {}
ast::TyKind::Array(_, len) => {
self.check_unused_delims_expr(