mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
fix #105061, Fix unused_parens issue for higher ranked function pointers
This commit is contained in:
parent
44a500c8c1
commit
7d99866bfc
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
17
tests/ui/lint/unused/issue-105061.rs
Normal file
17
tests/ui/lint/unused/issue-105061.rs
Normal file
@ -0,0 +1,17 @@
|
||||
#![warn(unused)]
|
||||
#![deny(warnings)]
|
||||
|
||||
struct Inv<'a>(&'a mut &'a ());
|
||||
|
||||
trait Trait {}
|
||||
impl Trait for (for<'a> fn(Inv<'a>),) {}
|
||||
|
||||
|
||||
fn with_bound()
|
||||
where
|
||||
((for<'a> fn(Inv<'a>)),): Trait, //~ ERROR unnecessary parentheses around type
|
||||
{}
|
||||
|
||||
fn main() {
|
||||
with_bound();
|
||||
}
|
20
tests/ui/lint/unused/issue-105061.stderr
Normal file
20
tests/ui/lint/unused/issue-105061.stderr
Normal file
@ -0,0 +1,20 @@
|
||||
error: unnecessary parentheses around type
|
||||
--> $DIR/issue-105061.rs:12:6
|
||||
|
|
||||
LL | ((for<'a> fn(Inv<'a>)),): Trait,
|
||||
| ^ ^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-105061.rs:2:9
|
||||
|
|
||||
LL | #![deny(warnings)]
|
||||
| ^^^^^^^^
|
||||
= note: `#[deny(unused_parens)]` implied by `#[deny(warnings)]`
|
||||
help: remove these parentheses
|
||||
|
|
||||
LL - ((for<'a> fn(Inv<'a>)),): Trait,
|
||||
LL + (for<'a> fn(Inv<'a>),): Trait,
|
||||
|
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in New Issue
Block a user