diff --git a/src/chains.rs b/src/chains.rs index f3cd2ab8f013..f0a3f56822da 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -19,10 +19,11 @@ /// we put each subexpression on a separate, much like the (default) function /// argument function argument strategy. /// -/// Depends on config options: `chain_base_indent` is the indent to use for -/// blocks in the parent/root/base of the chain. +/// Depends on config options: `chain_indent` is the indent to use for +/// blocks in the parent/root/base of the chain (and the rest of the chain's +/// alignment). /// E.g., `let foo = { aaaa; bbb; ccc }.bar.baz();`, we would layout for the -/// following values of `chain_base_indent`: +/// following values of `chain_indent`: /// Visual: /// ``` /// let foo = { @@ -54,7 +55,6 @@ /// .baz(); /// ``` /// -/// `chain_indent` dictates how the rest of the chain is aligned. /// If the first item in the chain is a block expression, we align the dots with /// the braces. /// Visual: @@ -75,11 +75,6 @@ /// .baz() /// .qux /// ``` -/// `chains_overflow_last` applies only to chains where the last item is a -/// method call. Usually, any line break in a chain sub-expression causes the -/// whole chain to be split with newlines at each `.`. With `chains_overflow_last` -/// true, then we allow the last method call to spill over multiple lines without -/// forcing the rest of the chain to be split. use {Indent, Shape}; use rewrite::{Rewrite, RewriteContext}; @@ -106,7 +101,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) - // Parent is the first item in the chain, e.g., `foo` in `foo.bar.baz()`. let mut parent_shape = shape; if is_block_expr(&parent, "\n") { - parent_shape = chain_base_indent(context, shape); + parent_shape = chain_indent(context, shape); } let parent_rewrite = try_opt!(parent.rewrite(context, parent_shape)); @@ -164,7 +159,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) - if fits_single_line { fits_single_line = match expr.node { - ref e @ ast::ExprKind::MethodCall(..) if context.config.chains_overflow_last => { + ref e @ ast::ExprKind::MethodCall(..) => { rewrite_method_call_with_overflow(e, &mut last[0], almost_total, @@ -272,14 +267,6 @@ fn make_subexpr_list(expr: &ast::Expr, context: &RewriteContext) -> (ast::Expr, (parent, subexpr_list) } -fn chain_base_indent(context: &RewriteContext, shape: Shape) -> Shape { - match context.config.chain_base_indent { - BlockIndentStyle::Visual => shape, - BlockIndentStyle::Inherit => shape.block_indent(0), - BlockIndentStyle::Tabbed => shape.block_indent(context.config.tab_spaces), - } -} - fn chain_indent(context: &RewriteContext, shape: Shape) -> Shape { match context.config.chain_indent { BlockIndentStyle::Visual => shape, diff --git a/src/config.rs b/src/config.rs index 508b569232be..b34082fca3e0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -379,9 +379,7 @@ create_config! { "Report all, none or unnumbered occurrences of TODO in source file comments"; report_fixme: ReportTactic, ReportTactic::Never, "Report all, none or unnumbered occurrences of FIXME in source file comments"; - chain_base_indent: BlockIndentStyle, BlockIndentStyle::Tabbed, "Indent on chain base"; chain_indent: BlockIndentStyle, BlockIndentStyle::Tabbed, "Indentation of chain"; - chains_overflow_last: bool, true, "Allow last call in method chain to break the line"; reorder_imports: bool, false, "Reorder import statements alphabetically"; reorder_imported_names: bool, false, "Reorder lists of names in import statements alphabetically"; diff --git a/src/expr.rs b/src/expr.rs index 8f6ccbd095ee..f893f9cd12c7 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1558,7 +1558,7 @@ fn rewrite_call_inner(context: &RewriteContext, Some(&ast::ExprKind::Closure(..)) | Some(&ast::ExprKind::Block(..)) if arg_count > 1 => true, _ => false, - } && context.config.chains_overflow_last; + }; let mut orig_last = None; let mut placeholder = None;