1
Fork 0

comments feedback

This commit is contained in:
yukang 2023-01-16 20:44:14 +08:00
parent 644ee8d250
commit 9d74bb832f
3 changed files with 50 additions and 28 deletions

View file

@ -1009,7 +1009,8 @@ impl EarlyLintPass for UnusedParens {
}
fn check_ty(&mut self, cx: &EarlyContext<'_>, ty: &ast::Ty) {
if let ast::TyKind::Array(_, len) = &ty.kind {
match &ty.kind {
ast::TyKind::Array(_, len) => {
self.check_unused_delims_expr(
cx,
&len.value,
@ -1019,7 +1020,7 @@ impl EarlyLintPass for UnusedParens {
None,
);
}
if let ast::TyKind::Paren(r) = &ty.kind {
ast::TyKind::Paren(r) => {
match &r.kind {
ast::TyKind::TraitObject(..) => {}
ast::TyKind::BareFn(b)
@ -1034,6 +1035,9 @@ impl EarlyLintPass for UnusedParens {
self.emit_unused_delims(cx, ty.span, spans, "type", (false, false));
}
}
self.with_self_ty_parens = false;
}
_ => {}
}
}
@ -1055,7 +1059,7 @@ impl EarlyLintPass for UnusedParens {
}
fn exit_where_predicate(&mut self, _: &EarlyContext<'_>, _: &ast::WherePredicate) {
self.with_self_ty_parens = false;
assert!(!self.with_self_ty_parens);
}
}

View file

@ -6,12 +6,18 @@ struct Inv<'a>(&'a mut &'a ());
trait Trait<'a> {}
impl<'b> Trait<'b> for for<'a> fn(Inv<'a>) {}
fn with_bound()
where
for<'b> (for<'a> fn(Inv<'a>)): Trait<'b>, //~ ERROR unnecessary parentheses around type
{}
trait Hello<T> {}
fn with_dyn_bound<T>()
where
(dyn Hello<(for<'b> fn(&'b ()))>): Hello<T> //~ ERROR unnecessary parentheses around type
{}
fn main() {
with_bound();
with_dyn_bound();
}

View file

@ -1,5 +1,5 @@
error: unnecessary parentheses around type
--> $DIR/issue-105061-should-lint.rs:12:13
--> $DIR/issue-105061-should-lint.rs:11:13
|
LL | for<'b> (for<'a> fn(Inv<'a>)): Trait<'b>,
| ^ ^
@ -16,5 +16,17 @@ LL - for<'b> (for<'a> fn(Inv<'a>)): Trait<'b>,
LL + for<'b> for<'a> fn(Inv<'a>): Trait<'b>,
|
error: aborting due to previous error
error: unnecessary parentheses around type
--> $DIR/issue-105061-should-lint.rs:17:16
|
LL | (dyn Hello<(for<'b> fn(&'b ()))>): Hello<T>
| ^ ^
|
help: remove these parentheses
|
LL - (dyn Hello<(for<'b> fn(&'b ()))>): Hello<T>
LL + (dyn Hello<for<'b> fn(&'b ())>): Hello<T>
|
error: aborting due to 2 previous errors