Skip to content

Commit ba70ea3

Browse files
authored
Merge pull request #1803 from nrc/writemode
Change the writemode to overwrite
2 parents cf195fb + 6984c05 commit ba70ea3

File tree

6 files changed

+13
-22
lines changed

6 files changed

+13
-22
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "rustfmt-nightly"
4-
version = "0.1.9"
4+
version = "0.2.0"
55
authors = ["Nicholas Cameron <[email protected]>", "The Rustfmt developers"]
66
description = "Tool to find and fix Rust formatting issues"
77
repository = "https://github.com/rust-lang-nursery/rustfmt"

Configurations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2120,5 +2120,5 @@ See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comm
21202120

21212121
What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
21222122

2123-
- **Default value**: `"Replace"`
2123+
- **Default value**: `"Overwrite"`
21242124
- **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ read data from stdin. Alternatively, you can use `cargo fmt` to format all
9090
binary and library targets of your crate.
9191

9292
You'll probably want to specify the write mode. Currently, there are modes for
93-
diff, replace, overwrite, display, coverage, and checkstyle.
93+
`diff`, `replace`, `overwrite`, `display`, `coverage`, `checkstyle`, and `plain`.
9494

95-
* `replace` Is the default and overwrites the original files after creating backups of the files.
96-
* `overwrite` Overwrites the original files _without_ creating backups.
95+
* `overwrite` Is the default and overwrites the original files _without_ creating backups.
96+
* `replace` Overwrites the original files after creating backups of the files.
9797
* `display` Will print the formatted files to stdout.
98+
* `plain` Also writes to stdout, but with no metadata.
9899
* `diff` Will print a diff between the original files and formatted files to stdout.
99100
Will also exit with an error code if there are any differences.
100101
* `checkstyle` Will output the lines that need to be corrected as a checkstyle XML file,
@@ -103,7 +104,7 @@ diff, replace, overwrite, display, coverage, and checkstyle.
103104
The write mode can be set by passing the `--write-mode` flag on
104105
the command line. For example `rustfmt --write-mode=display src/filename.rs`
105106

106-
`cargo fmt` uses `--write-mode=replace` by default.
107+
`cargo fmt` uses `--write-mode=overwrite` by default.
107108

108109
If you want to restrict reformatting to specific sets of lines, you can
109110
use the `--file-lines` option. Its argument is a JSON array of objects

src/bin/rustfmt.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ impl CliOptions {
7878
format!("Invalid write-mode: {}", write_mode),
7979
));
8080
}
81-
} else if !matches.opt_present("no-warn-write-mode") {
82-
println!(
83-
"Warning: the default write-mode for Rustfmt will soon change to overwrite \
84-
- this will not leave backups of changed files."
85-
);
8681
}
8782

8883
if let Some(ref file_lines) = matches.opt_str("file-lines") {
@@ -120,17 +115,11 @@ fn make_opts() -> Options {
120115
opts.optflag("h", "help", "show this message");
121116
opts.optflag("V", "version", "show version information");
122117
opts.optflag("v", "verbose", "print verbose output");
123-
// Suppress warning. Remove this option after the default write mode changed to overwrite.
124-
opts.optflag(
125-
"w",
126-
"no-warn-write-mode",
127-
"inhibit warning about write-mode change",
128-
);
129118
opts.optopt(
130119
"",
131120
"write-mode",
132-
"mode to write in (not usable when piping from stdin)",
133-
"[replace|overwrite|display|diff|coverage|checkstyle]",
121+
"how to write output (not usable when piping from stdin)",
122+
"[replace|overwrite|display|plain|diff|coverage|checkstyle]",
134123
);
135124
opts.optflag("", "skip-children", "don't reformat child modules");
136125

src/config.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,9 @@ create_config! {
596596
spaces_within_square_brackets: bool, false, "Put spaces within non-empty square brackets";
597597
spaces_within_parens: bool, false, "Put spaces within non-empty parentheses";
598598
use_try_shorthand: bool, false, "Replace uses of the try! macro by the ? shorthand";
599-
write_mode: WriteMode, WriteMode::Replace,
600-
"What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage";
599+
write_mode: WriteMode, WriteMode::Overwrite,
600+
"What Write Mode to use when none is supplied: \
601+
Replace, Overwrite, Display, Plain, Diff, Coverage";
601602
condense_wildcard_suffixes: bool, false, "Replace strings of _ wildcards by a single .. in \
602603
tuple patterns";
603604
combine_control_expr: bool, true, "Combine control expressions with funciton calls.";

0 commit comments

Comments
 (0)