Skip to content

Commit

Permalink
Run cargo fmt with merge_imports enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro committed Feb 21, 2018
1 parent c12e8d8 commit 144e595
Show file tree
Hide file tree
Showing 25 changed files with 66 additions and 104 deletions.
7 changes: 2 additions & 5 deletions rustfmt-core/src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
debug!("rewrite_chain {:?}", shape);
Expand Down
3 changes: 1 addition & 2 deletions rustfmt-core/src/checkstyle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 1 addition & 3 deletions rustfmt-core/src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion rustfmt-core/src/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 8 additions & 3 deletions rustfmt-core/src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 4 additions & 6 deletions rustfmt-core/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};
Expand Down
4 changes: 1 addition & 3 deletions rustfmt-core/src/filemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 1 addition & 2 deletions rustfmt-core/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 3 additions & 6 deletions rustfmt-core/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 9 additions & 17 deletions rustfmt-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions rustfmt-core/src/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 5 additions & 9 deletions rustfmt-core/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 1 addition & 2 deletions rustfmt-core/src/missed_spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
8 changes: 2 additions & 6 deletions rustfmt-core/src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 2 additions & 3 deletions rustfmt-core/src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions rustfmt-core/src/reorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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())
Expand Down
3 changes: 1 addition & 2 deletions rustfmt-core/src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions rustfmt-core/src/rustfmt_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions rustfmt-core/src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions rustfmt-core/src/spanned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
5 changes: 3 additions & 2 deletions rustfmt-core/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 3 additions & 5 deletions rustfmt-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
8 changes: 4 additions & 4 deletions rustfmt-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions rustfmt-core/src/vertical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
11 changes: 4 additions & 7 deletions rustfmt-core/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 144e595

Please sign in to comment.