diff options
| author | rchaser53 <tayoshizawa29@gmail.com> | 2019-02-22 23:02:22 +0900 |
|---|---|---|
| committer | rchaser53 <tayoshizawa29@gmail.com> | 2019-02-23 13:46:41 +0900 |
| commit | be7b3ba2e2c8d71fd01dfd7daa0200133d62cfea (patch) | |
| tree | 0e3739e0e8431db3149683dad8c3770a1bee3c87 | |
| parent | e68044f8bcd2b1e90a969fe355b91728d2842d4d (diff) | |
apply inline_attribute_width for extern crate
| -rw-r--r-- | src/imports.rs | 4 | ||||
| -rw-r--r-- | src/reorder.rs | 17 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/imports.rs b/src/imports.rs index 0fa6dec2265..a87d100ca9b 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -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 diff --git a/src/reorder.rs b/src/reorder.rs index 40f6f07c8dc..e206d9249e7 100644 --- a/src/reorder.rs +++ b/src/reorder.rs @@ -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 |
