Merge pull request #970 from Manishearth/rustup

s/PatKind::Ident/PatKind::Binding/g
This commit is contained in:
Martin Carton 2016-05-31 23:54:02 +02:00
commit 5f0f64c82d
17 changed files with 35 additions and 21 deletions

View File

@ -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

View File

@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.70"
version = "0.0.71"
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",
"Andre Bogus <bogusandre@gmail.com>",
@ -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"

View File

@ -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 <manishsmail@gmail.com>",

View File

@ -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,

View File

@ -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),

View File

@ -192,7 +192,7 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<Interned
bindings_impl(cx, pat, map);
}
}
PatKind::Ident(_, ref ident, ref as_pat) => {
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));
}

View File

@ -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 {

View File

@ -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,

View File

@ -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 {

View File

@ -108,7 +108,7 @@ fn get_type_name(cx: &LateContext, expr: &Expr, arg: &Expr) -> Option<&'static s
fn get_arg_name(pat: &Pat) -> Option<ast::Name> {
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,
}

View File

@ -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,
};

View File

@ -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,

View File

@ -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;

View File

@ -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,

View File

@ -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)

View File

@ -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,
};

View File

@ -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() {