Merge pull request #868 from rust-lang-nursery/tuple-wide

Don't apply the function args heuristic to tuple lits.
This commit is contained in:
Marcus Klaas de Vries 2016-03-24 14:57:24 +01:00
commit 8fd95df54a
10 changed files with 46 additions and 81 deletions

View file

@ -236,8 +236,7 @@ fn rewrite_method_call(method_name: ast::Ident,
.map(|ty| ty.rewrite(context, width, offset))
.collect());
(types.last().unwrap().span.hi,
format!("::<{}>", type_list.join(", ")))
(types.last().unwrap().span.hi, format!("::<{}>", type_list.join(", ")))
};
let callee_str = format!(".{}{}", method_name, type_str);

View file

@ -501,9 +501,7 @@ impl<'a> Iterator for CommentCodeSlices<'a> {
CodeCharKind::Comment => CodeCharKind::Normal,
CodeCharKind::Normal => CodeCharKind::Comment,
};
let res = (kind,
self.last_slice_end,
&self.slice[self.last_slice_end..sub_slice_end]);
let res = (kind, self.last_slice_end, &self.slice[self.last_slice_end..sub_slice_end]);
self.last_slice_end = sub_slice_end;
self.last_slice_kind = kind;

View file

@ -18,7 +18,7 @@ use std::fmt::Write;
use {Indent, Spanned};
use rewrite::{Rewrite, RewriteContext};
use lists::{write_list, itemize_list, ListFormatting, SeparatorTactic, ListTactic,
DefinitiveListTactic, definitive_tactic, ListItem, format_fn_args};
DefinitiveListTactic, definitive_tactic, ListItem, format_item_list};
use string::{StringFormat, rewrite_string};
use utils::{CodeMapSpanUtils, extra_offset, last_line_width, wrap_str, binary_search,
first_line_width, semicolon_for_stmt};
@ -1336,9 +1336,7 @@ fn rewrite_call_inner<R>(context: &RewriteContext,
// Replace the stub with the full overflowing last argument if the rewrite
// succeeded and its first line fits with the other arguments.
match (overflow_last, tactic, placeholder) {
(true,
DefinitiveListTactic::Horizontal,
placeholder @ Some(..)) => {
(true, DefinitiveListTactic::Horizontal, placeholder @ Some(..)) => {
item_vec[arg_count - 1].item = placeholder;
}
(true, _, _) => {
@ -1511,8 +1509,7 @@ fn rewrite_struct_lit<'a>(context: &RewriteContext,
outer_indent))
};
match (context.config.struct_lit_style,
context.config.struct_lit_multiline_style) {
match (context.config.struct_lit_style, context.config.struct_lit_multiline_style) {
(StructLitStyle::Block, _) if fields_str.contains('\n') || fields_str.len() > h_budget => {
format_on_newline()
}
@ -1583,7 +1580,7 @@ pub fn rewrite_tuple<'a, I>(context: &RewriteContext,
list_lo,
span.hi - BytePos(1));
let budget = try_opt!(width.checked_sub(2));
let list_str = try_opt!(format_fn_args(items, budget, indent, context.config));
let list_str = try_opt!(format_item_list(items, budget, indent, context.config));
Some(format!("({})", list_str))
}

View file

@ -1581,9 +1581,7 @@ fn compute_budgets_for_args(context: &RewriteContext,
let multi_line_budget = context.config.max_width -
(indent.width() + result.len() + "()".len());
return (one_line_budget,
multi_line_budget,
indent + result.len() + 1);
return (one_line_budget, multi_line_budget, indent + result.len() + 1);
}
}