Remove BlockIndentStyle::Inherit

This commit is contained in:
Nick Cameron 2017-03-20 11:07:33 +13:00
parent 13a6644074
commit ce7b0aacd0
15 changed files with 42 additions and 97 deletions

View File

@ -123,7 +123,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
parent_shape.block_indent(context.config.tab_spaces)),
false)
} else {
(chain_indent_newline(context, shape.add_offset(parent_rewrite.len())), false)
(shape.block_indent(context.config.tab_spaces), false)
};
let max_width = try_opt!((shape.width + shape.indent.width() + shape.offset)
@ -135,7 +135,6 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
let mut shape = try_opt!(parent_shape.shrink_left(last_line_width(&parent_rewrite)));
match context.config.chain_indent {
BlockIndentStyle::Visual => other_child_shape,
BlockIndentStyle::Inherit => shape,
BlockIndentStyle::Tabbed => {
shape.offset = shape.offset.checked_sub(context.config.tab_spaces).unwrap_or(0);
shape.indent.block_indent += context.config.tab_spaces;
@ -296,22 +295,10 @@ fn make_subexpr_list(expr: &ast::Expr, context: &RewriteContext) -> (ast::Expr,
fn chain_indent(context: &RewriteContext, shape: Shape) -> Shape {
match context.config.chain_indent {
BlockIndentStyle::Visual => shape.visual_indent(0),
BlockIndentStyle::Inherit => shape.block_indent(0),
BlockIndentStyle::Tabbed => shape.block_indent(context.config.tab_spaces),
}
}
// Ignores visual indenting because this function should be called where it is
// not possible to use visual indentation because we are starting on a newline.
fn chain_indent_newline(context: &RewriteContext, shape: Shape) -> Shape {
match context.config.chain_indent {
BlockIndentStyle::Inherit => shape.block_indent(0),
BlockIndentStyle::Visual | BlockIndentStyle::Tabbed => {
shape.block_indent(context.config.tab_spaces)
}
}
}
fn rewrite_method_call_with_overflow(expr_kind: &ast::ExprKind,
last: &mut String,
almost_total: usize,

View File

@ -83,8 +83,6 @@ configuration_option_enum! { FnArgLayoutStyle:
}
configuration_option_enum! { BlockIndentStyle:
// Same level as parent.
Inherit,
// One level deeper than parent.
Tabbed,
// Aligned with block open.

View File

@ -1806,7 +1806,6 @@ fn rewrite_args(context: &RewriteContext,
}
let indent = match context.config.fn_arg_indent {
BlockIndentStyle::Inherit => indent,
BlockIndentStyle::Tabbed => indent.block_indent(context.config),
BlockIndentStyle::Visual => arg_indent,
};
@ -1915,7 +1914,6 @@ fn rewrite_generics(context: &RewriteContext,
}
let offset = match context.config.generics_indent {
BlockIndentStyle::Inherit => shape.indent,
BlockIndentStyle::Tabbed => shape.indent.block_indent(context.config),
// 1 = <
BlockIndentStyle::Visual => generics_offset + 1,
@ -2078,15 +2076,9 @@ fn rewrite_where_clause(context: &RewriteContext,
span_end);
}
let extra_indent = match context.config.where_indent {
BlockIndentStyle::Inherit => Indent::empty(),
BlockIndentStyle::Tabbed | BlockIndentStyle::Visual => {
Indent::new(context.config.tab_spaces, 0)
}
};
let extra_indent = Indent::new(context.config.tab_spaces, 0);
let offset = match context.config.where_pred_indent {
BlockIndentStyle::Inherit => shape.indent + extra_indent,
BlockIndentStyle::Tabbed => shape.indent + extra_indent.block_indent(context.config),
// 6 = "where ".len()
BlockIndentStyle::Visual => shape.indent + extra_indent + 6,

View File

@ -1,5 +0,0 @@
// rustfmt-chain_indent: Inherit
fn test() {
let x = my_long_function().my_even_longer_function().my_nested_function().some_random_name().another_function().do_it();
}

View File

@ -1,6 +1,6 @@
// rustfmt-fn_arg_indent: Inherit
// rustfmt-fn_arg_indent: Tabbed
// rustfmt-generics_indent: Tabbed
// rustfmt-where_indent: Inherit
// rustfmt-where_indent: Tabbed
// rustfmt-where_layout: Mixed
// Test different indents.

View File

@ -1,5 +1,5 @@
// rustfmt-fn_arg_indent: Tabbed
// rustfmt-generics_indent: Inherit
// rustfmt-generics_indent: Tabbed
// rustfmt-where_layout: HorizontalVertical
// Test different indents.

View File

@ -1,6 +0,0 @@
// rustfmt-where_pred_indent: Inherit
// Test different indents.
fn qux() where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT {
baz();
}

View File

@ -1,5 +1,5 @@
// rustfmt-fn_args_layout: BlockAlways
// rustfmt-where_indent: Inherit
// rustfmt-where_indent: Tabbed
// rustfmt-fn_brace_style: PreferSameLine
// Test different indents.

View File

@ -1,5 +1,5 @@
// rustfmt-fn_args_layout: Block
// rustfmt-where_indent: Inherit
// rustfmt-where_indent: Tabbed
// rustfmt-fn_brace_style: PreferSameLine
// Test different indents.

View File

@ -1,10 +0,0 @@
// rustfmt-chain_indent: Inherit
fn test() {
let x = my_long_function()
.my_even_longer_function()
.my_nested_function()
.some_random_name()
.another_function()
.do_it();
}

View File

@ -1,14 +1,14 @@
// rustfmt-fn_arg_indent: Inherit
// rustfmt-fn_arg_indent: Tabbed
// rustfmt-generics_indent: Tabbed
// rustfmt-where_indent: Inherit
// rustfmt-where_indent: Tabbed
// rustfmt-where_layout: Mixed
// Test different indents.
fn foo(a: Aaaaaaaaaaaaaaa,
b: Bbbbbbbbbbbbbbbb,
c: Ccccccccccccccccc,
d: Ddddddddddddddddddddddddd,
e: Eeeeeeeeeeeeeeeeeee) {
b: Bbbbbbbbbbbbbbbb,
c: Ccccccccccccccccc,
d: Ddddddddddddddddddddddddd,
e: Eeeeeeeeeeeeeeeeeee) {
foo();
}
@ -21,25 +21,25 @@ fn bar<
}
fn baz()
where X: TTTTTTTT
where X: TTTTTTTT
{
baz();
}
fn qux()
where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT
where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT
{
baz();
}
impl Foo {
fn foo(self,
a: Aaaaaaaaaaaaaaa,
b: Bbbbbbbbbbbbbbbb,
c: Ccccccccccccccccc,
d: Ddddddddddddddddddddddddd,
e: Eeeeeeeeeeeeeeeeeee) {
a: Aaaaaaaaaaaaaaa,
b: Bbbbbbbbbbbbbbbb,
c: Ccccccccccccccccc,
d: Ddddddddddddddddddddddddd,
e: Eeeeeeeeeeeeeeeeeee) {
foo();
}
@ -53,7 +53,7 @@ impl Foo {
}
fn baz()
where X: TTTTTTTT
where X: TTTTTTTT
{
baz();
}

View File

@ -1,5 +1,5 @@
// rustfmt-fn_arg_indent: Tabbed
// rustfmt-generics_indent: Inherit
// rustfmt-generics_indent: Tabbed
// rustfmt-where_layout: HorizontalVertical
// Test different indents.
@ -12,9 +12,9 @@ fn foo(a: Aaaaaaaaaaaaaaa,
}
fn bar<
'a: 'bbbbbbbbbbbbbbbbbbbbbbbbbbb,
TTTTTTTTTTTTT,
UUUUUUUUUUUUUUUUUUUU: WWWWWWWWWWWWWWWWWWWWWWWW
'a: 'bbbbbbbbbbbbbbbbbbbbbbbbbbb,
TTTTTTTTTTTTT,
UUUUUUUUUUUUUUUUUUUU: WWWWWWWWWWWWWWWWWWWWWWWW
>(a: Aaaaaaaaaaaaaaa) {
bar();
}
@ -45,9 +45,9 @@ impl Foo {
}
fn bar<
'a: 'bbbbbbbbbbbbbbbbbbbbbbbbbbb,
TTTTTTTTTTTTT,
UUUUUUUUUUUUUUUUUUUU: WWWWWWWWWWWWWWWWWWWWWWWW
'a: 'bbbbbbbbbbbbbbbbbbbbbbbbbbb,
TTTTTTTTTTTTT,
UUUUUUUUUUUUUUUUUUUU: WWWWWWWWWWWWWWWWWWWWWWWW
>
(a: Aaaaaaaaaaaaaaa) {
bar();
@ -55,10 +55,10 @@ impl Foo {
}
struct Foo<
TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
UUUUUUUUUUUUUUUUUUUUUU,
VVVVVVVVVVVVVVVVVVVVVVVVVVV,
WWWWWWWWWWWWWWWWWWWWWWWW
TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
UUUUUUUUUUUUUUUUUUUUUU,
VVVVVVVVVVVVVVVVVVVVVVVVVVV,
WWWWWWWWWWWWWWWWWWWWWWWW
> {
foo: Foo,
}

View File

@ -1,11 +0,0 @@
// rustfmt-where_pred_indent: Inherit
// Test different indents.
fn qux()
where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT
{
baz();
}

View File

@ -1,5 +1,5 @@
// rustfmt-fn_args_layout: BlockAlways
// rustfmt-where_indent: Inherit
// rustfmt-where_indent: Tabbed
// rustfmt-fn_brace_style: PreferSameLine
// Test different indents.
@ -54,7 +54,7 @@ fn bar(
fn foo(
a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb,
) -> String
where T: UUUUUUUUUUU {
where T: UUUUUUUUUUU {
foo();
}
@ -65,7 +65,7 @@ fn bar(
d: Dddddddddddddddd,
e: Eeeeeeeeeeeeeee,
) -> String
where T: UUUUUUUUUUU {
where T: UUUUUUUUUUU {
bar();
}

View File

@ -1,5 +1,5 @@
// rustfmt-fn_args_layout: Block
// rustfmt-where_indent: Inherit
// rustfmt-where_indent: Tabbed
// rustfmt-fn_brace_style: PreferSameLine
// Test different indents.
@ -32,7 +32,7 @@ fn bar(
}
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb)
where T: UUUUUUUUUUU {
where T: UUUUUUUUUUU {
foo();
}
@ -47,7 +47,7 @@ fn bar(
}
fn foo(a: Aaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbb) -> String
where T: UUUUUUUUUUU {
where T: UUUUUUUUUUU {
foo();
}
@ -58,7 +58,7 @@ fn bar(
d: Dddddddddddddddd,
e: Eeeeeeeeeeeeeee,
) -> String
where T: UUUUUUUUUUU {
where T: UUUUUUUUUUU {
bar();
}
@ -68,7 +68,7 @@ trait Test {
fn bar(a: u8) -> String {}
fn bar(a: u8) -> String
where Foo: foooo,
Bar: barrr {
where Foo: foooo,
Bar: barrr {
}
}