From ce7b0aacd0d70145d9583e41c1ef65154d790823 Mon Sep 17 00:00:00 2001
From: Nick Cameron <ncameron@mozilla.com>
Date: Mon, 20 Mar 2017 11:07:33 +1300
Subject: [PATCH] Remove BlockIndentStyle::Inherit

---
 src/chains.rs                         | 15 +-------------
 src/config.rs                         |  2 --
 src/items.rs                          | 10 +--------
 tests/source/chains-indent-inherit.rs |  5 -----
 tests/source/fn-custom-2.rs           |  4 ++--
 tests/source/fn-custom-3.rs           |  2 +-
 tests/source/fn-custom-5.rs           |  6 ------
 tests/source/fn-custom-6.rs           |  2 +-
 tests/source/fn-custom-8.rs           |  2 +-
 tests/target/chains-indent-inherit.rs | 10 ---------
 tests/target/fn-custom-2.rs           | 30 +++++++++++++--------------
 tests/target/fn-custom-3.rs           | 22 ++++++++++----------
 tests/target/fn-custom-5.rs           | 11 ----------
 tests/target/fn-custom-6.rs           |  6 +++---
 tests/target/fn-custom-8.rs           | 12 +++++------
 15 files changed, 42 insertions(+), 97 deletions(-)
 delete mode 100644 tests/source/chains-indent-inherit.rs
 delete mode 100644 tests/source/fn-custom-5.rs
 delete mode 100644 tests/target/chains-indent-inherit.rs
 delete mode 100644 tests/target/fn-custom-5.rs

diff --git a/src/chains.rs b/src/chains.rs
index 4918ebd3cac..32505138e65 100644
--- a/src/chains.rs
+++ b/src/chains.rs
@@ -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,
diff --git a/src/config.rs b/src/config.rs
index 4206392d7a7..ff9b7cd4d96 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -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.
diff --git a/src/items.rs b/src/items.rs
index d20b2f77598..445959f63b0 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -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,
diff --git a/tests/source/chains-indent-inherit.rs b/tests/source/chains-indent-inherit.rs
deleted file mode 100644
index 67272a656c6..00000000000
--- a/tests/source/chains-indent-inherit.rs
+++ /dev/null
@@ -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();
-}
diff --git a/tests/source/fn-custom-2.rs b/tests/source/fn-custom-2.rs
index a45f5501ea7..ddd11949580 100644
--- a/tests/source/fn-custom-2.rs
+++ b/tests/source/fn-custom-2.rs
@@ -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.
 
diff --git a/tests/source/fn-custom-3.rs b/tests/source/fn-custom-3.rs
index e63b642d19c..b5df5edddae 100644
--- a/tests/source/fn-custom-3.rs
+++ b/tests/source/fn-custom-3.rs
@@ -1,5 +1,5 @@
 // rustfmt-fn_arg_indent: Tabbed
-// rustfmt-generics_indent: Inherit
+// rustfmt-generics_indent: Tabbed
 // rustfmt-where_layout: HorizontalVertical
 // Test different indents.
 
diff --git a/tests/source/fn-custom-5.rs b/tests/source/fn-custom-5.rs
deleted file mode 100644
index 98f11a72eab..00000000000
--- a/tests/source/fn-custom-5.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-// rustfmt-where_pred_indent: Inherit
-// Test different indents.
-
-fn qux() where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT {
-    baz();
-}
diff --git a/tests/source/fn-custom-6.rs b/tests/source/fn-custom-6.rs
index 1f2d740a075..5f464d93045 100644
--- a/tests/source/fn-custom-6.rs
+++ b/tests/source/fn-custom-6.rs
@@ -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.
 
diff --git a/tests/source/fn-custom-8.rs b/tests/source/fn-custom-8.rs
index a1aebf1f38c..26ab6a89443 100644
--- a/tests/source/fn-custom-8.rs
+++ b/tests/source/fn-custom-8.rs
@@ -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.
 
diff --git a/tests/target/chains-indent-inherit.rs b/tests/target/chains-indent-inherit.rs
deleted file mode 100644
index 76d3ef8204b..00000000000
--- a/tests/target/chains-indent-inherit.rs
+++ /dev/null
@@ -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();
-}
diff --git a/tests/target/fn-custom-2.rs b/tests/target/fn-custom-2.rs
index ff67084b202..71aecfeab4e 100644
--- a/tests/target/fn-custom-2.rs
+++ b/tests/target/fn-custom-2.rs
@@ -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();
     }
diff --git a/tests/target/fn-custom-3.rs b/tests/target/fn-custom-3.rs
index f8de7f4a343..96e82ac91f8 100644
--- a/tests/target/fn-custom-3.rs
+++ b/tests/target/fn-custom-3.rs
@@ -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,
 }
diff --git a/tests/target/fn-custom-5.rs b/tests/target/fn-custom-5.rs
deleted file mode 100644
index 08c717538f2..00000000000
--- a/tests/target/fn-custom-5.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// rustfmt-where_pred_indent: Inherit
-// Test different indents.
-
-fn qux()
-    where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
-    X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
-    X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
-    X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT
-{
-    baz();
-}
diff --git a/tests/target/fn-custom-6.rs b/tests/target/fn-custom-6.rs
index 2da0d5c28d6..8cd8d20f360 100644
--- a/tests/target/fn-custom-6.rs
+++ b/tests/target/fn-custom-6.rs
@@ -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();
 }
 
diff --git a/tests/target/fn-custom-8.rs b/tests/target/fn-custom-8.rs
index 7ed0f801140..0c1c2aaf8f3 100644
--- a/tests/target/fn-custom-8.rs
+++ b/tests/target/fn-custom-8.rs
@@ -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 {
     }
 }