Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6c96ab7

Browse files
committed
address review comment in Attribute rewrite fn
1 parent 171e656 commit 6c96ab7

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

src/attr.rs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -351,35 +351,33 @@ impl Rewrite for ast::Attribute {
351351
return Some(snippet.to_owned());
352352
}
353353

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+
);
373369
}
374370
}
375-
}
376371

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+
}
383381
}
384382
}
385383
}

0 commit comments

Comments
 (0)