File tree 1 file changed +24
-23
lines changed
1 file changed +24
-23
lines changed Original file line number Diff line number Diff line change @@ -242,30 +242,31 @@ impl UseTree {
242
242
format ! ( "{}use {};" , vis, s)
243
243
}
244
244
} ) ?;
245
- if let Some ( ref attrs) = self . attrs {
246
- let attr_str = attrs. rewrite ( context, shape) ?;
247
- let lo = attrs. last ( ) . as_ref ( ) ?. span ( ) . hi ( ) ;
248
- let hi = self . span . lo ( ) ;
249
- let span = mk_sp ( lo, hi) ;
250
-
251
- let allow_extend = if attrs. len ( ) == 1 {
252
- let line_len = attr_str. len ( ) + 1 + use_str. len ( ) ;
253
- !attrs. first ( ) . unwrap ( ) . is_sugared_doc
254
- && context. config . inline_attribute_width ( ) >= line_len
255
- } else {
256
- false
257
- } ;
245
+ match self . attrs {
246
+ Some ( ref attrs) if !attrs. is_empty ( ) => {
247
+ let attr_str = attrs. rewrite ( context, shape) ?;
248
+ let lo = attrs. last ( ) . as_ref ( ) ?. span ( ) . hi ( ) ;
249
+ let hi = self . span . lo ( ) ;
250
+ let span = mk_sp ( lo, hi) ;
251
+
252
+ let allow_extend = if attrs. len ( ) == 1 {
253
+ let line_len = attr_str. len ( ) + 1 + use_str. len ( ) ;
254
+ !attrs. first ( ) . unwrap ( ) . is_sugared_doc
255
+ && context. config . inline_attribute_width ( ) >= line_len
256
+ } else {
257
+ false
258
+ } ;
258
259
259
- combine_strs_with_missing_comments (
260
- context,
261
- & attr_str,
262
- & use_str,
263
- span,
264
- shape,
265
- allow_extend,
266
- )
267
- } else {
268
- Some ( use_str)
260
+ combine_strs_with_missing_comments (
261
+ context,
262
+ & attr_str,
263
+ & use_str,
264
+ span,
265
+ shape,
266
+ allow_extend,
267
+ )
268
+ }
269
+ _ => Some ( use_str) ,
269
270
}
270
271
}
271
272
You can’t perform that action at this time.
0 commit comments