@@ -1877,14 +1877,16 @@ pub(crate) fn rewrite_struct_field(
18771877 let prefix = rewrite_struct_field_prefix ( context, field) ?;
18781878
18791879 let attrs_str = field. attrs . rewrite ( context, shape) ?;
1880+ let ty_str = field. ty . rewrite ( context, shape) ?;
18801881
1881- let allow_extend = if field. attrs . len ( ) == 1 {
1882- let line_len = attrs_str. len ( ) + 1 + prefix. len ( ) ;
1883- !field. attrs . first ( ) . unwrap ( ) . is_doc_comment ( )
1884- && context. config . inline_attribute_width ( ) >= line_len
1885- } else {
1886- false
1887- } ;
1882+ let allow_extend = extend_inline_attr (
1883+ & field. attrs ,
1884+ shape,
1885+ & attrs_str,
1886+ // +1 = " ", +1 = ","
1887+ prefix. len ( ) + 1 + ty_str. len ( ) + 1 ,
1888+ context,
1889+ ) ;
18881890
18891891 let attrs_extendable =
18901892 ( field. ident . is_none ( ) && is_attributes_extendable ( & attrs_str) ) || allow_extend;
@@ -3394,13 +3396,8 @@ impl Rewrite for ast::ForeignItem {
33943396 mk_sp ( self . attrs [ self . attrs . len ( ) - 1 ] . span . hi ( ) , self . span . lo ( ) )
33953397 } ;
33963398
3397- let allow_extend = if self . attrs . len ( ) == 1 {
3398- let line_len = attrs_str. len ( ) + 1 + item_str. len ( ) ;
3399- !self . attrs . first ( ) . unwrap ( ) . is_doc_comment ( )
3400- && context. config . inline_attribute_width ( ) >= line_len
3401- } else {
3402- false
3403- } ;
3399+ let allow_extend =
3400+ extend_inline_attr ( & self . attrs , shape, & attrs_str, item_str. len ( ) , context) ;
34043401
34053402 combine_strs_with_missing_comments (
34063403 context,
@@ -3429,13 +3426,7 @@ fn rewrite_attrs(
34293426 mk_sp ( attrs[ attrs. len ( ) - 1 ] . span . hi ( ) , item. span . lo ( ) )
34303427 } ;
34313428
3432- let allow_extend = if attrs. len ( ) == 1 {
3433- let line_len = attrs_str. len ( ) + 1 + item_str. len ( ) ;
3434- !attrs. first ( ) . unwrap ( ) . is_doc_comment ( )
3435- && context. config . inline_attribute_width ( ) >= line_len
3436- } else {
3437- false
3438- } ;
3429+ let allow_extend = extend_inline_attr ( & item. attrs , shape, & attrs_str, item_str. len ( ) , context) ;
34393430
34403431 combine_strs_with_missing_comments (
34413432 context,
0 commit comments