diff options
| author | Nick Cameron <nrc@ncameron.org> | 2017-05-01 15:48:53 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-01 15:48:53 +1200 |
| commit | fba5af2a7d5efa2a324b52fd80648a04d6fabb3d (patch) | |
| tree | 2501011a3d42eb6a1c1341ef9438cf8cf97a7f95 /src/expr.rs | |
| parent | a8fbfdb4a3f3c0917e2d6a2dade42ec3f1580ca2 (diff) | |
| parent | 02cf515be63600c1a2f59ba4ce77695e1ef60ceb (diff) | |
Merge pull request #1469 from topecongiro/bug/chains
Remove a bug when calculating the length of the chain
Diffstat (limited to 'src/expr.rs')
| -rw-r--r-- | src/expr.rs | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/expr.rs b/src/expr.rs index 7b4153083cb..fa12ad8b170 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -600,9 +600,7 @@ fn and_one_line(x: Option<String>) -> Option<String> { fn nop_block_collapse(block_str: Option<String>, budget: usize) -> Option<String> { debug!("nop_block_collapse {:?} {}", block_str, budget); block_str.map(|block_str| if block_str.starts_with('{') && budget >= 2 && - (block_str[1..] - .find(|c: char| !c.is_whitespace()) - .unwrap() == + (block_str[1..].find(|c: char| !c.is_whitespace()).unwrap() == block_str.len() - 2) { "{}".to_owned() } else { @@ -933,16 +931,12 @@ impl<'a> Rewrite for ControlFlow<'a> { // for event in event let between_kwd_cond = - mk_sp(context - .codemap - .span_after(self.span, self.keyword.trim()), + mk_sp(context.codemap.span_after(self.span, self.keyword.trim()), self.pat .map_or(cond_span.lo, |p| if self.matcher.is_empty() { p.span.lo } else { - context - .codemap - .span_before(self.span, self.matcher.trim()) + context.codemap.span_before(self.span, self.matcher.trim()) })); let between_kwd_cond_comment = extract_comment(between_kwd_cond, context, shape); @@ -1137,10 +1131,7 @@ fn rewrite_match_arm_comment(context: &RewriteContext, let first = missed_str .find(|c: char| !c.is_whitespace()) .unwrap_or(missed_str.len()); - if missed_str[..first] - .chars() - .filter(|c| c == &'\n') - .count() >= 2 { + if missed_str[..first].chars().filter(|c| c == &'\n').count() >= 2 { // Excessive vertical whitespace before comment should be preserved // FIXME handle vertical whitespace better result.push('\n'); |
