New disable_all_formatting config option (#1297)

* New `disable_all_formatting` config option

* Resolve code review comments
This commit is contained in:
Craig M. Brandenburg 2017-02-06 21:11:47 -07:00 committed by Nick Cameron
parent 5925a1a6d1
commit f2c867d067
3 changed files with 8 additions and 0 deletions

View File

@ -326,6 +326,7 @@ macro_rules! create_config {
create_config! {
verbose: bool, false, "Use verbose output";
disable_all_formatting: bool, false, "Don't reformat anything";
skip_children: bool, false, "Don't reformat out of line modules";
file_lines: FileLines, FileLines::all(),
"Lines to format; this is not supported in rustfmt.toml, and can only be specified \

View File

@ -473,6 +473,9 @@ pub fn format_input<T: Write>(input: Input,
mut out: Option<&mut T>)
-> Result<(Summary, FileMap, FormatReport), (io::Error, Summary)> {
let mut summary = Summary::new();
if config.disable_all_formatting {
return Ok((summary, FileMap::new(), FormatReport::new()));
}
let codemap = Rc::new(CodeMap::new());
let tty_handler =

View File

@ -0,0 +1,4 @@
// rustfmt-disable_all_formatting: true
// Don't format anything.
fn main() { println!("This should not be formatted."); }