Merge pull request #3523 from topecongiro/issue-3515
Attempt to format attributes if only they exist
This commit is contained in:
commit
a6daccc229
5 changed files with 38 additions and 24 deletions
|
@ -19,7 +19,6 @@ matrix:
|
|||
- env: CFG_RELEASE_CHANNEL=beta
|
||||
- os: osx
|
||||
- env: INTEGRATION=bitflags
|
||||
- env: INTEGRATION=cargo
|
||||
- env: INTEGRATION=chalk
|
||||
- env: INTEGRATION=crater
|
||||
- env: INTEGRATION=error-chain
|
||||
|
@ -41,6 +40,8 @@ matrix:
|
|||
- env: INTEGRATION=rust-semverver
|
||||
# can be moved back to include section after https://github.com/rust-lang-nursery/failure/pull/298 is merged
|
||||
- env: INTEGRATION=failure
|
||||
# `cargo test` doesn't finish - disabling for now.
|
||||
# - env: INTEGRATION=cargo
|
||||
|
||||
script:
|
||||
- |
|
||||
|
|
|
@ -242,30 +242,31 @@ impl UseTree {
|
|||
format!("{}use {};", vis, s)
|
||||
}
|
||||
})?;
|
||||
if let Some(ref attrs) = self.attrs {
|
||||
let attr_str = attrs.rewrite(context, shape)?;
|
||||
let lo = attrs.last().as_ref()?.span().hi();
|
||||
let hi = self.span.lo();
|
||||
let span = mk_sp(lo, hi);
|
||||
match self.attrs {
|
||||
Some(ref attrs) if !attrs.is_empty() => {
|
||||
let attr_str = attrs.rewrite(context, shape)?;
|
||||
let lo = attrs.last().as_ref()?.span().hi();
|
||||
let hi = self.span.lo();
|
||||
let span = mk_sp(lo, hi);
|
||||
|
||||
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
|
||||
} else {
|
||||
false
|
||||
};
|
||||
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
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
combine_strs_with_missing_comments(
|
||||
context,
|
||||
&attr_str,
|
||||
&use_str,
|
||||
span,
|
||||
shape,
|
||||
allow_extend,
|
||||
)
|
||||
} else {
|
||||
Some(use_str)
|
||||
combine_strs_with_missing_comments(
|
||||
context,
|
||||
&attr_str,
|
||||
&use_str,
|
||||
span,
|
||||
shape,
|
||||
allow_extend,
|
||||
)
|
||||
}
|
||||
_ => Some(use_str),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
6
tests/source/issue-3515.rs
Normal file
6
tests/source/issue-3515.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
// rustfmt-reorder_imports: false
|
||||
|
||||
use std :: fmt :: { self , Display } ;
|
||||
use std :: collections :: HashMap ;
|
||||
|
||||
fn main() {}
|
6
tests/target/issue-3515.rs
Normal file
6
tests/target/issue-3515.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
// rustfmt-reorder_imports: false
|
||||
|
||||
use std::fmt::{self, Display};
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn main() {}
|
|
@ -1,3 +1,3 @@
|
|||
// rustfmt-reorder_imports: false
|
||||
|
||||
pub use self :: super :: super :: super :: root::mozilla::detail::StringClassFlags as nsTStringRepr_ClassFlags ;
|
||||
pub use self::super::super::super::root::mozilla::detail::StringClassFlags as nsTStringRepr_ClassFlags;
|
||||
|
|
Loading…
Reference in a new issue