Skip to content

Commit f2c867d

Browse files
cmbrandenburgnrc
authored andcommitted
New disable_all_formatting config option (#1297)
* New `disable_all_formatting` config option * Resolve code review comments
1 parent 5925a1a commit f2c867d

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ macro_rules! create_config {
326326

327327
create_config! {
328328
verbose: bool, false, "Use verbose output";
329+
disable_all_formatting: bool, false, "Don't reformat anything";
329330
skip_children: bool, false, "Don't reformat out of line modules";
330331
file_lines: FileLines, FileLines::all(),
331332
"Lines to format; this is not supported in rustfmt.toml, and can only be specified \

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ pub fn format_input<T: Write>(input: Input,
473473
mut out: Option<&mut T>)
474474
-> Result<(Summary, FileMap, FormatReport), (io::Error, Summary)> {
475475
let mut summary = Summary::new();
476+
if config.disable_all_formatting {
477+
return Ok((summary, FileMap::new(), FormatReport::new()));
478+
}
476479
let codemap = Rc::new(CodeMap::new());
477480

478481
let tty_handler =
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// rustfmt-disable_all_formatting: true
2+
// Don't format anything.
3+
4+
fn main() { println!("This should not be formatted."); }

0 commit comments

Comments
 (0)