diff --git a/rustfmt-core/src/chains.rs b/rustfmt-core/src/chains.rs index 87100c7be41..98b425de480 100644 --- a/rustfmt-core/src/chains.rs +++ b/rustfmt-core/src/chains.rs @@ -67,12 +67,9 @@ use shape::Shape; use utils::{first_line_width, last_line_extendable, last_line_width, mk_sp, trimmed_last_line_width, wrap_str}; -use std::borrow::Cow; -use std::cmp::min; -use std::iter; +use std::{iter, borrow::Cow, cmp::min}; -use syntax::{ast, ptr}; -use syntax::codemap::Span; +use syntax::{ast, ptr, codemap::Span}; pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -> Option { debug!("rewrite_chain {:?}", shape); diff --git a/rustfmt-core/src/checkstyle.rs b/rustfmt-core/src/checkstyle.rs index 7f6e650ad22..708f1d54766 100644 --- a/rustfmt-core/src/checkstyle.rs +++ b/rustfmt-core/src/checkstyle.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::io::{self, Write}; -use std::path::Path; +use std::{io::{self, Write}, path::Path}; use config::WriteMode; use rustfmt_diff::{DiffLine, Mismatch}; diff --git a/rustfmt-core/src/closures.rs b/rustfmt-core/src/closures.rs index 6097f6339ed..9b6059532bb 100644 --- a/rustfmt-core/src/closures.rs +++ b/rustfmt-core/src/closures.rs @@ -9,9 +9,7 @@ // except according to those terms. use config::lists::*; -use syntax::{ast, ptr}; -use syntax::codemap::Span; -use syntax::parse::classify; +use syntax::{ast, ptr, codemap::Span, parse::classify}; use codemap::SpanUtils; use expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond, ToExpr}; diff --git a/rustfmt-core/src/codemap.rs b/rustfmt-core/src/codemap.rs index 224b2083561..4760d6cddfc 100644 --- a/rustfmt-core/src/codemap.rs +++ b/rustfmt-core/src/codemap.rs @@ -12,8 +12,8 @@ //! This includes extension traits and methods for looking up spans and line ranges for AST nodes. use config::file_lines::LineRange; -use visitor::SnippetProvider; use syntax::codemap::{BytePos, CodeMap, Span}; +use visitor::SnippetProvider; use comment::FindUncommented; diff --git a/rustfmt-core/src/comment.rs b/rustfmt-core/src/comment.rs index 8b148ccfc37..a442cb35943 100644 --- a/rustfmt-core/src/comment.rs +++ b/rustfmt-core/src/comment.rs @@ -1117,9 +1117,14 @@ fn remove_comment_header(comment: &str) -> &str { #[cfg(test)] mod test { - use super::{contains_comment, rewrite_comment, CharClasses, CodeCharKind, CommentCodeSlices, - FindUncommented, FullCodeCharKind}; - use shape::{Indent, Shape}; + use CharClasses; +use CodeCharKind; +use CommentCodeSlices; +use FindUncommented; +use FullCodeCharKind; +use contains_comment; +use rewrite_comment; +use shape::{Indent, Shape}; #[test] fn char_classes() { diff --git a/rustfmt-core/src/expr.rs b/rustfmt-core/src/expr.rs index 1ed85619235..2a8094cf1bd 100644 --- a/rustfmt-core/src/expr.rs +++ b/rustfmt-core/src/expr.rs @@ -8,13 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::borrow::Cow; -use std::cmp::min; -use std::iter::repeat; +use std::{borrow::Cow, cmp::min, iter::repeat}; use config::lists::*; -use syntax::{ast, ptr}; -use syntax::codemap::{BytePos, CodeMap, Span}; +use syntax::{ast, ptr, codemap::{BytePos, CodeMap, Span}}; use chains::rewrite_chain; use closures; @@ -23,7 +20,8 @@ use comment::{combine_strs_with_missing_comments, contains_comment, recover_comm rewrite_comment, rewrite_missing_comment, FindUncommented}; use config::{Config, ControlBraceStyle, IndentStyle}; use lists::{definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, - struct_lit_shape, struct_lit_tactic, write_list, ListFormatting, ListItem, Separator}; + struct_lit_shape, struct_lit_tactic, write_list, ListFormatting, ListItem, + Separator}; use macros::{rewrite_macro, MacroArg, MacroPosition}; use patterns::{can_be_overflowed_pat, TuplePatField}; use rewrite::{Rewrite, RewriteContext}; diff --git a/rustfmt-core/src/filemap.rs b/rustfmt-core/src/filemap.rs index ee2253043a1..f400aee1a9c 100644 --- a/rustfmt-core/src/filemap.rs +++ b/rustfmt-core/src/filemap.rs @@ -10,9 +10,7 @@ // TODO: add tests -use std::fs::{self, File}; -use std::io::{self, BufWriter, Read, Write}; -use std::path::Path; +use std::{fs::{self, File}, io::{self, BufWriter, Read, Write}, path::Path}; use checkstyle::{output_checkstyle_file, output_footer, output_header}; use config::{Config, NewlineStyle, WriteMode}; diff --git a/rustfmt-core/src/imports.rs b/rustfmt-core/src/imports.rs index 9a6af3f267c..4bb902a008e 100644 --- a/rustfmt-core/src/imports.rs +++ b/rustfmt-core/src/imports.rs @@ -11,8 +11,7 @@ use std::cmp::Ordering; use config::lists::*; -use syntax::ast; -use syntax::codemap::{BytePos, Span}; +use syntax::{ast, codemap::{BytePos, Span}}; use codemap::SpanUtils; use config::IndentStyle; diff --git a/rustfmt-core/src/items.rs b/rustfmt-core/src/items.rs index add3cdc0d79..5ef596ed7ec 100644 --- a/rustfmt-core/src/items.rs +++ b/rustfmt-core/src/items.rs @@ -10,14 +10,11 @@ // Formatting top-level items - functions, structs, enums, traits, impls. -use std::borrow::Cow; -use std::cmp::min; +use std::{borrow::Cow, cmp::min}; use config::lists::*; -use syntax::{abi, ast, ptr, symbol}; -use syntax::ast::{CrateSugar, ImplItem}; -use syntax::codemap::{BytePos, Span}; -use syntax::visit; +use syntax::{abi, ptr, symbol, visit, ast::{self, CrateSugar, ImplItem}, + codemap::{BytePos, Span}}; use codemap::{LineRangeUtils, SpanUtils}; use comment::{combine_strs_with_missing_comments, contains_comment, recover_comment_removed, diff --git a/rustfmt-core/src/lib.rs b/rustfmt-core/src/lib.rs index 5c9a93c6091..5632851fca0 100644 --- a/rustfmt-core/src/lib.rs +++ b/rustfmt-core/src/lib.rs @@ -27,20 +27,11 @@ extern crate syntax; extern crate term; extern crate unicode_segmentation; -use std::collections::HashMap; -use std::fmt; -use std::io::{self, stdout, BufRead, Write}; -use std::iter::repeat; -use std::path::PathBuf; -use std::rc::Rc; -use std::time::Duration; - -use errors::{DiagnosticBuilder, Handler}; -use errors::emitter::{ColorConfig, EmitterWriter}; -use syntax::ast; -use syntax::codemap::{CodeMap, FilePathMapping}; -pub use syntax::codemap::FileName; -use syntax::parse::{self, ParseSess}; +use std::{fmt, collections::HashMap, io::{self, stdout, BufRead, Write}, iter::repeat, + path::PathBuf, rc::Rc, time::Duration}; + +use errors::{DiagnosticBuilder, Handler, emitter::{ColorConfig, EmitterWriter}}; +use syntax::{ast, codemap::{CodeMap, FileName, FilePathMapping}, parse::{self, ParseSess}}; use checkstyle::{output_footer, output_header}; use comment::{CharClasses, FullCodeCharKind}; @@ -49,8 +40,7 @@ use shape::Indent; use utils::use_colored_tty; use visitor::{FmtVisitor, SnippetProvider}; -pub use config::Config; -pub use config::summary::Summary; +use config::{Config, summary::Summary}; #[macro_use] mod utils; @@ -849,7 +839,9 @@ pub fn run(input: Input, config: &Config) -> Summary { #[cfg(test)] mod test { - use super::{format_code_block, format_snippet, Config}; + use Config; +use format_code_block; +use format_snippet; #[test] fn test_no_panic_on_format_snippet_and_format_code_block() { diff --git a/rustfmt-core/src/lists.rs b/rustfmt-core/src/lists.rs index 49797a785bb..1ece1ac49d8 100644 --- a/rustfmt-core/src/lists.rs +++ b/rustfmt-core/src/lists.rs @@ -10,8 +10,7 @@ //! Format list-like expressions and items. -use std::cmp; -use std::iter::Peekable; +use std::{cmp, iter::Peekable}; use config::lists::*; use syntax::codemap::BytePos; diff --git a/rustfmt-core/src/macros.rs b/rustfmt-core/src/macros.rs index 1d40efb9b3a..6f40954f57a 100644 --- a/rustfmt-core/src/macros.rs +++ b/rustfmt-core/src/macros.rs @@ -22,15 +22,11 @@ use std::collections::HashMap; use config::lists::*; -use syntax::ast; -use syntax::codemap::{BytePos, Span}; -use syntax::parse::new_parser_from_tts; -use syntax::parse::parser::Parser; -use syntax::parse::token::{BinOpToken, DelimToken, Token}; -use syntax::print::pprust; -use syntax::symbol; -use syntax::tokenstream::{Cursor, ThinTokenStream, TokenStream, TokenTree}; -use syntax::util::ThinVec; +use syntax::{ast, symbol, codemap::{BytePos, Span}, + parse::{new_parser_from_tts, parser::Parser, + token::{BinOpToken, DelimToken, Token}}, + print::pprust, tokenstream::{Cursor, ThinTokenStream, TokenStream, TokenTree}, + util::ThinVec}; use codemap::SpanUtils; use comment::{contains_comment, remove_trailing_white_spaces, FindUncommented}; diff --git a/rustfmt-core/src/missed_spans.rs b/rustfmt-core/src/missed_spans.rs index dff6b94bd75..aacbf52572d 100644 --- a/rustfmt-core/src/missed_spans.rs +++ b/rustfmt-core/src/missed_spans.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::borrow::Cow; -use std::iter::repeat; +use std::{borrow::Cow, iter::repeat}; use syntax::codemap::{BytePos, FileName, Pos, Span}; diff --git a/rustfmt-core/src/modules.rs b/rustfmt-core/src/modules.rs index 0f439910324..7a07b284bc5 100644 --- a/rustfmt-core/src/modules.rs +++ b/rustfmt-core/src/modules.rs @@ -8,13 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::collections::BTreeMap; -use std::io; -use std::path::{Path, PathBuf}; +use std::{io, collections::BTreeMap, path::{Path, PathBuf}}; -use syntax::ast; -use syntax::codemap::{self, FileName}; -use syntax::parse::parser; +use syntax::{ast, codemap::{self, FileName}, parse::parser}; use utils::contains_skip; diff --git a/rustfmt-core/src/patterns.rs b/rustfmt-core/src/patterns.rs index 4bcf2890c35..4ea6710c51b 100644 --- a/rustfmt-core/src/patterns.rs +++ b/rustfmt-core/src/patterns.rs @@ -9,9 +9,8 @@ // except according to those terms. use config::lists::*; -use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax}; -use syntax::codemap::{self, BytePos, Span}; -use syntax::ptr; +use syntax::{ptr, ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax}, + codemap::{self, BytePos, Span}}; use codemap::SpanUtils; use comment::FindUncommented; diff --git a/rustfmt-core/src/reorder.rs b/rustfmt-core/src/reorder.rs index 99bdf54f6d7..d7c2461e592 100644 --- a/rustfmt-core/src/reorder.rs +++ b/rustfmt-core/src/reorder.rs @@ -19,9 +19,9 @@ use config::{Config, lists::*}; use syntax::{ast, attr, codemap::Span}; -use format_code_block; use codemap::LineRangeUtils; use comment::{combine_strs_with_missing_comments, contains_comment}; +use format_code_block; use imports::{path_to_imported_ident, rewrite_import}; use items::rewrite_mod; use lists::{itemize_list, write_list, ListFormatting}; @@ -31,8 +31,7 @@ use spanned::Spanned; use utils::mk_sp; use visitor::{filter_inline_attrs, is_use_item, rewrite_extern_crate, FmtVisitor}; -use std::cmp::Ordering; -use std::collections::BTreeMap; +use std::{cmp::Ordering, collections::BTreeMap}; fn compare_path_segments(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering { a.identifier.name.as_str().cmp(&b.identifier.name.as_str()) diff --git a/rustfmt-core/src/rewrite.rs b/rustfmt-core/src/rewrite.rs index 708e31d86dd..f6bc807fc67 100644 --- a/rustfmt-core/src/rewrite.rs +++ b/rustfmt-core/src/rewrite.rs @@ -10,8 +10,7 @@ // A generic trait to abstract the rewriting of an element (of the AST). -use syntax::codemap::{CodeMap, Span}; -use syntax::parse::ParseSess; +use syntax::{codemap::{CodeMap, Span}, parse::ParseSess}; use config::{Config, IndentStyle}; use shape::Shape; diff --git a/rustfmt-core/src/rustfmt_diff.rs b/rustfmt-core/src/rustfmt_diff.rs index f9919157620..de2b6f3bf35 100644 --- a/rustfmt-core/src/rustfmt_diff.rs +++ b/rustfmt-core/src/rustfmt_diff.rs @@ -10,10 +10,8 @@ use config::Color; use diff; -use std::collections::VecDeque; -use std::io; +use std::{collections::VecDeque, io::{self, Write}}; use term; -use std::io::Write; use utils::use_colored_tty; #[derive(Debug, PartialEq)] @@ -211,8 +209,9 @@ where #[cfg(test)] mod test { - use super::{make_diff, Mismatch}; - use super::DiffLine::*; + use DiffLine::*; +use Mismatch; +use make_diff; #[test] fn diff_simple() { diff --git a/rustfmt-core/src/shape.rs b/rustfmt-core/src/shape.rs index 22d6a096efa..1ab916d58bf 100644 --- a/rustfmt-core/src/shape.rs +++ b/rustfmt-core/src/shape.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::borrow::Cow; -use std::ops::{Add, Sub}; +use std::{borrow::Cow, ops::{Add, Sub}}; use Config; diff --git a/rustfmt-core/src/spanned.rs b/rustfmt-core/src/spanned.rs index 20dd8438798..f9973f588f6 100644 --- a/rustfmt-core/src/spanned.rs +++ b/rustfmt-core/src/spanned.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use syntax::ast; -use syntax::codemap::Span; +use syntax::{ast, codemap::Span}; use macros::MacroArg; use utils::{mk_sp, outer_attributes}; diff --git a/rustfmt-core/src/string.rs b/rustfmt-core/src/string.rs index 8a6b0e685c4..9e62a535e42 100644 --- a/rustfmt-core/src/string.rs +++ b/rustfmt-core/src/string.rs @@ -150,8 +150,9 @@ pub fn rewrite_string<'a>( #[cfg(test)] mod test { - use super::{rewrite_string, StringFormat}; - use shape::{Indent, Shape}; + use StringFormat; +use rewrite_string; +use shape::{Indent, Shape}; #[test] fn issue343() { diff --git a/rustfmt-core/src/types.rs b/rustfmt-core/src/types.rs index 204b5869f03..b7adfaa6ff7 100644 --- a/rustfmt-core/src/types.rs +++ b/rustfmt-core/src/types.rs @@ -8,13 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::iter::ExactSizeIterator; -use std::ops::Deref; +use std::{iter::ExactSizeIterator, ops::Deref}; use config::lists::*; -use syntax::ast::{self, FunctionRetTy, Mutability}; -use syntax::codemap::{self, BytePos, Span}; -use syntax::symbol::keywords; +use syntax::{ast::{self, FunctionRetTy, Mutability}, codemap::{self, BytePos, Span}, + symbol::keywords}; use codemap::SpanUtils; use config::{IndentStyle, TypeDensity}; diff --git a/rustfmt-core/src/utils.rs b/rustfmt-core/src/utils.rs index 20b30089d70..a6347856887 100644 --- a/rustfmt-core/src/utils.rs +++ b/rustfmt-core/src/utils.rs @@ -10,10 +10,10 @@ use std::borrow::Cow; -use syntax::{abi, ptr}; -use syntax::ast::{self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, - NestedMetaItemKind, Path, Visibility}; -use syntax::codemap::{BytePos, Span, NO_EXPANSION}; +use syntax::{abi, ptr, + ast::{self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, + NestedMetaItemKind, Path, Visibility}, + codemap::{BytePos, Span, NO_EXPANSION}}; use config::Color; use rewrite::RewriteContext; diff --git a/rustfmt-core/src/vertical.rs b/rustfmt-core/src/vertical.rs index 887fefb2272..c91b32426ce 100644 --- a/rustfmt-core/src/vertical.rs +++ b/rustfmt-core/src/vertical.rs @@ -13,8 +13,7 @@ use std::cmp; use config::lists::*; -use syntax::ast; -use syntax::codemap::{BytePos, Span}; +use syntax::{ast, codemap::{BytePos, Span}}; use codemap::SpanUtils; use comment::{combine_strs_with_missing_comments, contains_comment}; diff --git a/rustfmt-core/src/visitor.rs b/rustfmt-core/src/visitor.rs index 897df5b3d8c..282d1abaca7 100644 --- a/rustfmt-core/src/visitor.rs +++ b/rustfmt-core/src/visitor.rs @@ -11,15 +11,12 @@ use std::cmp; use config::lists::*; -use syntax::{ast, visit}; -use syntax::attr::HasAttrs; -use syntax::codemap::{self, BytePos, CodeMap, Pos, Span}; -use syntax::parse::ParseSess; +use syntax::{ast, visit, attr::HasAttrs, codemap::{self, BytePos, CodeMap, Pos, Span}, + parse::ParseSess}; use codemap::{LineRangeUtils, SpanUtils}; -use comment::{combine_strs_with_missing_comments, contains_comment, CodeCharKind, - CommentCodeSlices, FindUncommented}; -use comment::rewrite_doc_comment; +use comment::{combine_strs_with_missing_comments, contains_comment, rewrite_doc_comment, + CodeCharKind, CommentCodeSlices, FindUncommented}; use config::{BraceStyle, Config}; use expr::rewrite_literal; use items::{format_impl, format_trait, format_trait_alias, rewrite_associated_impl_type,