Fix trailing commas in where clauses
This commit is contained in:
parent
40be79304e
commit
decafbbaea
5 changed files with 53 additions and 8 deletions
|
|
@ -88,9 +88,6 @@ impl<'a> FmtVisitor<'a> {
|
|||
result.len() + indent + ret_str.len() > MAX_WIDTH {
|
||||
let indent = match FN_RETURN_INDENT {
|
||||
ReturnIndent::WithWhereClause => indent + 4,
|
||||
ReturnIndent::WithWhereClauseOrArgs if where_clause.predicates.len() > 0 => {
|
||||
indent + 4
|
||||
}
|
||||
// TODO 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.
|
||||
|
|
@ -254,7 +251,8 @@ impl<'a> FmtVisitor<'a> {
|
|||
// The fix is comments in the AST or a span for the closing paren.
|
||||
let snippet = self.snippet(codemap::mk_sp(prev_end, next_span_start));
|
||||
let snippet = snippet.trim();
|
||||
let snippet = &snippet[..snippet.find(terminator).unwrap_or(snippet.len())];
|
||||
let snippet = &snippet[..snippet.find(terminator)
|
||||
.unwrap_or(snippet.find(separator).unwrap_or(snippet.len()))];
|
||||
let snippet = snippet.trim();
|
||||
result.push(snippet.to_string());
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ const MAX_WIDTH: usize = 100;
|
|||
const MIN_STRING: usize = 10;
|
||||
const TAB_SPACES: usize = 4;
|
||||
const FN_BRACE_STYLE: BraceStyle = BraceStyle::SameLineWhere;
|
||||
const FN_RETURN_INDENT: ReturnIndent = ReturnIndent::WithWhereClauseOrArgs;
|
||||
const FN_RETURN_INDENT: ReturnIndent = ReturnIndent::WithArgs;
|
||||
// When we get scoped annotations, we should have rustfmt::skip.
|
||||
const SKIP_ANNOTATION: &'static str = "rustfmt_skip";
|
||||
|
||||
|
|
@ -99,8 +99,6 @@ enum ReturnIndent {
|
|||
WithArgs,
|
||||
// Aligned with the where clause
|
||||
WithWhereClause,
|
||||
// Aligned with the where clause if there is one, otherwise the args.
|
||||
WithWhereClauseOrArgs,
|
||||
}
|
||||
|
||||
// Formatting which depends on the AST.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue