Skip to content

Commit ea2c61b

Browse files
committed
added missing PatKind::Path + tests
1 parent 306326d commit ea2c61b

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

clippy_lints/src/let_if_seq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl LateLintPass for LetIfSeq {
6565
let Some(expr) = it.peek(),
6666
let hir::StmtDecl(ref decl, _) = stmt.node,
6767
let hir::DeclLocal(ref decl) = decl.node,
68-
let hir::PatKind::Ident(mode, ref name, None) = decl.pat.node,
68+
let hir::PatKind::Binding(mode, ref name, None) = decl.pat.node,
6969
let Some(def) = cx.tcx.def_map.borrow().get(&decl.pat.id),
7070
let hir::StmtExpr(ref if_, _) = expr.node,
7171
let hir::ExprIf(ref cond, ref then, ref else_) = if_.node,

clippy_lints/src/matches.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ fn check_single_match_opt_like(cx: &LateContext, ex: &Expr, arms: &[Arm], expr:
201201
path.to_string()
202202
}
203203
PatKind::Binding(BindByValue(MutImmutable), ident, None) => ident.node.to_string(),
204+
PatKind::Path(ref path) => path.to_string(),
204205
_ => return,
205206
};
206207

clippy_lints/src/utils/hir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
148148
(&PatKind::Binding(ref lb, ref li, ref lp), &PatKind::Binding(ref rb, ref ri, ref rp)) => {
149149
lb == rb && li.node.as_str() == ri.node.as_str() && both(lp, rp, |l, r| self.eq_pat(l, r))
150150
}
151+
(&PatKind::Path(ref l), &PatKind::Path(ref r)) => self.eq_path(l, r),
151152
(&PatKind::Lit(ref l), &PatKind::Lit(ref r)) => self.eq_expr(l, r),
152153
(&PatKind::QPath(ref ls, ref lp), &PatKind::QPath(ref rs, ref rp)) => {
153154
self.eq_qself(ls, rs) && self.eq_path(lp, rp)

tests/compile-fail/matches.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ fn overlapping() {
216216
11 ... 50 => println!("0 ... 10"),
217217
_ => (),
218218
}
219+
220+
if let None = Some(42) {
221+
// nothing
222+
} else if let None = Some(42) {
223+
// another nothing :-)
224+
}
219225
}
220226

221227
fn main() {

0 commit comments

Comments
 (0)