From 4f65124422eb49e4474b8752c25614bf6ab5d013 Mon Sep 17 00:00:00 2001
From: Nick Cameron <ncameron@mozilla.com>
Date: Fri, 24 Nov 2017 13:19:36 +1300
Subject: [PATCH] Remove legacy option `fn_return_indent`

---
 Configurations.md                             | 42 -------------------
 src/config.rs                                 | 10 -----
 src/items.rs                                  | 14 +++----
 tests/config/small_tabs.toml                  |  1 -
 .../configs-fn_return_indent-with_args.rs     |  6 ---
 ...figs-fn_return_indent-with_where_clause.rs |  6 ---
 .../configs-fn_return_indent-with_args.rs     | 16 -------
 ...figs-fn_return_indent-with_where_clause.rs | 16 -------
 8 files changed, 6 insertions(+), 105 deletions(-)
 delete mode 100644 tests/source/configs-fn_return_indent-with_args.rs
 delete mode 100644 tests/source/configs-fn_return_indent-with_where_clause.rs
 delete mode 100644 tests/target/configs-fn_return_indent-with_args.rs
 delete mode 100644 tests/target/configs-fn_return_indent-with_where_clause.rs

diff --git a/Configurations.md b/Configurations.md
index 219b7ced0c4..d71a07e53b6 100644
--- a/Configurations.md
+++ b/Configurations.md
@@ -991,48 +991,6 @@ fn lorem() {
 
 See also [`control_brace_style`](#control_brace_style).
 
-## `fn_return_indent`
-
-Location of return type in function declaration
-
-- **Default value**: `"WithArgs"`
-- **Possible values**: `"WithArgs"`, `"WithWhereClause"`
-
-#### `"WithArgs"` (default):
-
-```rust
-fn lorem(ipsum: Ipsum,
-         dolor: Dolor,
-         sit: Sit,
-         amet: Amet,
-         consectetur: Consectetur,
-         adipiscing: Adipiscing)
-         -> Elit
-    where Ipsum: Eq
-{
-    // body
-}
-
-```
-
-#### `"WithWhereClause"`:
-
-```rust
-fn lorem(ipsum: Ipsum,
-         dolor: Dolor,
-         sit: Sit,
-         amet: Amet,
-         consectetur: Consectetur,
-         adipiscing: Adipiscing)
-    -> Elit
-    where Ipsum: Eq
-{
-    // body
-}
-
-```
-
-**Note**: This option only takes effect when `indent_style` is set to `"Visual"`.
 
 ## `fn_single_line`
 
diff --git a/src/config.rs b/src/config.rs
index 51819028cbd..1c3ecee904d 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -63,14 +63,6 @@ configuration_option_enum! { ControlBraceStyle:
     AlwaysNextLine,
 }
 
-// How to indent a function's return type.
-configuration_option_enum! { ReturnIndent:
-    // Aligned with the arguments
-    WithArgs,
-    // Aligned with the where clause
-    WithWhereClause,
-}
-
 configuration_option_enum! { IndentStyle:
     // First line on the same line as the opening brace, all lines aligned with
     // the first line.
@@ -557,8 +549,6 @@ create_config! {
         "Add trailing semicolon after break, continue and return";
     fn_empty_single_line: bool, true, false, "Put empty-body functions on a single line";
     fn_single_line: bool, false, false, "Put single-expression functions on a single line";
-    fn_return_indent: ReturnIndent, ReturnIndent::WithArgs, false,
-        "Location of return type in function declaration";
     fn_args_paren_newline: bool, false, false, "If function argument parenthesis goes on a newline";
     fn_args_density: Density, Density::Tall, false, "Argument density in functions";
     array_width: usize, 60, false,
diff --git a/src/items.rs b/src/items.rs
index 3fe82f48ea5..3d0a31639e6 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -22,7 +22,7 @@ use spanned::Spanned;
 use codemap::{LineRangeUtils, SpanUtils};
 use comment::{combine_strs_with_missing_comments, contains_comment, recover_comment_removed,
               recover_missing_comment_in_span, rewrite_missing_comment, FindUncommented};
-use config::{BraceStyle, Config, Density, IndentStyle, ReturnIndent};
+use config::{BraceStyle, Config, Density, IndentStyle};
 use expr::{choose_rhs, format_expr, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs,
            rewrite_call_inner, ExprType};
 use lists::{definitive_tactic, itemize_list, write_list, DefinitiveListTactic, ListFormatting,
@@ -1979,17 +1979,15 @@ fn rewrite_fn_base(
             }
         };
         let ret_indent = if ret_should_indent {
-            let indent = match context.config.fn_return_indent() {
-                ReturnIndent::WithWhereClause => indent + 4,
+            let indent = if arg_str.is_empty() {
                 // Aligning with non-existent args looks silly.
-                _ if arg_str.is_empty() => {
-                    force_new_line_for_brace = true;
-                    indent + 4
-                }
+                force_new_line_for_brace = true;
+                indent + 4
+            } else {
                 // FIXME: we might want to check that using the arg indent
                 // doesn't blow our budget, and if it does, then fallback to
                 // the where clause indent.
-                _ => arg_indent,
+                arg_indent
             };
 
             result.push('\n');
diff --git a/tests/config/small_tabs.toml b/tests/config/small_tabs.toml
index 5b42f56ecdd..e377446c013 100644
--- a/tests/config/small_tabs.toml
+++ b/tests/config/small_tabs.toml
@@ -3,7 +3,6 @@ comment_width = 80
 tab_spaces = 2
 newline_style = "Unix"
 brace_style = "SameLineWhere"
-fn_return_indent = "WithArgs"
 fn_args_paren_newline = true
 fn_args_density = "Tall"
 where_density = "Tall"
diff --git a/tests/source/configs-fn_return_indent-with_args.rs b/tests/source/configs-fn_return_indent-with_args.rs
deleted file mode 100644
index 35d1459641a..00000000000
--- a/tests/source/configs-fn_return_indent-with_args.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-// rustfmt-fn_return_indent: WithArgs
-// Function return type indent
-
-fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur, adipiscing: Adipiscing) -> Elit where Ipsum: Eq {
-    // body
-}
diff --git a/tests/source/configs-fn_return_indent-with_where_clause.rs b/tests/source/configs-fn_return_indent-with_where_clause.rs
deleted file mode 100644
index 2fdbcd26572..00000000000
--- a/tests/source/configs-fn_return_indent-with_where_clause.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-// rustfmt-fn_return_indent: WithWhereClause
-// Function return type indent
-
-fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur, adipiscing: Adipiscing) -> Elit where Ipsum: Eq {
-    // body
-}
diff --git a/tests/target/configs-fn_return_indent-with_args.rs b/tests/target/configs-fn_return_indent-with_args.rs
deleted file mode 100644
index e1d49a65c25..00000000000
--- a/tests/target/configs-fn_return_indent-with_args.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// rustfmt-fn_return_indent: WithArgs
-// Function return type indent
-
-fn lorem(
-    ipsum: Ipsum,
-    dolor: Dolor,
-    sit: Sit,
-    amet: Amet,
-    consectetur: Consectetur,
-    adipiscing: Adipiscing,
-) -> Elit
-where
-    Ipsum: Eq,
-{
-    // body
-}
diff --git a/tests/target/configs-fn_return_indent-with_where_clause.rs b/tests/target/configs-fn_return_indent-with_where_clause.rs
deleted file mode 100644
index 62a35af516b..00000000000
--- a/tests/target/configs-fn_return_indent-with_where_clause.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// rustfmt-fn_return_indent: WithWhereClause
-// Function return type indent
-
-fn lorem(
-    ipsum: Ipsum,
-    dolor: Dolor,
-    sit: Sit,
-    amet: Amet,
-    consectetur: Consectetur,
-    adipiscing: Adipiscing,
-) -> Elit
-where
-    Ipsum: Eq,
-{
-    // body
-}