Skip to content

Commit 367a874

Browse files
matthiaskrgrcalebcartwright
authored andcommitted
address review comments and fix new clippy findings introduced since I made this PR
1 parent 21734b8 commit 367a874

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/formatting/attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn format_derive(
187187
} else if let SeparatorTactic::Always = context.config.trailing_comma() {
188188
// Retain the trailing comma.
189189
result.push_str(&item_str);
190-
} else if item_str.ends_with(",") {
190+
} else if item_str.ends_with(',') {
191191
// Remove the trailing comma.
192192
result.push_str(&item_str[..item_str.len() - 1]);
193193
} else {

src/formatting/comment.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1704,8 +1704,8 @@ impl<'a> Iterator for CommentReducer<'a> {
17041704
fn remove_comment_header(comment: &str) -> &str {
17051705
if comment.starts_with("///") || comment.starts_with("//!") {
17061706
&comment[3..]
1707-
} else if comment.starts_with("//") {
1708-
&comment[2..]
1707+
} else if let Some(stripped) = comment.strip_prefix("//") {
1708+
&stripped
17091709
} else if (comment.starts_with("/**") && !comment.starts_with("/**/"))
17101710
|| comment.starts_with("/*!")
17111711
{

src/formatting/vertical.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,15 @@ impl AlignedItem for ast::StructField {
5050
mk_sp(self.attrs.last().unwrap().span.hi(), self.span.lo())
5151
};
5252
let attrs_extendable = self.ident.is_none() && is_attributes_extendable(&attrs_str);
53-
Some(rewrite_struct_field_prefix(context, self)).and_then(|field_str| {
54-
combine_strs_with_missing_comments(
55-
context,
56-
&attrs_str,
57-
&field_str,
58-
missing_span,
59-
shape,
60-
attrs_extendable,
61-
)
62-
})
53+
let prefix = rewrite_struct_field_prefix(context, self);
54+
combine_strs_with_missing_comments(
55+
context,
56+
&attrs_str,
57+
&prefix,
58+
missing_span,
59+
shape,
60+
attrs_extendable,
61+
)
6362
}
6463

6564
fn rewrite_aligned_item(

0 commit comments

Comments
 (0)