Skip to content

Commit f222ae4

Browse files
committed
Run cargo fmt with merge_imports enabled
1 parent f51f26e commit f222ae4

25 files changed

+66
-104
lines changed

rustfmt-core/src/chains.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,9 @@ use shape::Shape;
6767
use utils::{first_line_width, last_line_extendable, last_line_width, mk_sp,
6868
trimmed_last_line_width, wrap_str};
6969

70-
use std::borrow::Cow;
71-
use std::cmp::min;
72-
use std::iter;
70+
use std::{iter, borrow::Cow, cmp::min};
7371

74-
use syntax::{ast, ptr};
75-
use syntax::codemap::Span;
72+
use syntax::{ast, ptr, codemap::Span};
7673

7774
pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -> Option<String> {
7875
debug!("rewrite_chain {:?}", shape);

rustfmt-core/src/checkstyle.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::io::{self, Write};
12-
use std::path::Path;
11+
use std::{io::{self, Write}, path::Path};
1312

1413
use config::WriteMode;
1514
use rustfmt_diff::{DiffLine, Mismatch};

rustfmt-core/src/closures.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
// except according to those terms.
1010

1111
use config::lists::*;
12-
use syntax::{ast, ptr};
13-
use syntax::codemap::Span;
14-
use syntax::parse::classify;
12+
use syntax::{ast, ptr, codemap::Span, parse::classify};
1513

1614
use codemap::SpanUtils;
1715
use expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond, ToExpr};

rustfmt-core/src/codemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
//! This includes extension traits and methods for looking up spans and line ranges for AST nodes.
1313
1414
use config::file_lines::LineRange;
15-
use visitor::SnippetProvider;
1615
use syntax::codemap::{BytePos, CodeMap, Span};
16+
use visitor::SnippetProvider;
1717

1818
use comment::FindUncommented;
1919

rustfmt-core/src/comment.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,14 @@ fn remove_comment_header(comment: &str) -> &str {
11171117

11181118
#[cfg(test)]
11191119
mod test {
1120-
use super::{contains_comment, rewrite_comment, CharClasses, CodeCharKind, CommentCodeSlices,
1121-
FindUncommented, FullCodeCharKind};
1122-
use shape::{Indent, Shape};
1120+
use CharClasses;
1121+
use CodeCharKind;
1122+
use CommentCodeSlices;
1123+
use FindUncommented;
1124+
use FullCodeCharKind;
1125+
use contains_comment;
1126+
use rewrite_comment;
1127+
use shape::{Indent, Shape};
11231128

11241129
#[test]
11251130
fn char_classes() {

rustfmt-core/src/expr.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::borrow::Cow;
12-
use std::cmp::min;
13-
use std::iter::repeat;
11+
use std::{borrow::Cow, cmp::min, iter::repeat};
1412

1513
use config::lists::*;
16-
use syntax::{ast, ptr};
17-
use syntax::codemap::{BytePos, CodeMap, Span};
14+
use syntax::{ast, ptr, codemap::{BytePos, CodeMap, Span}};
1815

1916
use chains::rewrite_chain;
2017
use closures;
@@ -23,7 +20,8 @@ use comment::{combine_strs_with_missing_comments, contains_comment, recover_comm
2320
rewrite_comment, rewrite_missing_comment, FindUncommented};
2421
use config::{Config, ControlBraceStyle, IndentStyle};
2522
use lists::{definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting,
26-
struct_lit_shape, struct_lit_tactic, write_list, ListFormatting, ListItem, Separator};
23+
struct_lit_shape, struct_lit_tactic, write_list, ListFormatting, ListItem,
24+
Separator};
2725
use macros::{rewrite_macro, MacroArg, MacroPosition};
2826
use patterns::{can_be_overflowed_pat, TuplePatField};
2927
use rewrite::{Rewrite, RewriteContext};

rustfmt-core/src/filemap.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
// TODO: add tests
1212

13-
use std::fs::{self, File};
14-
use std::io::{self, BufWriter, Read, Write};
15-
use std::path::Path;
13+
use std::{fs::{self, File}, io::{self, BufWriter, Read, Write}, path::Path};
1614

1715
use checkstyle::{output_checkstyle_file, output_footer, output_header};
1816
use config::{Config, NewlineStyle, WriteMode};

rustfmt-core/src/imports.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
use std::cmp::Ordering;
1212

1313
use config::lists::*;
14-
use syntax::ast;
15-
use syntax::codemap::{BytePos, Span};
14+
use syntax::{ast, codemap::{BytePos, Span}};
1615

1716
use codemap::SpanUtils;
1817
use config::IndentStyle;

rustfmt-core/src/items.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@
1010

1111
// Formatting top-level items - functions, structs, enums, traits, impls.
1212

13-
use std::borrow::Cow;
14-
use std::cmp::min;
13+
use std::{borrow::Cow, cmp::min};
1514

1615
use config::lists::*;
17-
use syntax::{abi, ast, ptr, symbol};
18-
use syntax::ast::{CrateSugar, ImplItem};
19-
use syntax::codemap::{BytePos, Span};
20-
use syntax::visit;
16+
use syntax::{abi, ptr, symbol, visit, ast::{self, CrateSugar, ImplItem},
17+
codemap::{BytePos, Span}};
2118

2219
use codemap::{LineRangeUtils, SpanUtils};
2320
use comment::{combine_strs_with_missing_comments, contains_comment, recover_comment_removed,

rustfmt-core/src/lib.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,11 @@ extern crate syntax;
2727
extern crate term;
2828
extern crate unicode_segmentation;
2929

30-
use std::collections::HashMap;
31-
use std::fmt;
32-
use std::io::{self, stdout, BufRead, Write};
33-
use std::iter::repeat;
34-
use std::path::PathBuf;
35-
use std::rc::Rc;
36-
use std::time::Duration;
37-
38-
use errors::{DiagnosticBuilder, Handler};
39-
use errors::emitter::{ColorConfig, EmitterWriter};
40-
use syntax::ast;
41-
use syntax::codemap::{CodeMap, FilePathMapping};
42-
pub use syntax::codemap::FileName;
43-
use syntax::parse::{self, ParseSess};
30+
use std::{fmt, collections::HashMap, io::{self, stdout, BufRead, Write}, iter::repeat,
31+
path::PathBuf, rc::Rc, time::Duration};
32+
33+
use errors::{DiagnosticBuilder, Handler, emitter::{ColorConfig, EmitterWriter}};
34+
use syntax::{ast, codemap::{CodeMap, FileName, FilePathMapping}, parse::{self, ParseSess}};
4435

4536
use checkstyle::{output_footer, output_header};
4637
use comment::{CharClasses, FullCodeCharKind};
@@ -49,8 +40,7 @@ use shape::Indent;
4940
use utils::use_colored_tty;
5041
use visitor::{FmtVisitor, SnippetProvider};
5142

52-
pub use config::Config;
53-
pub use config::summary::Summary;
43+
use config::{Config, summary::Summary};
5444

5545
#[macro_use]
5646
mod utils;
@@ -849,7 +839,9 @@ pub fn run(input: Input, config: &Config) -> Summary {
849839

850840
#[cfg(test)]
851841
mod test {
852-
use super::{format_code_block, format_snippet, Config};
842+
use Config;
843+
use format_code_block;
844+
use format_snippet;
853845

854846
#[test]
855847
fn test_no_panic_on_format_snippet_and_format_code_block() {

rustfmt-core/src/lists.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
//! Format list-like expressions and items.
1212
13-
use std::cmp;
14-
use std::iter::Peekable;
13+
use std::{cmp, iter::Peekable};
1514

1615
use config::lists::*;
1716
use syntax::codemap::BytePos;

rustfmt-core/src/macros.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@
2222
use std::collections::HashMap;
2323

2424
use config::lists::*;
25-
use syntax::ast;
26-
use syntax::codemap::{BytePos, Span};
27-
use syntax::parse::new_parser_from_tts;
28-
use syntax::parse::parser::Parser;
29-
use syntax::parse::token::{BinOpToken, DelimToken, Token};
30-
use syntax::print::pprust;
31-
use syntax::symbol;
32-
use syntax::tokenstream::{Cursor, ThinTokenStream, TokenStream, TokenTree};
33-
use syntax::util::ThinVec;
25+
use syntax::{ast, symbol, codemap::{BytePos, Span},
26+
parse::{new_parser_from_tts, parser::Parser,
27+
token::{BinOpToken, DelimToken, Token}},
28+
print::pprust, tokenstream::{Cursor, ThinTokenStream, TokenStream, TokenTree},
29+
util::ThinVec};
3430

3531
use codemap::SpanUtils;
3632
use comment::{contains_comment, remove_trailing_white_spaces, FindUncommented};

rustfmt-core/src/missed_spans.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::borrow::Cow;
12-
use std::iter::repeat;
11+
use std::{borrow::Cow, iter::repeat};
1312

1413
use syntax::codemap::{BytePos, FileName, Pos, Span};
1514

rustfmt-core/src/modules.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::collections::BTreeMap;
12-
use std::io;
13-
use std::path::{Path, PathBuf};
11+
use std::{io, collections::BTreeMap, path::{Path, PathBuf}};
1412

15-
use syntax::ast;
16-
use syntax::codemap::{self, FileName};
17-
use syntax::parse::parser;
13+
use syntax::{ast, codemap::{self, FileName}, parse::parser};
1814

1915
use utils::contains_skip;
2016

rustfmt-core/src/patterns.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
// except according to those terms.
1010

1111
use config::lists::*;
12-
use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax};
13-
use syntax::codemap::{self, BytePos, Span};
14-
use syntax::ptr;
12+
use syntax::{ptr, ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax},
13+
codemap::{self, BytePos, Span}};
1514

1615
use codemap::SpanUtils;
1716
use comment::FindUncommented;

rustfmt-core/src/reorder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
use config::{Config, lists::*};
2020
use syntax::{ast, attr, codemap::Span};
2121

22-
use format_code_block;
2322
use codemap::LineRangeUtils;
2423
use comment::{combine_strs_with_missing_comments, contains_comment};
24+
use format_code_block;
2525
use imports::{path_to_imported_ident, rewrite_import};
2626
use items::rewrite_mod;
2727
use lists::{itemize_list, write_list, ListFormatting};
@@ -31,8 +31,7 @@ use spanned::Spanned;
3131
use utils::mk_sp;
3232
use visitor::{filter_inline_attrs, is_use_item, rewrite_extern_crate, FmtVisitor};
3333

34-
use std::cmp::Ordering;
35-
use std::collections::BTreeMap;
34+
use std::{cmp::Ordering, collections::BTreeMap};
3635

3736
fn compare_path_segments(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering {
3837
a.identifier.name.as_str().cmp(&b.identifier.name.as_str())

rustfmt-core/src/rewrite.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
// A generic trait to abstract the rewriting of an element (of the AST).
1212

13-
use syntax::codemap::{CodeMap, Span};
14-
use syntax::parse::ParseSess;
13+
use syntax::{codemap::{CodeMap, Span}, parse::ParseSess};
1514

1615
use config::{Config, IndentStyle};
1716
use shape::Shape;

rustfmt-core/src/rustfmt_diff.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111
use config::Color;
1212
use diff;
13-
use std::collections::VecDeque;
14-
use std::io;
13+
use std::{collections::VecDeque, io::{self, Write}};
1514
use term;
16-
use std::io::Write;
1715
use utils::use_colored_tty;
1816

1917
#[derive(Debug, PartialEq)]
@@ -211,8 +209,9 @@ where
211209

212210
#[cfg(test)]
213211
mod test {
214-
use super::{make_diff, Mismatch};
215-
use super::DiffLine::*;
212+
use DiffLine::*;
213+
use Mismatch;
214+
use make_diff;
216215

217216
#[test]
218217
fn diff_simple() {

rustfmt-core/src/shape.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::borrow::Cow;
12-
use std::ops::{Add, Sub};
11+
use std::{borrow::Cow, ops::{Add, Sub}};
1312

1413
use Config;
1514

rustfmt-core/src/spanned.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use syntax::ast;
12-
use syntax::codemap::Span;
11+
use syntax::{ast, codemap::Span};
1312

1413
use macros::MacroArg;
1514
use utils::{mk_sp, outer_attributes};

rustfmt-core/src/string.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ pub fn rewrite_string<'a>(
150150

151151
#[cfg(test)]
152152
mod test {
153-
use super::{rewrite_string, StringFormat};
154-
use shape::{Indent, Shape};
153+
use StringFormat;
154+
use rewrite_string;
155+
use shape::{Indent, Shape};
155156

156157
#[test]
157158
fn issue343() {

rustfmt-core/src/types.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::iter::ExactSizeIterator;
12-
use std::ops::Deref;
11+
use std::{iter::ExactSizeIterator, ops::Deref};
1312

1413
use config::lists::*;
15-
use syntax::ast::{self, FunctionRetTy, Mutability};
16-
use syntax::codemap::{self, BytePos, Span};
17-
use syntax::symbol::keywords;
14+
use syntax::{ast::{self, FunctionRetTy, Mutability}, codemap::{self, BytePos, Span},
15+
symbol::keywords};
1816

1917
use codemap::SpanUtils;
2018
use config::{IndentStyle, TypeDensity};

rustfmt-core/src/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
use std::borrow::Cow;
1212

13-
use syntax::{abi, ptr};
14-
use syntax::ast::{self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem,
15-
NestedMetaItemKind, Path, Visibility};
16-
use syntax::codemap::{BytePos, Span, NO_EXPANSION};
13+
use syntax::{abi, ptr,
14+
ast::{self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem,
15+
NestedMetaItemKind, Path, Visibility},
16+
codemap::{BytePos, Span, NO_EXPANSION}};
1717

1818
use config::Color;
1919
use rewrite::RewriteContext;

rustfmt-core/src/vertical.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
use std::cmp;
1414

1515
use config::lists::*;
16-
use syntax::ast;
17-
use syntax::codemap::{BytePos, Span};
16+
use syntax::{ast, codemap::{BytePos, Span}};
1817

1918
use codemap::SpanUtils;
2019
use comment::{combine_strs_with_missing_comments, contains_comment};

rustfmt-core/src/visitor.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111
use std::cmp;
1212

1313
use config::lists::*;
14-
use syntax::{ast, visit};
15-
use syntax::attr::HasAttrs;
16-
use syntax::codemap::{self, BytePos, CodeMap, Pos, Span};
17-
use syntax::parse::ParseSess;
14+
use syntax::{ast, visit, attr::HasAttrs, codemap::{self, BytePos, CodeMap, Pos, Span},
15+
parse::ParseSess};
1816

1917
use codemap::{LineRangeUtils, SpanUtils};
20-
use comment::{combine_strs_with_missing_comments, contains_comment, CodeCharKind,
21-
CommentCodeSlices, FindUncommented};
22-
use comment::rewrite_doc_comment;
18+
use comment::{combine_strs_with_missing_comments, contains_comment, rewrite_doc_comment,
19+
CodeCharKind, CommentCodeSlices, FindUncommented};
2320
use config::{BraceStyle, Config};
2421
use expr::rewrite_literal;
2522
use items::{format_impl, format_trait, format_trait_alias, rewrite_associated_impl_type,

0 commit comments

Comments
 (0)