Use max width for function decls, etc.

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.
This commit is contained in:
Nick Cameron 2015-09-27 19:30:32 +13:00
parent 224eecce50
commit bc59f83f02
3 changed files with 5 additions and 8 deletions

View File

@ -216,7 +216,6 @@ macro_rules! create_config {
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 @@ impl Default for Config {
Config {
max_width: 100,
ideal_width: 80,
leeway: 5,
tab_spaces: 4,
fn_call_width: 50,
struct_lit_width: 12,

View File

@ -528,7 +528,7 @@ impl<'a> FmtVisitor<'a> {
// 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 @@ impl<'a> FmtVisitor<'a> {
// 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 @@ impl<'a> FmtVisitor<'a> {
} 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 @@ impl<'a> FmtVisitor<'a> {
};
// 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 @@ impl<'a> FmtVisitor<'a> {
// 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(),

View File

@ -1,6 +1,5 @@
max_width = 100
ideal_width = 80
leeway = 5
tab_spaces = 2
newline_style = "Unix"
fn_brace_style = "SameLineWhere"