};
let eq = |lhs: &Arm, rhs: &Arm| -> bool {
- SpanlessEq::new(cx).eq_expr(&lhs.body, &rhs.body) &&
+ // Arms with a guard are ignored, those can’t always be merged together
+ lhs.guard.is_none() && rhs.guard.is_none() &&
+ SpanlessEq::new(cx).eq_expr(&lhs.body, &rhs.body) &&
// all patterns should have the same bindings
bindings(cx, &lhs.pats[0]) == bindings(cx, &rhs.pats[0])
};
if let ExprMatch(_, ref arms, MatchSource::Normal) = expr.node {
- if let Some((i, j)) = search_same(&**arms, hash, eq) {
+ if let Some((i, j)) = search_same(&arms, hash, eq) {
span_note_and_lint(cx,
MATCH_SAME_ARMS,
j.body.span,
_ => true,
};
+ let _ = match Some(42) {
+ Some(_) => 24,
+ None => 24,
+ };
+
let _ = match Some(42) {
Some(42) => 24,
Some(a) => 24, // bindings are different
None => 0,
};
+ let _ = match Some(42) {
+ Some(a) if a > 0 => 24,
+ Some(a) => 24, // one arm has a guard
+ None => 0,
+ };
+
match (Some(42), Some(42)) {
(Some(a), None) => bar(a),
(None, Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies