@@ -351,35 +351,33 @@ impl Rewrite for ast::Attribute {
351
351
return Some ( snippet. to_owned ( ) ) ;
352
352
}
353
353
354
- let meta = self . meta ( ) ;
355
-
356
- // This attribute is possibly a doc attribute needing normalization to a doc comment
357
- if context. config . normalize_doc_attributes ( ) {
358
- if let Some ( ref meta) = meta {
359
- if meta. check_name ( "doc" ) {
360
- if let Some ( ref literal) = meta. value_str ( ) {
361
- let comment_style = match self . style {
362
- ast:: AttrStyle :: Inner => CommentStyle :: Doc ,
363
- ast:: AttrStyle :: Outer => CommentStyle :: TripleSlash ,
364
- } ;
365
-
366
- let doc_comment = format ! ( "{}{}" , comment_style. opener( ) , literal) ;
367
- return rewrite_doc_comment (
368
- & doc_comment,
369
- shape. comment ( context. config ) ,
370
- context. config ,
371
- ) ;
372
- }
354
+ if let Some ( ref meta) = self . meta ( ) {
355
+ // This attribute is possibly a doc attribute needing normalization to a doc comment
356
+ if context. config . normalize_doc_attributes ( ) && meta. check_name ( "doc" ) {
357
+ if let Some ( ref literal) = meta. value_str ( ) {
358
+ let comment_style = match self . style {
359
+ ast:: AttrStyle :: Inner => CommentStyle :: Doc ,
360
+ ast:: AttrStyle :: Outer => CommentStyle :: TripleSlash ,
361
+ } ;
362
+
363
+ let doc_comment = format ! ( "{}{}" , comment_style. opener( ) , literal) ;
364
+ return rewrite_doc_comment (
365
+ & doc_comment,
366
+ shape. comment ( context. config ) ,
367
+ context. config ,
368
+ ) ;
373
369
}
374
370
}
375
- }
376
371
377
- // 1 = `[`
378
- let shape = shape. offset_left ( prefix. len ( ) + 1 ) ?;
379
- Some (
380
- meta. and_then ( |meta| meta. rewrite ( context, shape) )
381
- . map_or_else ( || snippet. to_owned ( ) , |rw| format ! ( "{}[{}]" , prefix, rw) ) ,
382
- )
372
+ // 1 = `[`
373
+ let shape = shape. offset_left ( prefix. len ( ) + 1 ) ?;
374
+ Some (
375
+ meta. rewrite ( context, shape)
376
+ . map_or_else ( || snippet. to_owned ( ) , |rw| format ! ( "{}[{}]" , prefix, rw) ) ,
377
+ )
378
+ } else {
379
+ Some ( snippet. to_owned ( ) )
380
+ }
383
381
}
384
382
}
385
383
}
0 commit comments