Skip to content

Commit be7b3ba

Browse files
committed
apply inline_attribute_width for extern crate
1 parent e68044f commit be7b3ba

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/imports.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use syntax::source_map::{self, BytePos, Span, DUMMY_SP};
77

88
use crate::comment::combine_strs_with_missing_comments;
99
use crate::config::lists::*;
10-
use crate::config::{Edition, IndentStyle, Version};
10+
use crate::config::{Edition, IndentStyle};
1111
use crate::lists::{
1212
definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator,
1313
};
@@ -250,7 +250,7 @@ impl UseTree {
250250
let hi = self.span.lo();
251251
let span = mk_sp(lo, hi);
252252

253-
let allow_extend = if context.config.version() == Version::Two {
253+
let allow_extend = if attrs.len() == 1 {
254254
let line_len = attr_str.len() + 1 + use_str.len();
255255
!attrs.first().unwrap().is_sugared_doc
256256
&& context.config.inline_attribute_width() >= line_len

src/reorder.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,22 @@ fn rewrite_reorderable_item(
8383
_ => return None,
8484
};
8585

86-
combine_strs_with_missing_comments(context, &attrs_str, &item_str, missed_span, shape, false)
86+
let allow_extend = if attrs.len() == 1 {
87+
let line_len = attrs_str.len() + 1 + item_str.len();
88+
!attrs.first().unwrap().is_sugared_doc
89+
&& context.config.inline_attribute_width() >= line_len
90+
} else {
91+
false
92+
};
93+
94+
combine_strs_with_missing_comments(
95+
context,
96+
&attrs_str,
97+
&item_str,
98+
missed_span,
99+
shape,
100+
allow_extend,
101+
)
87102
}
88103

89104
/// Rewrite a list of items with reordering. Every item in `items` must have

0 commit comments

Comments
 (0)