about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2018-06-19 13:26:36 +1200
committerNick Cameron <ncameron@mozilla.com>2018-06-19 13:28:27 +1200
commit261238ea51bd564460027d5fddbd93fcd189a5cd (patch)
tree49410d837d0e5ac1d4bbf31ef41dfacf7e0e71f7 /src
parenta1c5c46986eb03836ad3463fca4623695db091de (diff)
Change `use_small_heuristics` to an enum and stabilise
Since it is now an enum, we can be future compatible since we can add variants
for different heuristics.

Closes #1974
Diffstat (limited to 'src')
-rw-r--r--src/config/config_type.rs2
-rw-r--r--src/config/mod.rs6
-rw-r--r--src/config/options.rs7
3 files changed, 11 insertions, 4 deletions
diff --git a/src/config/config_type.rs b/src/config/config_type.rs
index f12d1864728..57a02fb531b 100644
--- a/src/config/config_type.rs
+++ b/src/config/config_type.rs
@@ -399,7 +399,7 @@ macro_rules! create_config {
             }
 
             fn set_heuristics(&mut self) {
-                if self.use_small_heuristics.2 {
+                if self.use_small_heuristics.2 == Heuristics::Default {
                     let max_width = self.max_width.2;
                     self.set().width_heuristics(WidthHeuristics::scaled(max_width));
                 } else {
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 31da2820167..71bdefeea79 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -41,8 +41,8 @@ create_config! {
     hard_tabs: bool, false, true, "Use tab characters for indentation, spaces for alignment";
     tab_spaces: usize, 4, true, "Number of spaces per tab";
     newline_style: NewlineStyle, NewlineStyle::Unix, true, "Unix or Windows line endings";
-    use_small_heuristics: bool, true, false, "Whether to use different formatting for items and \
-        expressions if they satisfy a heuristic notion of 'small'.";
+    use_small_heuristics: Heuristics, Heuristics::Default, true, "Whether to use different \
+        formatting for items and expressions if they satisfy a heuristic notion of 'small'.";
     indent_style: IndentStyle, IndentStyle::Block, false, "How do we indent expressions or items.";
 
     // Comments and strings
@@ -236,7 +236,7 @@ mod test {
         create_config! {
             // Options that are used by the generated functions
             max_width: usize, 100, true, "Maximum width of each line";
-            use_small_heuristics: bool, true, false,
+            use_small_heuristics: Heuristics, Heuristics::Default, true,
                 "Whether to use different formatting for items and \
                  expressions if they satisfy a heuristic notion of 'small'.";
             license_template_path: String, String::default(), false,
diff --git a/src/config/options.rs b/src/config/options.rs
index 8f16e57d468..5f781507d90 100644
--- a/src/config/options.rs
+++ b/src/config/options.rs
@@ -151,6 +151,13 @@ configuration_option_enum! { TypeDensity:
     Wide,
 }
 
+configuration_option_enum! { Heuristics:
+    // Turn off any heuristics
+    Off,
+    // Use Rustfmt's defaults
+    Default,
+}
+
 impl Density {
     pub fn to_list_tactic(self) -> ListTactic {
         match self {