diff --git a/.travis.yml b/.travis.yml index 905c0748f45..f54d4d55cd9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: - | diff --git a/src/imports.rs b/src/imports.rs index f6b41deaef9..08647dee490 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -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); - - 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 - }; + 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 + }; - 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), } } diff --git a/tests/source/issue-3515.rs b/tests/source/issue-3515.rs new file mode 100644 index 00000000000..9f760cb94e8 --- /dev/null +++ b/tests/source/issue-3515.rs @@ -0,0 +1,6 @@ +// rustfmt-reorder_imports: false + +use std :: fmt :: { self , Display } ; +use std :: collections :: HashMap ; + +fn main() {} diff --git a/tests/target/issue-3515.rs b/tests/target/issue-3515.rs new file mode 100644 index 00000000000..b59d03c6c82 --- /dev/null +++ b/tests/target/issue-3515.rs @@ -0,0 +1,6 @@ +// rustfmt-reorder_imports: false + +use std::fmt::{self, Display}; +use std::collections::HashMap; + +fn main() {} diff --git a/tests/target/long-use-statement-issue-3154.rs b/tests/target/long-use-statement-issue-3154.rs index 339382b5bbf..877241e3b6f 100644 --- a/tests/target/long-use-statement-issue-3154.rs +++ b/tests/target/long-use-statement-issue-3154.rs @@ -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;