apply rustfmt

This commit is contained in:
Oliver Schneider
2017-01-17 19:30:32 +01:00
parent 7b836dd27c
commit 713da45906
21 changed files with 101 additions and 129 deletions

View File

@@ -445,12 +445,10 @@ fn trim_multiline_inner(s: Cow<str>, ignore_first: bool, ch: char) -> Cow<str> {
if x > 0 {
Cow::Owned(s.lines()
.enumerate()
.map(|(i, l)| {
if (ignore_first && i == 0) || l.is_empty() {
l
} else {
l.split_at(x).1
}
.map(|(i, l)| if (ignore_first && i == 0) || l.is_empty() {
l
} else {
l.split_at(x).1
})
.collect::<Vec<_>>()
.join("\n"))
@@ -467,12 +465,10 @@ pub fn get_parent_expr<'c>(cx: &'c LateContext, e: &Expr) -> Option<&'c Expr> {
if node_id == parent_id {
return None;
}
map.find(parent_id).and_then(|node| {
if let Node::NodeExpr(parent) = node {
Some(parent)
} else {
None
}
map.find(parent_id).and_then(|node| if let Node::NodeExpr(parent) = node {
Some(parent)
} else {
None
})
}

View File

@@ -258,8 +258,9 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg, rhs: &Sugg) -> Sugg<'static> {
fn needs_paren(op: &AssocOp, other: &AssocOp, dir: Associativity) -> bool {
other.precedence() < op.precedence() ||
(other.precedence() == op.precedence() &&
((op != other && associativity(op) != dir) || (op == other && associativity(op) != Associativity::Both))) ||
is_shift(op) && is_arith(other) || is_shift(other) && is_arith(op)
((op != other && associativity(op) != dir) ||
(op == other && associativity(op) != Associativity::Both))) || is_shift(op) && is_arith(other) ||
is_shift(other) && is_arith(op)
}
let lhs_paren = if let Sugg::BinOp(ref lop, _) = *lhs {
@@ -433,13 +434,11 @@ impl<'a, 'b, 'c, T: LintContext<'c>> DiagnosticBuilderExt<'c, T> for rustc_error
let mut first = true;
let new_item = new_item.lines()
.map(|l| {
if first {
first = false;
format!("{}\n", l)
} else {
format!("{}{}\n", indent, l)
}
.map(|l| if first {
first = false;
format!("{}\n", l)
} else {
format!("{}{}\n", indent, l)
})
.collect::<String>();