]> git.lizzy.rs Git - rust.git/commitdiff
Use max width for function decls, etc.
authorNick Cameron <ncameron@mozilla.com>
Sun, 27 Sep 2015 06:30:32 +0000 (19:30 +1300)
committerNick Cameron <ncameron@mozilla.com>
Sun, 27 Sep 2015 06:34:35 +0000 (19:34 +1300)
We were using ideal width + leeway before. This means we can remove leeway from the config. We could remove ideal_width too, but I want to use it for comments.

src/config.rs
src/items.rs
tests/config/small_tabs.toml

index 020761744820ec9a977bb5aa6fd81710a0ca916c..b21fe3d2a076c90f2236e5658715a60335b467e0 100644 (file)
@@ -216,7 +216,6 @@ pub fn get_docs() -> Vec<ConfigHelpItem> {
 create_config! {
     max_width: usize, "Maximum width of each line",
     ideal_width: usize, "Ideal width of each line (only used for comments)",
-    leeway: usize, "Leeway of line width (deprecated)",
     tab_spaces: usize, "Number of spaces per tab",
     fn_call_width: usize, "Maximum width of the args of a function call\
                            before faling back to vertical formatting",
@@ -258,7 +257,6 @@ fn default() -> Config {
         Config {
             max_width: 100,
             ideal_width: 80,
-            leeway: 5,
             tab_spaces: 4,
             fn_call_width: 50,
             struct_lit_width: 12,
index 3cf12b68a82d93254a9dd59e9370d571b1b0969b..13e06d0b438c0309fccb0c5562f55bd5e3c9c307 100644 (file)
@@ -528,7 +528,7 @@ fn compute_budgets_for_args(&self,
 
             // 2 = `()`
             let used_space = indent.width() + result.len() + 2;
-            let max_space = self.config.ideal_width + self.config.leeway;
+            let max_space = self.config.max_width;
             debug!("compute_budgets_for_args: used_space: {}, max_space: {}",
                    used_space,
                    max_space);
@@ -542,7 +542,7 @@ fn compute_budgets_for_args(&self,
         // Didn't work. we must force vertical layout and put args on a newline.
         let new_indent = indent.block_indent(self.config);
         let used_space = new_indent.width() + 2; // account for `(` and `)`
-        let max_space = self.config.ideal_width + self.config.leeway;
+        let max_space = self.config.max_width;
         if used_space <= max_space {
             (0, max_space - used_space, new_indent)
         } else {
@@ -637,7 +637,7 @@ fn visit_variant(&mut self, field: &ast::Variant, last_field: bool, next_span_st
                     } else {
                         0
                     };
-                    let budget = self.config.ideal_width - indent.width() - comma_cost - 1; // 1 = )
+                    let budget = self.config.max_width - indent.width() - comma_cost - 1; // 1 = )
 
                     let fmt = ListFormatting {
                         tactic: ListTactic::HorizontalVertical,
@@ -774,7 +774,7 @@ fn format_struct(&self,
         };
 
         // 1 = ,
-        let budget = self.config.ideal_width - offset.width() + self.config.tab_spaces - 1;
+        let budget = self.config.max_width - offset.width() + self.config.tab_spaces - 1;
         let fmt = ListFormatting {
             tactic: tactic,
             separator: ",",
@@ -979,7 +979,7 @@ fn rewrite_where_clause(&self,
         // FIXME: if where_pred_indent != Visual, then the budgets below might
         // be out by a char or two.
 
-        let budget = self.config.ideal_width + self.config.leeway - offset.width();
+        let budget = self.config.max_width - offset.width();
         let span_start = span_for_where_pred(&where_clause.predicates[0]).lo;
         let items = itemize_list(self.codemap,
                                  where_clause.predicates.iter(),
index 754cde57cd9c91e41ccec0f334b7b6a884505c6c..1681aff77b4b42233207210df27f35fbcce84dd5 100644 (file)
@@ -1,6 +1,5 @@
 max_width = 100
 ideal_width = 80
-leeway = 5
 tab_spaces = 2
 newline_style = "Unix"
 fn_brace_style = "SameLineWhere"