File tree 4 files changed +49
-0
lines changed
4 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -1343,6 +1343,7 @@ pub fn can_be_overflowed_expr(
1343
1343
args_len : usize ,
1344
1344
) -> bool {
1345
1345
match expr. node {
1346
+ _ if !expr. attrs . is_empty ( ) => false ,
1346
1347
ast:: ExprKind :: Match ( ..) => {
1347
1348
( context. use_block_indent ( ) && args_len == 1 )
1348
1349
|| ( context. config . indent_style ( ) == IndentStyle :: Visual && args_len > 1 )
Original file line number Diff line number Diff line change @@ -92,6 +92,17 @@ impl<'a> Spanned for OverflowableItem<'a> {
92
92
}
93
93
94
94
impl < ' a > OverflowableItem < ' a > {
95
+ fn has_attrs ( & self ) -> bool {
96
+ match self {
97
+ OverflowableItem :: Expr ( ast:: Expr { attrs, .. } )
98
+ | OverflowableItem :: GenericParam ( ast:: GenericParam { attrs, .. } ) => !attrs. is_empty ( ) ,
99
+ OverflowableItem :: StructField ( ast:: StructField { attrs, .. } ) => !attrs. is_empty ( ) ,
100
+ OverflowableItem :: MacroArg ( MacroArg :: Expr ( expr) ) => !expr. attrs . is_empty ( ) ,
101
+ OverflowableItem :: MacroArg ( MacroArg :: Item ( item) ) => !item. attrs . is_empty ( ) ,
102
+ _ => false ,
103
+ }
104
+ }
105
+
95
106
pub fn map < F , T > ( & self , f : F ) -> T
96
107
where
97
108
F : Fn ( & dyn IntoOverflowableItem < ' a > ) -> T ,
@@ -448,6 +459,7 @@ impl<'a> Context<'a> {
448
459
// 1 = "("
449
460
let combine_arg_with_callee = self . items . len ( ) == 1
450
461
&& self . items [ 0 ] . is_expr ( )
462
+ && !self . items [ 0 ] . has_attrs ( )
451
463
&& self . ident . len ( ) < self . context . config . tab_spaces ( ) ;
452
464
let overflow_last = combine_arg_with_callee || can_be_overflowed ( self . context , & self . items ) ;
453
465
Original file line number Diff line number Diff line change @@ -532,3 +532,16 @@ fn issue3457() {
532
532
}
533
533
}
534
534
}
535
+
536
+ // #3498
537
+ static REPRO : & [ usize ] = & [ #[ cfg( feature = "zero" ) ]
538
+ 0 ] ;
539
+
540
+ fn overflow_with_attr ( ) {
541
+ foo ( #[ cfg( feature = "zero" ) ]
542
+ 0 ) ;
543
+ foobar ( #[ cfg( feature = "zero" ) ]
544
+ 0 ) ;
545
+ foobar ( x, y, #[ cfg( feature = "zero" ) ]
546
+ { } ) ;
547
+ }
Original file line number Diff line number Diff line change @@ -615,3 +615,26 @@ fn issue3457() {
615
615
}
616
616
}
617
617
}
618
+
619
+ // #3498
620
+ static REPRO : & [ usize ] = & [
621
+ #[ cfg( feature = "zero" ) ]
622
+ 0 ,
623
+ ] ;
624
+
625
+ fn overflow_with_attr ( ) {
626
+ foo (
627
+ #[ cfg( feature = "zero" ) ]
628
+ 0 ,
629
+ ) ;
630
+ foobar (
631
+ #[ cfg( feature = "zero" ) ]
632
+ 0 ,
633
+ ) ;
634
+ foobar (
635
+ x,
636
+ y,
637
+ #[ cfg( feature = "zero" ) ]
638
+ { } ,
639
+ ) ;
640
+ }
You can’t perform that action at this time.
0 commit comments