Skip to content

Commit

Permalink
New disable_all_formatting config option (#1297)
Browse files Browse the repository at this point in the history
* New `disable_all_formatting` config option

* Resolve code review comments
  • Loading branch information
cmbrandenburg authored and nrc committed Feb 7, 2017
1 parent 5925a1a commit f2c867d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config.rs
Expand Up @@ -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 \
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Expand Up @@ -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 =
Expand Down
4 changes: 4 additions & 0 deletions tests/target/disable_all_formatting.rs
@@ -0,0 +1,4 @@
// rustfmt-disable_all_formatting: true
// Don't format anything.

fn main() { println!("This should not be formatted."); }

0 comments on commit f2c867d

Please sign in to comment.