Skip to content

Commit 5f0f64c

Browse files
committed
Merge pull request #970 from Manishearth/rustup
s/PatKind::Ident/PatKind::Binding/g
2 parents 762aff2 + 5c51a24 commit 5f0f64c

17 files changed

+35
-21
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4-
## 0.0.71 — TBD
4+
## 0.0.71 — 2016-05-31
5+
* Rustup to *rustc 1.10.0-nightly (7bddce693 2016-05-27)*
56
* New lint: [`useless_let_if_seq`]
67

78
## 0.0.70 — 2016-05-28

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.70"
3+
version = "0.0.71"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",
@@ -30,7 +30,7 @@ toml = "0.1"
3030
unicode-normalization = "0.1"
3131
quine-mc_cluskey = "0.2.2"
3232
# begin automatic update
33-
clippy_lints = { version = "0.0.70", path = "clippy_lints" }
33+
clippy_lints = { version = "0.0.71", path = "clippy_lints" }
3434
# end automatic update
3535
rustc-serialize = "0.3"
3636

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_lints"
33
# begin automatic update
4-
version = "0.0.70"
4+
version = "0.0.71"
55
# end automatic update
66
authors = [
77
"Manish Goregaokar <[email protected]>",

clippy_lints/src/blacklisted_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl LintPass for BlackListedName {
3434

3535
impl LateLintPass for BlackListedName {
3636
fn check_pat(&mut self, cx: &LateContext, pat: &Pat) {
37-
if let PatKind::Ident(_, ref ident, _) = pat.node {
37+
if let PatKind::Binding(_, ref ident, _) = pat.node {
3838
if self.blacklist.iter().any(|s| s == &*ident.node.as_str()) {
3939
span_lint(cx,
4040
BLACKLISTED_NAME,

clippy_lints/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
345345
(BiDiv, Constant::Int(l), Some(Constant::Int(r))) => (l / r).ok().map(Constant::Int),
346346
(BiRem, Constant::Int(l), Some(Constant::Int(r))) => (l % r).ok().map(Constant::Int),
347347
(BiAnd, Constant::Bool(false), _) => Some(Constant::Bool(false)),
348-
(BiAnd, Constant::Bool(true), Some(r)) => Some(r),
349348
(BiOr, Constant::Bool(true), _) => Some(Constant::Bool(true)),
349+
(BiAnd, Constant::Bool(true), Some(r)) |
350350
(BiOr, Constant::Bool(false), Some(r)) => Some(r),
351351
(BiBitXor, Constant::Bool(l), Some(Constant::Bool(r))) => Some(Constant::Bool(l ^ r)),
352352
(BiBitXor, Constant::Int(l), Some(Constant::Int(r))) => (l ^ r).ok().map(Constant::Int),

clippy_lints/src/copies.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<Interned
192192
bindings_impl(cx, pat, map);
193193
}
194194
}
195-
PatKind::Ident(_, ref ident, ref as_pat) => {
195+
PatKind::Binding(_, ref ident, ref as_pat) => {
196196
if let Entry::Vacant(v) = map.entry(ident.node.as_str()) {
197197
v.insert(cx.tcx.pat_ty(pat));
198198
}

clippy_lints/src/eta_reduction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
7070
_ => (),
7171
}
7272
for (ref a1, ref a2) in decl.inputs.iter().zip(args) {
73-
if let PatKind::Ident(_, ident, _) = a1.pat.node {
73+
if let PatKind::Binding(_, ident, _) = a1.pat.node {
7474
// XXXManishearth Should I be checking the binding mode here?
7575
if let ExprPath(None, ref p) = a2.node {
7676
if p.segments.len() != 1 {

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/loops.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn check_for_loop(cx: &LateContext, pat: &Pat, arg: &Expr, body: &Expr, expr: &E
330330
fn check_for_loop_range(cx: &LateContext, pat: &Pat, arg: &Expr, body: &Expr, expr: &Expr) {
331331
if let Some(UnsugaredRange { start: Some(ref start), ref end, .. }) = unsugar_range(arg) {
332332
// the var must be a single name
333-
if let PatKind::Ident(_, ref ident, _) = pat.node {
333+
if let PatKind::Binding(_, ref ident, _) = pat.node {
334334
let mut visitor = VarVisitor {
335335
cx: cx,
336336
var: ident.node,
@@ -613,7 +613,7 @@ fn check_for_loop_over_map_kv(cx: &LateContext, pat: &Pat, arg: &Expr, body: &Ex
613613
fn pat_is_wild(pat: &PatKind, body: &Expr) -> bool {
614614
match *pat {
615615
PatKind::Wild => true,
616-
PatKind::Ident(_, ident, None) if ident.node.as_str().starts_with('_') => {
616+
PatKind::Binding(_, ident, None) if ident.node.as_str().starts_with('_') => {
617617
let mut visitor = UsedVisitor {
618618
var: ident.node,
619619
used: false,
@@ -884,7 +884,7 @@ impl<'v, 't> Visitor<'v> for InitializeVisitor<'v, 't> {
884884
// Look for declarations of the variable
885885
if let DeclLocal(ref local) = decl.node {
886886
if local.pat.id == self.var_id {
887-
if let PatKind::Ident(_, ref ident, _) = local.pat.node {
887+
if let PatKind::Binding(_, ref ident, _) = local.pat.node {
888888
self.name = Some(ident.node);
889889

890890
self.state = if let Some(ref init) = local.init {

clippy_lints/src/map_clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn get_type_name(cx: &LateContext, expr: &Expr, arg: &Expr) -> Option<&'static s
108108

109109
fn get_arg_name(pat: &Pat) -> Option<ast::Name> {
110110
match pat.node {
111-
PatKind::Ident(_, name, None) => Some(name.node),
111+
PatKind::Binding(_, name, None) => Some(name.node),
112112
PatKind::Ref(ref subpat, _) => get_arg_name(subpat),
113113
_ => None,
114114
}

clippy_lints/src/matches.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ fn check_single_match_opt_like(cx: &LateContext, ex: &Expr, arms: &[Arm], expr:
200200
}
201201
path.to_string()
202202
}
203-
PatKind::Ident(BindByValue(MutImmutable), ident, None) => ident.node.to_string(),
203+
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/misc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl LateLintPass for TopLevelRefPass {
4545
return;
4646
}
4747
for ref arg in &decl.inputs {
48-
if let PatKind::Ident(BindByRef(_), _, _) = arg.pat.node {
48+
if let PatKind::Binding(BindByRef(_), _, _) = arg.pat.node {
4949
span_lint(cx,
5050
TOPLEVEL_REF_ARG,
5151
arg.pat.span,
@@ -58,7 +58,7 @@ impl LateLintPass for TopLevelRefPass {
5858
[
5959
let StmtDecl(ref d, _) = s.node,
6060
let DeclLocal(ref l) = d.node,
61-
let PatKind::Ident(BindByRef(_), i, None) = l.pat.node,
61+
let PatKind::Binding(BindByRef(_), i, None) = l.pat.node,
6262
let Some(ref init) = l.init
6363
], {
6464
let tyopt = if let Some(ref ty) = l.ty {
@@ -346,7 +346,7 @@ impl LintPass for PatternPass {
346346

347347
impl LateLintPass for PatternPass {
348348
fn check_pat(&mut self, cx: &LateContext, pat: &Pat) {
349-
if let PatKind::Ident(_, ref ident, Some(ref right)) = pat.node {
349+
if let PatKind::Binding(_, ref ident, Some(ref right)) = pat.node {
350350
if right.node == PatKind::Wild {
351351
span_lint(cx,
352352
REDUNDANT_PATTERN,

clippy_lints/src/shadow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl LateLintPass for ShadowPass {
6565
fn check_fn(cx: &LateContext, decl: &FnDecl, block: &Block) {
6666
let mut bindings = Vec::new();
6767
for arg in &decl.inputs {
68-
if let PatKind::Ident(_, ident, _) = arg.pat.node {
68+
if let PatKind::Binding(_, ident, _) = arg.pat.node {
6969
bindings.push((ident.node.unhygienize(), ident.span))
7070
}
7171
}
@@ -119,7 +119,7 @@ fn is_binding(cx: &LateContext, pat: &Pat) -> bool {
119119
fn check_pat(cx: &LateContext, pat: &Pat, init: &Option<&Expr>, span: Span, bindings: &mut Vec<(Name, Span)>) {
120120
// TODO: match more stuff / destructuring
121121
match pat.node {
122-
PatKind::Ident(_, ref ident, ref inner) => {
122+
PatKind::Binding(_, ref ident, ref inner) => {
123123
let name = ident.node.unhygienize();
124124
if is_binding(cx, pat) {
125125
let mut new_binding = true;

clippy_lints/src/swap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn check_manual_swap(cx: &LateContext, block: &Block) {
6363
let StmtDecl(ref tmp, _) = w[0].node,
6464
let DeclLocal(ref tmp) = tmp.node,
6565
let Some(ref tmp_init) = tmp.init,
66-
let PatKind::Ident(_, ref tmp_name, None) = tmp.pat.node,
66+
let PatKind::Binding(_, ref tmp_name, None) = tmp.pat.node,
6767

6868
// foo() = bar();
6969
let StmtSemi(ref first, _) = w[1].node,

clippy_lints/src/utils/hir.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
145145
(&PatKind::TupleStruct(ref lp, ref la, ls), &PatKind::TupleStruct(ref rp, ref ra, rs)) => {
146146
self.eq_path(lp, rp) && over(la, ra, |l, r| self.eq_pat(l, r)) && ls == rs
147147
}
148-
(&PatKind::Ident(ref lb, ref li, ref lp), &PatKind::Ident(ref rb, ref ri, ref rp)) => {
148+
(&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/copies.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ fn if_same_then_else() -> Result<&'static str, ()> {
173173

174174
let _ = match Some(42) {
175175
Some(_) => 24,
176+
None => 24, //~ERROR this `match` has identical arm bodies
177+
};
178+
179+
let _ = match Some(42) {
180+
Some(foo) => 24,
176181
None => 24,
177182
};
178183

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)