apply inline_attribute_width for extern crate

This commit is contained in:
rchaser53 2019-02-22 23:02:22 +09:00
parent e68044f8bc
commit be7b3ba2e2
2 changed files with 18 additions and 3 deletions

View File

@ -7,7 +7,7 @@ use syntax::source_map::{self, BytePos, Span, DUMMY_SP};
use crate::comment::combine_strs_with_missing_comments;
use crate::config::lists::*;
use crate::config::{Edition, IndentStyle, Version};
use crate::config::{Edition, IndentStyle};
use crate::lists::{
definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator,
};
@ -250,7 +250,7 @@ impl UseTree {
let hi = self.span.lo();
let span = mk_sp(lo, hi);
let allow_extend = if context.config.version() == Version::Two {
let allow_extend = if attrs.len() == 1 {
let line_len = attr_str.len() + 1 + use_str.len();
!attrs.first().unwrap().is_sugared_doc
&& context.config.inline_attribute_width() >= line_len

View File

@ -83,7 +83,22 @@ fn rewrite_reorderable_item(
_ => return None,
};
combine_strs_with_missing_comments(context, &attrs_str, &item_str, missed_span, shape, false)
let allow_extend = if attrs.len() == 1 {
let line_len = attrs_str.len() + 1 + item_str.len();
!attrs.first().unwrap().is_sugared_doc
&& context.config.inline_attribute_width() >= line_len
} else {
false
};
combine_strs_with_missing_comments(
context,
&attrs_str,
&item_str,
missed_span,
shape,
allow_extend,
)
}
/// Rewrite a list of items with reordering. Every item in `items` must have