diff --git a/Configurations.md b/Configurations.md index 0064f561720..a13fe062d89 100644 --- a/Configurations.md +++ b/Configurations.md @@ -2442,10 +2442,6 @@ Break comments to fit on the line Internal option -## `make_backup` - -Internal option, use `--backup` - ## `print_misformatted_file_names` Internal option, use `-l` or `--files-with-diff` diff --git a/src/bin/main.rs b/src/bin/main.rs index ccbfb4052e2..4ecc81b2856 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -114,7 +114,6 @@ fn make_opts() -> Options { "[files|stdout]" }; opts.optopt("", "emit", "What data to emit and how", emit_opts); - opts.optflag("", "backup", "Backup any modified files."); opts.optopt( "", "config-path", @@ -505,7 +504,6 @@ struct GetOptsOptions { config_path: Option, inline_config: HashMap, emit_mode: Option, - backup: bool, check: bool, edition: Option, color: Option, @@ -607,10 +605,6 @@ impl GetOptsOptions { options.edition = Some(edition_from_edition_str(edition_str)?); } - if matches.opt_present("backup") { - options.backup = true; - } - if matches.opt_present("files-with-diff") { options.print_misformatted_file_names = true; } @@ -674,9 +668,6 @@ impl CliOptions for GetOptsOptions { } else if let Some(emit_mode) = self.emit_mode { config.set().emit_mode(emit_mode); } - if self.backup { - config.set().make_backup(true); - } if let Some(color) = self.color { config.set().color(color); } diff --git a/src/config/mod.rs b/src/config/mod.rs index 94f390ceef4..698a3224591 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -151,7 +151,6 @@ create_config! { "'small' heuristic values"; emit_mode: EmitMode, EmitMode::Files, false, "What emit Mode to use when none is supplied"; - make_backup: bool, false, false, "Backup changed files"; print_misformatted_file_names: bool, false, true, "Prints the names of mismatched files that were formatted. Prints the names of \ files that would be formated when used with `--check` mode. "; @@ -552,7 +551,6 @@ report_todo = "Never" report_fixme = "Never" ignore = [] emit_mode = "Files" -make_backup = false "#, env!("CARGO_PKG_VERSION") ); diff --git a/src/emitter.rs b/src/emitter.rs index dc2c99a301e..25774a35855 100644 --- a/src/emitter.rs +++ b/src/emitter.rs @@ -1,7 +1,6 @@ pub(crate) use self::checkstyle::*; pub(crate) use self::diff::*; pub(crate) use self::files::*; -pub(crate) use self::files_with_backup::*; pub(crate) use self::json::*; pub(crate) use self::modified_lines::*; pub(crate) use self::stdout::*; @@ -12,7 +11,6 @@ use std::path::Path; mod checkstyle; mod diff; mod files; -mod files_with_backup; mod json; mod modified_lines; mod stdout; diff --git a/src/emitter/files_with_backup.rs b/src/emitter/files_with_backup.rs deleted file mode 100644 index 4c15f6fa5ec..00000000000 --- a/src/emitter/files_with_backup.rs +++ /dev/null @@ -1,31 +0,0 @@ -use super::*; -use std::fs; - -#[derive(Debug, Default)] -pub(crate) struct FilesWithBackupEmitter; - -impl Emitter for FilesWithBackupEmitter { - fn emit_formatted_file( - &mut self, - _output: &mut dyn Write, - FormattedFile { - filename, - original_text, - formatted_text, - }: FormattedFile<'_>, - ) -> Result { - let filename = ensure_real_path(filename); - if original_text != formatted_text { - // Do a little dance to make writing safer - write to a temp file - // rename the original to a .bk, then rename the temp file to the - // original. - let tmp_name = filename.with_extension("tmp"); - let bk_name = filename.with_extension("bk"); - - fs::write(&tmp_name, formatted_text)?; - fs::rename(filename, bk_name)?; - fs::rename(tmp_name, filename)?; - } - Ok(EmitterResult::default()) - } -} diff --git a/src/lib.rs b/src/lib.rs index dbd9469908e..eab23dffff0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -478,9 +478,6 @@ impl<'b, T: Write + 'b> Session<'b, T> { pub(crate) fn create_emitter<'a>(config: &Config) -> Box { match config.emit_mode() { - EmitMode::Files if config.make_backup() => { - Box::new(emitter::FilesWithBackupEmitter::default()) - } EmitMode::Files => Box::new(emitter::FilesEmitter::new( config.print_misformatted_file_names(), )),