mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-31 17:12:53 +00:00
New disable_all_formatting
config option (#1297)
* New `disable_all_formatting` config option * Resolve code review comments
This commit is contained in:
parent
5925a1a6d1
commit
f2c867d067
@ -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 \
|
||||
|
@ -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 =
|
||||
|
4
tests/target/disable_all_formatting.rs
Normal file
4
tests/target/disable_all_formatting.rs
Normal file
@ -0,0 +1,4 @@
|
||||
// rustfmt-disable_all_formatting: true
|
||||
// Don't format anything.
|
||||
|
||||
fn main() { println!("This should not be formatted."); }
|
Loading…
Reference in New Issue
Block a user