Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// rustfmt-disable_all_formatting: true
// Don't format anything.

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