@@ -1285,24 +1285,32 @@ impl EarlyLintPass for UnusedParens {
12851285 ) ;
12861286 }
12871287 ast:: TyKind :: Paren ( r) => {
1288- match & r. kind {
1289- ast:: TyKind :: ImplTrait ( _, bounds) | ast:: TyKind :: TraitObject ( bounds, _)
1290- if self . in_no_bounds_pos . get ( & ty. id ) . is_some_and ( |exception| {
1291- matches ! ( exception, NoBoundsException :: None ) || bounds. len ( ) > 1
1292- } ) => { }
1293- ast:: TyKind :: BareFn ( b)
1294- if self . with_self_ty_parens && b. generic_params . len ( ) > 0 => { }
1295- _ => {
1296- let spans = if !ty. span . from_expansion ( ) {
1288+ let unused_parens = match & r. kind {
1289+ ast:: TyKind :: ImplTrait ( _, bounds) | ast:: TyKind :: TraitObject ( bounds, _) => {
1290+ match self . in_no_bounds_pos . get ( & ty. id ) {
1291+ Some ( NoBoundsException :: None ) => false ,
1292+ Some ( NoBoundsException :: OneBound ) => bounds. len ( ) <= 1 ,
1293+ None => true ,
1294+ }
1295+ }
1296+ ast:: TyKind :: BareFn ( b) => {
1297+ !self . with_self_ty_parens || b. generic_params . is_empty ( )
1298+ }
1299+ _ => true ,
1300+ } ;
1301+
1302+ if unused_parens {
1303+ let spans = ( !ty. span . from_expansion ( ) )
1304+ . then ( || {
12971305 r. span
12981306 . find_ancestor_inside ( ty. span )
12991307 . map ( |r| ( ty. span . with_hi ( r. lo ( ) ) , ty. span . with_lo ( r. hi ( ) ) ) )
1300- } else {
1301- None
1302- } ;
1303- self . emit_unused_delims ( cx, ty. span , spans, "type" , ( false , false ) , false ) ;
1304- }
1308+ } )
1309+ . flatten ( ) ;
1310+
1311+ self . emit_unused_delims ( cx, ty. span , spans, "type" , ( false , false ) , false ) ;
13051312 }
1313+
13061314 self . with_self_ty_parens = false ;
13071315 }
13081316 ast:: TyKind :: Ref ( _, mut_ty) | ast:: TyKind :: Ptr ( mut_ty) => {
0 commit comments