Put attributes and struct fields on different line
This commit is contained in:
parent
6e05ca87b0
commit
2420d346c5
3 changed files with 5 additions and 8 deletions
|
|
@ -204,7 +204,8 @@ impl str::FromStr for FileLines {
|
|||
// For JSON decoding.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
struct JsonSpan {
|
||||
#[serde(deserialize_with = "deserialize_filename")] file: FileName,
|
||||
#[serde(deserialize_with = "deserialize_filename")]
|
||||
file: FileName,
|
||||
range: (usize, usize),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -558,15 +558,13 @@ impl<'a> FmtVisitor<'a> {
|
|||
}
|
||||
};
|
||||
|
||||
let attrs_extendable = attrs_str.is_empty()
|
||||
|| (context.config.same_line_attributes() && is_attributes_extendable(&attrs_str));
|
||||
combine_strs_with_missing_comments(
|
||||
&context,
|
||||
&attrs_str,
|
||||
&variant_body,
|
||||
span,
|
||||
shape,
|
||||
attrs_extendable,
|
||||
is_attributes_extendable(&attrs_str),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1439,8 +1437,7 @@ pub fn rewrite_struct_field(
|
|||
let prefix = rewrite_struct_field_prefix(context, field)?;
|
||||
|
||||
let attrs_str = field.attrs.rewrite(context, shape)?;
|
||||
let attrs_extendable = attrs_str.is_empty()
|
||||
|| (context.config.same_line_attributes() && is_attributes_extendable(&attrs_str));
|
||||
let attrs_extendable = field.ident.is_none() && is_attributes_extendable(&attrs_str);
|
||||
let missing_span = if field.attrs.is_empty() {
|
||||
mk_sp(field.span.lo(), field.span.lo())
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ impl AlignedItem for ast::StructField {
|
|||
} else {
|
||||
mk_sp(self.attrs.last().unwrap().span.hi(), self.span.lo())
|
||||
};
|
||||
let attrs_extendable =
|
||||
context.config.same_line_attributes() && is_attributes_extendable(&attrs_str);
|
||||
let attrs_extendable = self.ident.is_none() && is_attributes_extendable(&attrs_str);
|
||||
rewrite_struct_field_prefix(context, self).and_then(|field_str| {
|
||||
combine_strs_with_missing_comments(
|
||||
context,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue