address review comment in Attribute rewrite fn
@@ -351,12 +351,9 @@ impl Rewrite for ast::Attribute {
return Some(snippet.to_owned());
}
- let meta = self.meta();
-
+ if let Some(ref meta) = self.meta() {
// This attribute is possibly a doc attribute needing normalization to a doc comment
- if context.config.normalize_doc_attributes() {
- if let Some(ref meta) = meta {
- if meta.check_name("doc") {
+ if context.config.normalize_doc_attributes() && meta.check_name("doc") {
if let Some(ref literal) = meta.value_str() {
let comment_style = match self.style {
ast::AttrStyle::Inner => CommentStyle::Doc,
@@ -371,15 +368,16 @@ impl Rewrite for ast::Attribute {
);
}
}
- }
- }
// 1 = `[`
let shape = shape.offset_left(prefix.len() + 1)?;
Some(
- meta.and_then(|meta| meta.rewrite(context, shape))
+ meta.rewrite(context, shape)
.map_or_else(|| snippet.to_owned(), |rw| format!("{}[{}]", prefix, rw)),
)
+ } else {
+ Some(snippet.to_owned())
+ }
}
}
}
