Take attributes_on_same_line_as_field into account

This commit is contained in:
topecongiro 2017-09-04 16:15:32 +09:00
parent 59d1e84259
commit 467b7b5a6c
4 changed files with 16 additions and 2 deletions

View File

@ -265,7 +265,7 @@ where
// Now that we know how we will layout, we can decide for sure if there
// will be a trailing separator.
let mut trailing_separator = formatting.needs_trailing_separator();
let mut result = String::new();
let mut result = String::with_capacity(128);
let cloned_items = items.clone();
let mut iter = items.into_iter().enumerate().peekable();
let mut item_max_width: Option<usize> = None;

View File

@ -53,6 +53,8 @@ impl AlignedItem for ast::StructField {
} else {
mk_sp(self.attrs.last().unwrap().span.hi(), self.span.lo())
};
let attrs_extendable = context.config.attributes_on_same_line_as_field() &&
is_attributes_extendable(&attrs_str);
rewrite_struct_field_prefix(context, self).and_then(|field_str| {
combine_strs_with_missing_comments(
context,
@ -60,7 +62,7 @@ impl AlignedItem for ast::StructField {
&field_str,
missing_span,
shape,
is_attributes_extendable(&attrs_str),
attrs_extendable,
)
})
}

View File

@ -9,3 +9,9 @@ struct Lorem {
#[ serde(rename = "Amet") ]
amet: usize,
}
// #1943
pub struct Bzip2 {
# [ serde (rename = "level") ]
level: i32 ,
}

View File

@ -9,3 +9,9 @@ struct Lorem {
#[serde(rename = "Amet")]
amet: usize,
}
// #1943
pub struct Bzip2 {
#[serde(rename = "level")]
level: i32,
}