File tree Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Expand file tree Collapse file tree 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(
13431343 args_len : usize ,
13441344) -> bool {
13451345 match expr. node {
1346+ _ if !expr. attrs . is_empty ( ) => false ,
13461347 ast:: ExprKind :: Match ( ..) => {
13471348 ( context. use_block_indent ( ) && args_len == 1 )
13481349 || ( 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> {
9292}
9393
9494impl < ' 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+
95106 pub fn map < F , T > ( & self , f : F ) -> T
96107 where
97108 F : Fn ( & dyn IntoOverflowableItem < ' a > ) -> T ,
@@ -448,6 +459,7 @@ impl<'a> Context<'a> {
448459 // 1 = "("
449460 let combine_arg_with_callee = self . items . len ( ) == 1
450461 && self . items [ 0 ] . is_expr ( )
462+ && !self . items [ 0 ] . has_attrs ( )
451463 && self . ident . len ( ) < self . context . config . tab_spaces ( ) ;
452464 let overflow_last = combine_arg_with_callee || can_be_overflowed ( self . context , & self . items ) ;
453465
Original file line number Diff line number Diff line change @@ -532,3 +532,16 @@ fn issue3457() {
532532 }
533533 }
534534}
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() {
615615 }
616616 }
617617}
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