From d287b06ebac33c73bbb56cbee76f3882c6df1383 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Sat, 4 Nov 2017 22:24:43 +0900 Subject: [PATCH 1/2] Rename 'chain_one_line_max' to 'chain_width' --- Configurations.md | 12 ++++++------ src/chains.rs | 2 +- src/config.rs | 4 ++-- tests/source/chains.rs | 2 +- tests/source/configs-chain_one_line_max-above.rs | 2 +- tests/source/configs-chain_one_line_max-below.rs | 2 +- tests/target/chains.rs | 2 +- tests/target/configs-chain_one_line_max-above.rs | 2 +- tests/target/configs-chain_one_line_max-below.rs | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Configurations.md b/Configurations.md index 46d94eb1474..29782dbec0e 100644 --- a/Configurations.md +++ b/Configurations.md @@ -227,26 +227,26 @@ let lorem = ipsum.dolor() .elit(); ``` -See also [`chain_one_line_max`](#chain_one_line_max). +See also [`chain_width`](#chain_width). -## `chain_one_line_max` +## `chain_width` Maximum length of a chain to fit on a single line - **Default value**: `60` - **Possible values**: any positive integer -#### Lines shorter than `chain_one_line_max`: +#### Lines shorter than `chain_width`: ```rust let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elit(); ``` -#### Lines longer than `chain_one_line_max`: +#### Lines longer than `chain_width`: See [`chain_indent`](#chain_indent). ## `chain_split_single_child` -Split a chain with a single child if its length exceeds [`chain_one_line_max`](#chain_one_line_max). +Split a chain with a single child if its length exceeds [`chain_width`](#chain_width). - **Default value**: `false` - **Possible values**: `false`, `true` @@ -264,7 +264,7 @@ let files = fs::read_dir("tests/coverage/source") .expect("Couldn't read source dir"); ``` -See also [`chain_one_line_max`](#chain_one_line_max). +See also [`chain_width`](#chain_width). ## `closure_block_indent_threshold` diff --git a/src/chains.rs b/src/chains.rs index a35648de5c2..9864c901dc2 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -161,7 +161,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) - let one_line_budget = if rewrites.is_empty() && !context.config.chain_split_single_child() { shape.width } else { - min(shape.width, context.config.chain_one_line_max()) + min(shape.width, context.config.chain_width()) }; let all_in_one_line = !parent_rewrite_contains_newline && rewrites.iter().all(|s| !s.contains('\n')) diff --git a/src/config.rs b/src/config.rs index 302719e72e3..99cea7e3c71 100644 --- a/src/config.rs +++ b/src/config.rs @@ -587,9 +587,9 @@ create_config! { report_fixme: ReportTactic, ReportTactic::Never, false, "Report all, none or unnumbered occurrences of FIXME in source file comments"; chain_indent: IndentStyle, IndentStyle::Block, false, "Indentation of chain"; - chain_one_line_max: usize, 60, false, "Maximum length of a chain to fit on a single line"; + chain_width: usize, 60, false, "Maximum length of a chain to fit on a single line"; chain_split_single_child: bool, false, false, "Split a chain with a single child if its length \ - exceeds `chain_one_line_max`"; + exceeds `chain_width`"; imports_indent: IndentStyle, IndentStyle::Visual, false, "Indent of imports"; imports_layout: ListTactic, ListTactic::Mixed, false, "Item layout inside a import block"; reorder_extern_crates: bool, true, false, "Reorder extern crate statements alphabetically"; diff --git a/tests/source/chains.rs b/tests/source/chains.rs index 7a8e4dc9176..fe5555f79cb 100644 --- a/tests/source/chains.rs +++ b/tests/source/chains.rs @@ -1,6 +1,6 @@ // rustfmt-normalize_comments: true // rustfmt-single_line_if_else_max_width: 0 -// rustfmt-chain_one_line_max: 100 +// rustfmt-chain_width: 100 // Test chain formatting. fn main() { diff --git a/tests/source/configs-chain_one_line_max-above.rs b/tests/source/configs-chain_one_line_max-above.rs index 6e72c09b215..d26505b8628 100644 --- a/tests/source/configs-chain_one_line_max-above.rs +++ b/tests/source/configs-chain_one_line_max-above.rs @@ -1,4 +1,4 @@ -// rustfmt-chain_one_line_max: 10 +// rustfmt-chain_width: 10 // Chain one line max fn main() { diff --git a/tests/source/configs-chain_one_line_max-below.rs b/tests/source/configs-chain_one_line_max-below.rs index e869c782d07..d877deb74eb 100644 --- a/tests/source/configs-chain_one_line_max-below.rs +++ b/tests/source/configs-chain_one_line_max-below.rs @@ -1,4 +1,4 @@ -// rustfmt-chain_one_line_max: 100 +// rustfmt-chain_width: 100 // Chain one line max fn main() { diff --git a/tests/target/chains.rs b/tests/target/chains.rs index 573570704ab..d3868e1acd8 100644 --- a/tests/target/chains.rs +++ b/tests/target/chains.rs @@ -1,6 +1,6 @@ // rustfmt-normalize_comments: true // rustfmt-single_line_if_else_max_width: 0 -// rustfmt-chain_one_line_max: 100 +// rustfmt-chain_width: 100 // Test chain formatting. fn main() { diff --git a/tests/target/configs-chain_one_line_max-above.rs b/tests/target/configs-chain_one_line_max-above.rs index e766f0d0ea2..1b5e12c331a 100644 --- a/tests/target/configs-chain_one_line_max-above.rs +++ b/tests/target/configs-chain_one_line_max-above.rs @@ -1,4 +1,4 @@ -// rustfmt-chain_one_line_max: 10 +// rustfmt-chain_width: 10 // Chain one line max fn main() { diff --git a/tests/target/configs-chain_one_line_max-below.rs b/tests/target/configs-chain_one_line_max-below.rs index e869c782d07..d877deb74eb 100644 --- a/tests/target/configs-chain_one_line_max-below.rs +++ b/tests/target/configs-chain_one_line_max-below.rs @@ -1,4 +1,4 @@ -// rustfmt-chain_one_line_max: 100 +// rustfmt-chain_width: 100 // Chain one line max fn main() { From 619bc91081b00737df88aef3d59005d2ce2ee4b5 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Sat, 4 Nov 2017 22:30:26 +0900 Subject: [PATCH 2/2] Change test files' name --- ...s-chain_one_line_max-above.rs => configs-chain_width-above.rs} | 0 ...s-chain_one_line_max-below.rs => configs-chain_width-below.rs} | 0 ...s-chain_one_line_max-above.rs => configs-chain_width-above.rs} | 0 ...s-chain_one_line_max-below.rs => configs-chain_width-below.rs} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename tests/source/{configs-chain_one_line_max-above.rs => configs-chain_width-above.rs} (100%) rename tests/source/{configs-chain_one_line_max-below.rs => configs-chain_width-below.rs} (100%) rename tests/target/{configs-chain_one_line_max-above.rs => configs-chain_width-above.rs} (100%) rename tests/target/{configs-chain_one_line_max-below.rs => configs-chain_width-below.rs} (100%) diff --git a/tests/source/configs-chain_one_line_max-above.rs b/tests/source/configs-chain_width-above.rs similarity index 100% rename from tests/source/configs-chain_one_line_max-above.rs rename to tests/source/configs-chain_width-above.rs diff --git a/tests/source/configs-chain_one_line_max-below.rs b/tests/source/configs-chain_width-below.rs similarity index 100% rename from tests/source/configs-chain_one_line_max-below.rs rename to tests/source/configs-chain_width-below.rs diff --git a/tests/target/configs-chain_one_line_max-above.rs b/tests/target/configs-chain_width-above.rs similarity index 100% rename from tests/target/configs-chain_one_line_max-above.rs rename to tests/target/configs-chain_width-above.rs diff --git a/tests/target/configs-chain_one_line_max-below.rs b/tests/target/configs-chain_width-below.rs similarity index 100% rename from tests/target/configs-chain_one_line_max-below.rs rename to tests/target/configs-chain_width-below.rs