Skip to content

Stabilize disable_all_formatting #3481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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
2 changes: 1 addition & 1 deletion Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ Don't reformat anything

- **Default value**: `false`
- **Possible values**: `true`, `false`
- **Stable**: No (tracking issue: #3388)
- **Stable**: Yes

## `error_on_line_overflow`

Expand Down
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ create_config! {
"Require a specific version of rustfmt";
unstable_features: bool, false, false,
"Enables unstable features. Only available on nightly channel";
disable_all_formatting: bool, false, false, "Don't reformat anything";
disable_all_formatting: bool, false, true, "Don't reformat anything";
skip_children: bool, false, false, "Don't reformat out of line modules";
hide_parse_errors: bool, false, false, "Hide errors from the parser";
error_on_line_overflow: bool, false, false, "Error if unable to get all lines within max_width";
Expand Down
10 changes: 9 additions & 1 deletion src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const SKIP_FILE_WHITE_LIST: &[&str] = &[
// We want to make sure that the `skip_children` is correctly working,
// so we do not want to test this file directly.
"configs/skip_children/foo/mod.rs",
"configs/disable_all_formatting/true_mod/mod.rs",
"configs/disable_all_formatting/false_mod/mod.rs",
"configs/disable_all_formatting/no_entry_false.rs",
"configs/disable_all_formatting/no_entry_true.rs",
"issue-3434/no_entry.rs",
];

Expand Down Expand Up @@ -97,7 +101,11 @@ fn verify_config_used(path: &Path, config_name: &str) {
.lines()
.map(|l| l.unwrap())
.take_while(|l| l.starts_with("//"))
.any(|l| l.starts_with(&format!("// rustfmt-{}", config_name))),
.any(|l| {
let option_name = format!("// rustfmt-{}", config_name);
let skip_name = "// skip-option-check";
l.starts_with(&option_name) || l.starts_with(&skip_name)
}),
format!(
"config option file {} does not contain expected config name",
path.display()
Expand Down
2 changes: 2 additions & 0 deletions tests/source/configs/disable_all_formatting/false.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// rustfmt-disable_all_formatting: false
// Disable all formatting

mod no_entry_false;
mod false_mod;
fn main() {
if lorem{println!("ipsum!");}else{println!("dolor!");}
}
4 changes: 4 additions & 0 deletions tests/source/configs/disable_all_formatting/false_mod/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// skip-option-check
fn bar() {
if lorem{println!("ipsum!");}else{println!("dolor!");}
}
4 changes: 4 additions & 0 deletions tests/source/configs/disable_all_formatting/no_entry_false.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// skip-option-check
fn foo() {
if lorem{println!("ipsum!");}else{println!("dolor!");}
}
4 changes: 4 additions & 0 deletions tests/source/configs/disable_all_formatting/no_entry_true.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// skip-option-check
fn foo() {
iflorem{println!("ipsum!");}else{println!("dolor!");}
}
2 changes: 2 additions & 0 deletions tests/source/configs/disable_all_formatting/true.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// rustfmt-disable_all_formatting: true
// Disable all formatting

mod true_mod;
mod no_entry_true;
fn main() {
iflorem{println!("ipsum!");}else{println!("dolor!");}
}
4 changes: 4 additions & 0 deletions tests/source/configs/disable_all_formatting/true_mod/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// skip-option-check
fn bar() {
iflorem{println!("ipsum!");}else{println!("dolor!");}
}
2 changes: 2 additions & 0 deletions tests/target/configs/disable_all_formatting/false.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// rustfmt-disable_all_formatting: false
// Disable all formatting

mod false_mod;
mod no_entry_false;
fn main() {
if lorem {
println!("ipsum!");
Expand Down
8 changes: 8 additions & 0 deletions tests/target/configs/disable_all_formatting/false_mod/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// skip-option-check
fn bar() {
if lorem {
println!("ipsum!");
} else {
println!("dolor!");
}
}
8 changes: 8 additions & 0 deletions tests/target/configs/disable_all_formatting/no_entry_false.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// skip-option-check
fn foo() {
if lorem {
println!("ipsum!");
} else {
println!("dolor!");
}
}
4 changes: 4 additions & 0 deletions tests/target/configs/disable_all_formatting/no_entry_true.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// skip-option-check
fn foo() {
if lorem{println!("ipsum!");}else{println!("dolor!");}
}
2 changes: 2 additions & 0 deletions tests/target/configs/disable_all_formatting/true.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// rustfmt-disable_all_formatting: true
// Disable all formatting

mod no_entry_true;
mod true_mod;
fn main() {
if lorem{println!("ipsum!");}else{println!("dolor!");}
}
4 changes: 4 additions & 0 deletions tests/target/configs/disable_all_formatting/true_mod/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// skip-option-check
fn bar() {
iflorem{println!("ipsum!");}else{println!("dolor!");}
}