diff --git a/CHANGELOG.md b/CHANGELOG.md index b59249b257cf..7a21dbea2c23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Change Log All notable changes to this project will be documented in this file. -## 0.0.71 — TBD +## 0.0.71 — 2016-05-31 +* Rustup to *rustc 1.10.0-nightly (7bddce693 2016-05-27)* * New lint: [`useless_let_if_seq`] ## 0.0.70 — 2016-05-28 diff --git a/Cargo.toml b/Cargo.toml index 828857701d5a..ec38ce916231 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.70" +version = "0.0.71" authors = [ "Manish Goregaokar ", "Andre Bogus ", @@ -30,7 +30,7 @@ toml = "0.1" unicode-normalization = "0.1" quine-mc_cluskey = "0.2.2" # begin automatic update -clippy_lints = { version = "0.0.70", path = "clippy_lints" } +clippy_lints = { version = "0.0.71", path = "clippy_lints" } # end automatic update rustc-serialize = "0.3" diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index c309b7a63e24..db6ee1245058 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "clippy_lints" # begin automatic update -version = "0.0.70" +version = "0.0.71" # end automatic update authors = [ "Manish Goregaokar ", diff --git a/clippy_lints/src/blacklisted_name.rs b/clippy_lints/src/blacklisted_name.rs index 5cb84f62651b..a2dbdf34a2ff 100644 --- a/clippy_lints/src/blacklisted_name.rs +++ b/clippy_lints/src/blacklisted_name.rs @@ -34,7 +34,7 @@ impl LintPass for BlackListedName { impl LateLintPass for BlackListedName { fn check_pat(&mut self, cx: &LateContext, pat: &Pat) { - if let PatKind::Ident(_, ref ident, _) = pat.node { + if let PatKind::Binding(_, ref ident, _) = pat.node { if self.blacklist.iter().any(|s| s == &*ident.node.as_str()) { span_lint(cx, BLACKLISTED_NAME, diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 96956d1793b6..b4c8521a0a9f 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -345,8 +345,8 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { (BiDiv, Constant::Int(l), Some(Constant::Int(r))) => (l / r).ok().map(Constant::Int), (BiRem, Constant::Int(l), Some(Constant::Int(r))) => (l % r).ok().map(Constant::Int), (BiAnd, Constant::Bool(false), _) => Some(Constant::Bool(false)), - (BiAnd, Constant::Bool(true), Some(r)) => Some(r), (BiOr, Constant::Bool(true), _) => Some(Constant::Bool(true)), + (BiAnd, Constant::Bool(true), Some(r)) | (BiOr, Constant::Bool(false), Some(r)) => Some(r), (BiBitXor, Constant::Bool(l), Some(Constant::Bool(r))) => Some(Constant::Bool(l ^ r)), (BiBitXor, Constant::Int(l), Some(Constant::Int(r))) => (l ^ r).ok().map(Constant::Int), diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 3873e82b69ae..3022ffe730fc 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -192,7 +192,7 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap { + PatKind::Binding(_, ref ident, ref as_pat) => { if let Entry::Vacant(v) = map.entry(ident.node.as_str()) { v.insert(cx.tcx.pat_ty(pat)); } diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index f73b6cfed2d7..99b40a0231b5 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -70,7 +70,7 @@ fn check_closure(cx: &LateContext, expr: &Expr) { _ => (), } for (ref a1, ref a2) in decl.inputs.iter().zip(args) { - if let PatKind::Ident(_, ident, _) = a1.pat.node { + if let PatKind::Binding(_, ident, _) = a1.pat.node { // XXXManishearth Should I be checking the binding mode here? if let ExprPath(None, ref p) = a2.node { if p.segments.len() != 1 { diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 29551a413e2a..1eb2f756cbf9 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -65,7 +65,7 @@ impl LateLintPass for LetIfSeq { let Some(expr) = it.peek(), let hir::StmtDecl(ref decl, _) = stmt.node, let hir::DeclLocal(ref decl) = decl.node, - let hir::PatKind::Ident(mode, ref name, None) = decl.pat.node, + let hir::PatKind::Binding(mode, ref name, None) = decl.pat.node, let Some(def) = cx.tcx.def_map.borrow().get(&decl.pat.id), let hir::StmtExpr(ref if_, _) = expr.node, let hir::ExprIf(ref cond, ref then, ref else_) = if_.node, diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index c7f34d338b1d..3d3c9ab47a41 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -330,7 +330,7 @@ fn check_for_loop(cx: &LateContext, pat: &Pat, arg: &Expr, body: &Expr, expr: &E fn check_for_loop_range(cx: &LateContext, pat: &Pat, arg: &Expr, body: &Expr, expr: &Expr) { if let Some(UnsugaredRange { start: Some(ref start), ref end, .. }) = unsugar_range(arg) { // the var must be a single name - if let PatKind::Ident(_, ref ident, _) = pat.node { + if let PatKind::Binding(_, ref ident, _) = pat.node { let mut visitor = VarVisitor { cx: cx, var: ident.node, @@ -613,7 +613,7 @@ fn check_for_loop_over_map_kv(cx: &LateContext, pat: &Pat, arg: &Expr, body: &Ex fn pat_is_wild(pat: &PatKind, body: &Expr) -> bool { match *pat { PatKind::Wild => true, - PatKind::Ident(_, ident, None) if ident.node.as_str().starts_with('_') => { + PatKind::Binding(_, ident, None) if ident.node.as_str().starts_with('_') => { let mut visitor = UsedVisitor { var: ident.node, used: false, @@ -884,7 +884,7 @@ impl<'v, 't> Visitor<'v> for InitializeVisitor<'v, 't> { // Look for declarations of the variable if let DeclLocal(ref local) = decl.node { if local.pat.id == self.var_id { - if let PatKind::Ident(_, ref ident, _) = local.pat.node { + if let PatKind::Binding(_, ref ident, _) = local.pat.node { self.name = Some(ident.node); self.state = if let Some(ref init) = local.init { diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index 4ad232759cfa..bd81cb2316b7 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -108,7 +108,7 @@ fn get_type_name(cx: &LateContext, expr: &Expr, arg: &Expr) -> Option<&'static s fn get_arg_name(pat: &Pat) -> Option { match pat.node { - PatKind::Ident(_, name, None) => Some(name.node), + PatKind::Binding(_, name, None) => Some(name.node), PatKind::Ref(ref subpat, _) => get_arg_name(subpat), _ => None, } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index ad3b958f5855..46bd251016b6 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -200,7 +200,8 @@ fn check_single_match_opt_like(cx: &LateContext, ex: &Expr, arms: &[Arm], expr: } path.to_string() } - PatKind::Ident(BindByValue(MutImmutable), ident, None) => ident.node.to_string(), + PatKind::Binding(BindByValue(MutImmutable), ident, None) => ident.node.to_string(), + PatKind::Path(ref path) => path.to_string(), _ => return, }; diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 3ab7823e50d2..5f113cf47cea 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -45,7 +45,7 @@ impl LateLintPass for TopLevelRefPass { return; } for ref arg in &decl.inputs { - if let PatKind::Ident(BindByRef(_), _, _) = arg.pat.node { + if let PatKind::Binding(BindByRef(_), _, _) = arg.pat.node { span_lint(cx, TOPLEVEL_REF_ARG, arg.pat.span, @@ -58,7 +58,7 @@ impl LateLintPass for TopLevelRefPass { [ let StmtDecl(ref d, _) = s.node, let DeclLocal(ref l) = d.node, - let PatKind::Ident(BindByRef(_), i, None) = l.pat.node, + let PatKind::Binding(BindByRef(_), i, None) = l.pat.node, let Some(ref init) = l.init ], { let tyopt = if let Some(ref ty) = l.ty { @@ -346,7 +346,7 @@ impl LintPass for PatternPass { impl LateLintPass for PatternPass { fn check_pat(&mut self, cx: &LateContext, pat: &Pat) { - if let PatKind::Ident(_, ref ident, Some(ref right)) = pat.node { + if let PatKind::Binding(_, ref ident, Some(ref right)) = pat.node { if right.node == PatKind::Wild { span_lint(cx, REDUNDANT_PATTERN, diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index bdaef590de51..0954d92cf9a5 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -65,7 +65,7 @@ impl LateLintPass for ShadowPass { fn check_fn(cx: &LateContext, decl: &FnDecl, block: &Block) { let mut bindings = Vec::new(); for arg in &decl.inputs { - if let PatKind::Ident(_, ident, _) = arg.pat.node { + if let PatKind::Binding(_, ident, _) = arg.pat.node { bindings.push((ident.node.unhygienize(), ident.span)) } } @@ -119,7 +119,7 @@ fn is_binding(cx: &LateContext, pat: &Pat) -> bool { fn check_pat(cx: &LateContext, pat: &Pat, init: &Option<&Expr>, span: Span, bindings: &mut Vec<(Name, Span)>) { // TODO: match more stuff / destructuring match pat.node { - PatKind::Ident(_, ref ident, ref inner) => { + PatKind::Binding(_, ref ident, ref inner) => { let name = ident.node.unhygienize(); if is_binding(cx, pat) { let mut new_binding = true; diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index c5572181395a..6dc9dda37ec4 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -63,7 +63,7 @@ fn check_manual_swap(cx: &LateContext, block: &Block) { let StmtDecl(ref tmp, _) = w[0].node, let DeclLocal(ref tmp) = tmp.node, let Some(ref tmp_init) = tmp.init, - let PatKind::Ident(_, ref tmp_name, None) = tmp.pat.node, + let PatKind::Binding(_, ref tmp_name, None) = tmp.pat.node, // foo() = bar(); let StmtSemi(ref first, _) = w[1].node, diff --git a/clippy_lints/src/utils/hir.rs b/clippy_lints/src/utils/hir.rs index 92b14b65168e..e9c4023e2260 100644 --- a/clippy_lints/src/utils/hir.rs +++ b/clippy_lints/src/utils/hir.rs @@ -145,9 +145,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { (&PatKind::TupleStruct(ref lp, ref la, ls), &PatKind::TupleStruct(ref rp, ref ra, rs)) => { self.eq_path(lp, rp) && over(la, ra, |l, r| self.eq_pat(l, r)) && ls == rs } - (&PatKind::Ident(ref lb, ref li, ref lp), &PatKind::Ident(ref rb, ref ri, ref rp)) => { + (&PatKind::Binding(ref lb, ref li, ref lp), &PatKind::Binding(ref rb, ref ri, ref rp)) => { lb == rb && li.node.as_str() == ri.node.as_str() && both(lp, rp, |l, r| self.eq_pat(l, r)) } + (&PatKind::Path(ref l), &PatKind::Path(ref r)) => self.eq_path(l, r), (&PatKind::Lit(ref l), &PatKind::Lit(ref r)) => self.eq_expr(l, r), (&PatKind::QPath(ref ls, ref lp), &PatKind::QPath(ref rs, ref rp)) => { self.eq_qself(ls, rs) && self.eq_path(lp, rp) diff --git a/tests/compile-fail/copies.rs b/tests/compile-fail/copies.rs index 6f3076f7775b..f4e74eed4a41 100644 --- a/tests/compile-fail/copies.rs +++ b/tests/compile-fail/copies.rs @@ -173,6 +173,11 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = match Some(42) { Some(_) => 24, + None => 24, //~ERROR this `match` has identical arm bodies + }; + + let _ = match Some(42) { + Some(foo) => 24, None => 24, }; diff --git a/tests/compile-fail/matches.rs b/tests/compile-fail/matches.rs index 3444e49ec513..affa7e4e86e6 100644 --- a/tests/compile-fail/matches.rs +++ b/tests/compile-fail/matches.rs @@ -216,6 +216,12 @@ fn overlapping() { 11 ... 50 => println!("0 ... 10"), _ => (), } + + if let None = Some(42) { + // nothing + } else if let None = Some(42) { + // another nothing :-) + } } fn main() {