diff --git a/src/len_zero.rs b/src/len_zero.rs index ea0c873cb..125a7c0ae 100644 --- a/src/len_zero.rs +++ b/src/len_zero.rs @@ -140,9 +140,7 @@ fn check_cmp(cx: &LateContext, span: Span, left: &Expr, right: &Expr, op: &str) } } match (&left.node, &right.node) { - (&ExprLit(ref lit), &ExprMethodCall(ref method, _, ref args)) => { - check_len_zero(cx, span, &method.node, args, lit, op) - } + (&ExprLit(ref lit), &ExprMethodCall(ref method, _, ref args)) | (&ExprMethodCall(ref method, _, ref args), &ExprLit(ref lit)) => { check_len_zero(cx, span, &method.node, args, lit, op) } diff --git a/src/methods.rs b/src/methods.rs index 40d975545..9263d6573 100644 --- a/src/methods.rs +++ b/src/methods.rs @@ -865,12 +865,11 @@ enum SelfKind { impl SelfKind { fn matches(&self, slf: &ExplicitSelf_, allow_value_for_ref: bool) -> bool { match (self, slf) { - (&SelfKind::Value, &SelfValue(_)) => true, - (&SelfKind::Ref, &SelfRegion(_, Mutability::MutImmutable, _)) => true, - (&SelfKind::RefMut, &SelfRegion(_, Mutability::MutMutable, _)) => true, - (&SelfKind::Ref, &SelfValue(_)) => allow_value_for_ref, - (&SelfKind::RefMut, &SelfValue(_)) => allow_value_for_ref, - (&SelfKind::No, &SelfStatic) => true, + (&SelfKind::Value, &SelfValue(_)) | + (&SelfKind::Ref, &SelfRegion(_, Mutability::MutImmutable, _)) | + (&SelfKind::RefMut, &SelfRegion(_, Mutability::MutMutable, _)) | + (&SelfKind::No, &SelfStatic) => true, + (&SelfKind::Ref, &SelfValue(_)) | (&SelfKind::RefMut, &SelfValue(_)) => allow_value_for_ref, (_, &SelfExplicit(ref ty, _)) => self.matches_explicit_type(ty, allow_value_for_ref), _ => false, } @@ -878,11 +877,11 @@ impl SelfKind { fn matches_explicit_type(&self, ty: &Ty, allow_value_for_ref: bool) -> bool { match (self, &ty.node) { - (&SelfKind::Value, &TyPath(..)) => true, - (&SelfKind::Ref, &TyRptr(_, MutTy { mutbl: Mutability::MutImmutable, .. })) => true, - (&SelfKind::RefMut, &TyRptr(_, MutTy { mutbl: Mutability::MutMutable, .. })) => true, - (&SelfKind::Ref, &TyPath(..)) => allow_value_for_ref, - (&SelfKind::RefMut, &TyPath(..)) => allow_value_for_ref, + (&SelfKind::Value, &TyPath(..)) | + (&SelfKind::Ref, &TyRptr(_, MutTy { mutbl: Mutability::MutImmutable, .. })) | + (&SelfKind::RefMut, &TyRptr(_, MutTy { mutbl: Mutability::MutMutable, .. })) => true, + (&SelfKind::Ref, &TyPath(..)) | + (&SelfKind::RefMut, &TyPath(..)) => allow_value_for_ref, _ => false, } } diff --git a/src/misc.rs b/src/misc.rs index f570c18b7..076e6e385 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -421,8 +421,7 @@ impl LateLintPass for UsedUnderscoreBinding { fn is_used(cx: &LateContext, expr: &Expr) -> bool { if let Some(ref parent) = get_parent_expr(cx, expr) { match parent.node { - ExprAssign(_, ref rhs) => **rhs == *expr, - ExprAssignOp(_, _, ref rhs) => **rhs == *expr, + ExprAssign(_, ref rhs) | ExprAssignOp(_, _, ref rhs) => **rhs == *expr, _ => is_used(cx, &parent), } } else { diff --git a/src/utils/hir.rs b/src/utils/hir.rs index 1ccb411b7..f8695956f 100644 --- a/src/utils/hir.rs +++ b/src/utils/hir.rs @@ -38,8 +38,8 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { false } } - (&StmtExpr(ref l, _), &StmtExpr(ref r, _)) => self.eq_expr(l, r), - (&StmtSemi(ref l, _), &StmtSemi(ref r, _)) => self.eq_expr(l, r), + (&StmtExpr(ref l, _), &StmtExpr(ref r, _)) | + (&StmtSemi(ref l, _), &StmtSemi(ref r, _)) => self.eq_expr(l, r), _ => false, } } diff --git a/tests/compile-fail/cyclomatic_complexity.rs b/tests/compile-fail/cyclomatic_complexity.rs index 5bdca7f36..3a4a83af5 100644 --- a/tests/compile-fail/cyclomatic_complexity.rs +++ b/tests/compile-fail/cyclomatic_complexity.rs @@ -138,15 +138,15 @@ fn bloo() { #[cyclomatic_complexity = "0"] fn baa() { //~ ERROR: the function has a cyclomatic complexity of 2 let x = || match 99 { - 0 => true, - 1 => false, - 2 => true, - 4 => true, - 6 => true, - 9 => true, - _ => false, + 0 => 0, + 1 => 1, + 2 => 2, + 4 => 4, + 6 => 6, + 9 => 9, + _ => 42, }; - if x() { + if x() == 42 { println!("x"); } else { println!("not x"); diff --git a/tests/compile-fail/matches.rs b/tests/compile-fail/matches.rs index 71cc7c59f..46d3ff8d5 100644 --- a/tests/compile-fail/matches.rs +++ b/tests/compile-fail/matches.rs @@ -101,8 +101,8 @@ fn match_bool() { let test: bool = true; match test { //~ ERROR you seem to be trying to match on a boolean expression - true => (), - false => (), + true => 0, + false => 42, }; let option = 1; @@ -128,9 +128,9 @@ fn match_bool() { // Not linted match option { - 1 ... 10 => (), - 11 ... 20 => (), - _ => (), + 1 ... 10 => 1, + 11 ... 20 => 2, + _ => 3, }; }