Skip to content

Commit c593229

Browse files
authored
Merge pull request rust-lang#2535 from nrc/import-ord
Import ordering
2 parents 5516223 + 3a138a2 commit c593229

30 files changed

+537
-174
lines changed

Configurations.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,28 +1297,28 @@ Reorder import statements in group
12971297

12981298
**Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
12991299

1300-
#### `false` (default):
1300+
#### `true` (default):
13011301

13021302
```rust
1303-
use std::mem;
13041303
use std::io;
1304+
use std::mem;
13051305

1306-
use lorem;
1307-
use ipsum;
13081306
use dolor;
1307+
use ipsum;
1308+
use lorem;
13091309
use sit;
13101310
```
13111311

1312-
#### `true`:
1312+
#### `false`:
13131313

1314-
```rust
1315-
use std::io;
1316-
use std::mem;
13171314

1315+
```rust
13181316
use dolor;
13191317
use ipsum;
13201318
use lorem;
13211319
use sit;
1320+
use std::io;
1321+
use std::mem;
13221322
```
13231323

13241324
See also [`reorder_imports`](#reorder_imports).
@@ -1360,7 +1360,11 @@ Reorder `extern crate` statements in group
13601360
- **Possible values**: `true`, `false`
13611361
- **Stable**: No
13621362

1363-
#### `true` (default):
1363+
#### `false` (default):
1364+
1365+
This value has no influence beyond the effect of the [`reorder_extern_crates`](#reorder_extern_crates) option. Set [`reorder_extern_crates`](#reorder_extern_crates) to `false` if you do not want `extern crate` groups to be collapsed and ordered.
1366+
1367+
#### `true`:
13641368

13651369
**Note:** This only takes effect when [`reorder_extern_crates`](#reorder_extern_crates) is set to `true`.
13661370

@@ -1374,10 +1378,6 @@ extern crate lorem;
13741378
extern crate sit;
13751379
```
13761380

1377-
#### `false`:
1378-
1379-
This value has no influence beyond the effect of the [`reorder_extern_crates`](#reorder_extern_crates) option. Set [`reorder_extern_crates`](#reorder_extern_crates) to `false` if you do not want `extern crate` groups to be collapsed and ordered.
1380-
13811381
## `reorder_modules`
13821382

13831383
Reorder `mod` declarations alphabetically in group.
@@ -1386,7 +1386,7 @@ Reorder `mod` declarations alphabetically in group.
13861386
- **Possible values**: `true`, `false`
13871387
- **Stable**: No
13881388

1389-
#### `true`
1389+
#### `true` (default)
13901390

13911391
```rust
13921392
mod a;

bootstrap.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
cargo build --release
88

99
target/release/rustfmt --write-mode=overwrite src/lib.rs
10-
target/release/rustfmt --write-mode=overwrite src/bin/rustfmt.rs
11-
target/release/rustfmt --write-mode=overwrite src/bin/cargo-fmt.rs
12-
target/release/rustfmt --write-mode=overwrite tests/system.rs
10+
target/release/rustfmt --write-mode=overwrite src/bin/main.rs
11+
target/release/rustfmt --write-mode=overwrite src/cargo-fmt/main.rs
1312

1413
for filename in tests/target/*.rs; do
1514
if ! grep -q "rustfmt-" "$filename"; then

src/bin/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ extern crate env_logger;
1414
extern crate getopts;
1515
extern crate rustfmt_nightly as rustfmt;
1616

17-
use std::{env, error};
1817
use std::fs::File;
1918
use std::io::{self, Read, Write};
2019
use std::path::{Path, PathBuf};
2120
use std::str::FromStr;
21+
use std::{env, error};
2222

2323
use getopts::{Matches, Options};
2424

25-
use rustfmt::config::{get_toml_path, Color, Config, WriteMode};
2625
use rustfmt::config::file_lines::FileLines;
26+
use rustfmt::config::{get_toml_path, Color, Config, WriteMode};
2727
use rustfmt::{run, FileName, Input, Summary};
2828

2929
type FmtError = Box<error::Error + Send + Sync>;

src/chains.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ use std::borrow::Cow;
7777
use std::cmp::min;
7878
use std::iter;
7979

80-
use syntax::{ast, ptr};
8180
use syntax::codemap::Span;
81+
use syntax::{ast, ptr};
8282

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

src/closures.rs

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

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

1616
use codemap::SpanUtils;
1717
use expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond, ToExpr};

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

src/config/file_lines.rs

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

1111
//! This module contains types and functions to support formatting specific line ranges.
1212
13-
use std::{cmp, iter, str};
1413
use std::collections::HashMap;
1514
use std::rc::Rc;
15+
use std::{cmp, iter, str};
1616

1717
use serde::de::{Deserialize, Deserializer};
1818
use serde_json as json;

src/config/license.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use std::io;
21
use std::fmt;
32
use std::fs::File;
3+
use std::io;
44
use std::io::Read;
55

66
use regex;

src/config/mod.rs

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

11-
use std::{env, fs};
1211
use std::cell::Cell;
1312
use std::default::Default;
1413
use std::fs::File;
1514
use std::io::{Error, ErrorKind, Read};
1615
use std::path::{Path, PathBuf};
16+
use std::{env, fs};
1717

1818
use regex::Regex;
1919

@@ -23,9 +23,9 @@ mod config_type;
2323
mod options;
2424

2525
pub mod file_lines;
26+
pub mod license;
2627
pub mod lists;
2728
pub mod summary;
28-
pub mod license;
2929

3030
use config::config_type::ConfigType;
3131
use config::file_lines::FileLines;
@@ -70,11 +70,11 @@ create_config! {
7070
// Ordering
7171
reorder_extern_crates: bool, true, false, "Reorder extern crate statements alphabetically";
7272
reorder_extern_crates_in_group: bool, true, false, "Reorder extern crate statements in group";
73-
reorder_imports: bool, false, false, "Reorder import statements alphabetically";
74-
reorder_imports_in_group: bool, false, false, "Reorder import statements in group";
73+
reorder_imports: bool, true, false, "Reorder import statements alphabetically";
74+
reorder_imports_in_group: bool, true, false, "Reorder import statements in group";
7575
reorder_imported_names: bool, true, false,
7676
"Reorder lists of names in import statements alphabetically";
77-
reorder_modules: bool, false, false, "Reorder module statemtents alphabetically in group";
77+
reorder_modules: bool, true, false, "Reorder module statemtents alphabetically in group";
7878

7979
// Spaces around punctuation
8080
binop_separator: SeparatorPlace, SeparatorPlace::Front, false,

src/config/summary.rs

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

11-
use std::time::{Duration, Instant};
1211
use std::default::Default;
12+
use std::time::{Duration, Instant};
1313

1414
#[must_use]
1515
#[derive(Debug, Default, Clone, Copy)]

0 commit comments

Comments
 (0)