mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-26 14:40:32 +00:00
Rustup (fixes #2002)
This commit is contained in:
parent
c99b67c619
commit
9d6c0feef2
16 changed files with 40 additions and 19 deletions
|
@ -1,6 +1,9 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## 0.0.155
|
||||||
|
* Update to *rustc 1.21.0-nightly (c11f689d2 2017-08-29)*
|
||||||
|
* New lint: [`infinite_iter`], [`maybe_infinite_iter`], [`cast_lossless`]
|
||||||
|
|
||||||
## 0.0.154
|
## 0.0.154
|
||||||
* Update to *rustc 1.21.0-nightly (2c0558f63 2017-08-24)*
|
* Update to *rustc 1.21.0-nightly (2c0558f63 2017-08-24)*
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "clippy"
|
name = "clippy"
|
||||||
version = "0.0.154"
|
version = "0.0.155"
|
||||||
authors = [
|
authors = [
|
||||||
"Manish Goregaokar <manishsmail@gmail.com>",
|
"Manish Goregaokar <manishsmail@gmail.com>",
|
||||||
"Andre Bogus <bogusandre@gmail.com>",
|
"Andre Bogus <bogusandre@gmail.com>",
|
||||||
|
@ -31,7 +31,7 @@ path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# begin automatic update
|
# begin automatic update
|
||||||
clippy_lints = { version = "0.0.154", path = "clippy_lints" }
|
clippy_lints = { version = "0.0.155", path = "clippy_lints" }
|
||||||
# end automatic update
|
# end automatic update
|
||||||
cargo_metadata = "0.2"
|
cargo_metadata = "0.2"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "clippy_lints"
|
name = "clippy_lints"
|
||||||
# begin automatic update
|
# begin automatic update
|
||||||
version = "0.0.154"
|
version = "0.0.155"
|
||||||
# end automatic update
|
# end automatic update
|
||||||
authors = [
|
authors = [
|
||||||
"Manish Goregaokar <manishsmail@gmail.com>",
|
"Manish Goregaokar <manishsmail@gmail.com>",
|
||||||
|
|
|
@ -56,7 +56,7 @@ struct ExVisitor<'a, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
|
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
|
||||||
fn visit_expr(&mut self, expr: &'tcx Expr) {
|
fn visit_expr(&mut self, expr: &'tcx Expr) {
|
||||||
if let ExprClosure(_, _, eid, _) = expr.node {
|
if let ExprClosure(_, _, eid, _, _) = expr.node {
|
||||||
let body = self.cx.tcx.hir.body(eid);
|
let body = self.cx.tcx.hir.body(eid);
|
||||||
let ex = &body.value;
|
let ex = &body.value;
|
||||||
if matches!(ex.node, ExprBlock(_)) {
|
if matches!(ex.node, ExprBlock(_)) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
|
||||||
let ExprMethodCall(ref filter, _, ref filter_args) = count_args[0].node,
|
let ExprMethodCall(ref filter, _, ref filter_args) = count_args[0].node,
|
||||||
filter.name == "filter",
|
filter.name == "filter",
|
||||||
filter_args.len() == 2,
|
filter_args.len() == 2,
|
||||||
let ExprClosure(_, _, body_id, _) = filter_args[1].node,
|
let ExprClosure(_, _, body_id, _, _) = filter_args[1].node,
|
||||||
], {
|
], {
|
||||||
let body = cx.tcx.hir.body(body_id);
|
let body = cx.tcx.hir.body(body_id);
|
||||||
if_let_chain!([
|
if_let_chain!([
|
||||||
|
|
|
@ -171,7 +171,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> {
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExprClosure(..) => (),
|
ExprClosure(.., _) => (),
|
||||||
ExprBinary(op, _, _) => {
|
ExprBinary(op, _, _) => {
|
||||||
walk_expr(self, e);
|
walk_expr(self, e);
|
||||||
match op.node {
|
match op.node {
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaPass {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_closure(cx: &LateContext, expr: &Expr) {
|
fn check_closure(cx: &LateContext, expr: &Expr) {
|
||||||
if let ExprClosure(_, ref decl, eid, _) = expr.node {
|
if let ExprClosure(_, ref decl, eid, _, _) = expr.node {
|
||||||
let body = cx.tcx.hir.body(eid);
|
let body = cx.tcx.hir.body(eid);
|
||||||
let ex = &body.value;
|
let ex = &body.value;
|
||||||
if let ExprCall(ref caller, ref args) = ex.node {
|
if let ExprCall(ref caller, ref args) = ex.node {
|
||||||
|
|
|
@ -104,7 +104,7 @@ struct DivergenceVisitor<'a, 'tcx: 'a> {
|
||||||
impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
|
impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
|
||||||
fn maybe_walk_expr(&mut self, e: &'tcx Expr) {
|
fn maybe_walk_expr(&mut self, e: &'tcx Expr) {
|
||||||
match e.node {
|
match e.node {
|
||||||
ExprClosure(..) => {},
|
ExprClosure(.., _) => {},
|
||||||
ExprMatch(ref e, ref arms, _) => {
|
ExprMatch(ref e, ref arms, _) => {
|
||||||
self.visit_expr(e);
|
self.visit_expr(e);
|
||||||
for arm in arms {
|
for arm in arms {
|
||||||
|
@ -239,7 +239,7 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St
|
||||||
walk_expr(vis, expr);
|
walk_expr(vis, expr);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExprClosure(_, _, _, _) => {
|
ExprClosure(_, _, _, _, _) => {
|
||||||
// Either
|
// Either
|
||||||
//
|
//
|
||||||
// * `var` is defined in the closure body, in which case we've
|
// * `var` is defined in the closure body, in which case we've
|
||||||
|
@ -323,7 +323,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
|
||||||
// We're about to descend a closure. Since we don't know when (or
|
// We're about to descend a closure. Since we don't know when (or
|
||||||
// if) the closure will be evaluated, any reads in it might not
|
// if) the closure will be evaluated, any reads in it might not
|
||||||
// occur here (or ever). Like above, bail to avoid false positives.
|
// occur here (or ever). Like above, bail to avoid false positives.
|
||||||
ExprClosure(_, _, _, _) |
|
ExprClosure(_, _, _, _, _) |
|
||||||
|
|
||||||
// We want to avoid a false positive when a variable name occurs
|
// We want to avoid a false positive when a variable name occurs
|
||||||
// only to have its address taken, so we stop here. Technically,
|
// only to have its address taken, so we stop here. Technically,
|
||||||
|
|
|
@ -148,7 +148,7 @@ fn is_infinite(cx: &LateContext, expr: &Expr) -> Finiteness {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if method.name == "flat_map" && args.len() == 2 {
|
if method.name == "flat_map" && args.len() == 2 {
|
||||||
if let ExprClosure(_, _, body_id, _) = args[1].node {
|
if let ExprClosure(_, _, body_id, _, _) = args[1].node {
|
||||||
let body = cx.tcx.hir.body(body_id);
|
let body = cx.tcx.hir.body(body_id);
|
||||||
return is_infinite(cx, &body.value);
|
return is_infinite(cx, &body.value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
if let ExprMethodCall(ref method, _, ref args) = expr.node {
|
if let ExprMethodCall(ref method, _, ref args) = expr.node {
|
||||||
if method.name == "map" && args.len() == 2 {
|
if method.name == "map" && args.len() == 2 {
|
||||||
match args[1].node {
|
match args[1].node {
|
||||||
ExprClosure(_, ref decl, closure_eid, _) => {
|
ExprClosure(_, ref decl, closure_eid, _, _) => {
|
||||||
let body = cx.tcx.hir.body(closure_eid);
|
let body = cx.tcx.hir.body(closure_eid);
|
||||||
let closure_expr = remove_blocks(&body.value);
|
let closure_expr = remove_blocks(&body.value);
|
||||||
let ty = cx.tables.pat_ty(&body.arguments[0].pat);
|
let ty = cx.tables.pat_ty(&body.arguments[0].pat);
|
||||||
|
|
|
@ -46,7 +46,7 @@ fn has_no_effect(cx: &LateContext, expr: &Expr) -> bool {
|
||||||
}
|
}
|
||||||
match expr.node {
|
match expr.node {
|
||||||
Expr_::ExprLit(..) |
|
Expr_::ExprLit(..) |
|
||||||
Expr_::ExprClosure(..) |
|
Expr_::ExprClosure(.., _) |
|
||||||
Expr_::ExprPath(..) => true,
|
Expr_::ExprPath(..) => true,
|
||||||
Expr_::ExprIndex(ref a, ref b) |
|
Expr_::ExprIndex(ref a, ref b) |
|
||||||
Expr_::ExprBinary(_, ref a, ref b) => has_no_effect(cx, a) && has_no_effect(cx, b),
|
Expr_::ExprBinary(_, ref a, ref b) => has_no_effect(cx, a) && has_no_effect(cx, b),
|
||||||
|
|
|
@ -296,10 +296,16 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
|
||||||
println!("Match(ref expr, ref arms, ref desugaring) = {},", current);
|
println!("Match(ref expr, ref arms, ref desugaring) = {},", current);
|
||||||
println!(" // unimplemented: `ExprMatch` is not further destructured at the moment");
|
println!(" // unimplemented: `ExprMatch` is not further destructured at the moment");
|
||||||
},
|
},
|
||||||
Expr_::ExprClosure(ref _capture_clause, ref _func, _, _) => {
|
Expr_::ExprClosure(ref _capture_clause, ref _func, _, _, _) => {
|
||||||
println!("Closure(ref capture_clause, ref func, _, _) = {},", current);
|
println!("Closure(ref capture_clause, ref func, _, _, _) = {},", current);
|
||||||
println!(" // unimplemented: `ExprClosure` is not further destructured at the moment");
|
println!(" // unimplemented: `ExprClosure` is not further destructured at the moment");
|
||||||
},
|
},
|
||||||
|
Expr_::ExprYield(ref sub) => {
|
||||||
|
let sub_pat = self.next("sub");
|
||||||
|
println!("Yield(ref sub) = {},", current);
|
||||||
|
self.current = sub_pat;
|
||||||
|
self.visit_expr(sub);
|
||||||
|
},
|
||||||
Expr_::ExprBlock(ref block) => {
|
Expr_::ExprBlock(ref block) => {
|
||||||
let block_pat = self.next("block");
|
let block_pat = self.next("block");
|
||||||
println!("Block(ref {}) = {},", block_pat, current);
|
println!("Block(ref {}) = {},", block_pat, current);
|
||||||
|
|
|
@ -321,6 +321,11 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
|
||||||
self.hash_name(&i.node.name);
|
self.hash_name(&i.node.name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
ExprYield(ref e) => {
|
||||||
|
let c: fn(_) -> _ = ExprYield;
|
||||||
|
c.hash(&mut self.s);
|
||||||
|
self.hash_expr(e);
|
||||||
|
},
|
||||||
ExprAssign(ref l, ref r) => {
|
ExprAssign(ref l, ref r) => {
|
||||||
let c: fn(_, _) -> _ = ExprAssign;
|
let c: fn(_, _) -> _ = ExprAssign;
|
||||||
c.hash(&mut self.s);
|
c.hash(&mut self.s);
|
||||||
|
@ -373,8 +378,8 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
|
||||||
self.hash_expr(e);
|
self.hash_expr(e);
|
||||||
// TODO: _ty
|
// TODO: _ty
|
||||||
},
|
},
|
||||||
ExprClosure(cap, _, eid, _) => {
|
ExprClosure(cap, _, eid, _, _) => {
|
||||||
let c: fn(_, _, _, _) -> _ = ExprClosure;
|
let c: fn(_, _, _, _, _) -> _ = ExprClosure;
|
||||||
c.hash(&mut self.s);
|
c.hash(&mut self.s);
|
||||||
cap.hash(&mut self.s);
|
cap.hash(&mut self.s);
|
||||||
self.hash_expr(&self.cx.tcx.hir.body(eid).value);
|
self.hash_expr(&self.cx.tcx.hir.body(eid).value);
|
||||||
|
|
|
@ -245,10 +245,14 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
|
||||||
print_expr(cx, cond, indent + 1);
|
print_expr(cx, cond, indent + 1);
|
||||||
println!("{}source: {:?}", ind, source);
|
println!("{}source: {:?}", ind, source);
|
||||||
},
|
},
|
||||||
hir::ExprClosure(ref clause, _, _, _) => {
|
hir::ExprClosure(ref clause, _, _, _, _) => {
|
||||||
println!("{}Closure", ind);
|
println!("{}Closure", ind);
|
||||||
println!("{}clause: {:?}", ind, clause);
|
println!("{}clause: {:?}", ind, clause);
|
||||||
},
|
},
|
||||||
|
hir::ExprYield(ref sub) => {
|
||||||
|
println!("{}Yield", ind);
|
||||||
|
print_expr(cx, sub, indent + 1);
|
||||||
|
}
|
||||||
hir::ExprBlock(_) => {
|
hir::ExprBlock(_) => {
|
||||||
println!("{}Block", ind);
|
println!("{}Block", ind);
|
||||||
},
|
},
|
||||||
|
|
|
@ -104,6 +104,7 @@ pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool {
|
||||||
pub fn in_constant(cx: &LateContext, id: NodeId) -> bool {
|
pub fn in_constant(cx: &LateContext, id: NodeId) -> bool {
|
||||||
let parent_id = cx.tcx.hir.get_parent(id);
|
let parent_id = cx.tcx.hir.get_parent(id);
|
||||||
match MirSource::from_node(cx.tcx, parent_id) {
|
match MirSource::from_node(cx.tcx, parent_id) {
|
||||||
|
MirSource::GeneratorDrop(_) |
|
||||||
MirSource::Fn(_) => false,
|
MirSource::Fn(_) => false,
|
||||||
MirSource::Const(_) |
|
MirSource::Const(_) |
|
||||||
MirSource::Static(..) |
|
MirSource::Static(..) |
|
||||||
|
|
|
@ -49,11 +49,12 @@ impl<'a> Sugg<'a> {
|
||||||
match expr.node {
|
match expr.node {
|
||||||
hir::ExprAddrOf(..) |
|
hir::ExprAddrOf(..) |
|
||||||
hir::ExprBox(..) |
|
hir::ExprBox(..) |
|
||||||
hir::ExprClosure(..) |
|
hir::ExprClosure(.., _) |
|
||||||
hir::ExprIf(..) |
|
hir::ExprIf(..) |
|
||||||
hir::ExprUnary(..) |
|
hir::ExprUnary(..) |
|
||||||
hir::ExprMatch(..) => Sugg::MaybeParen(snippet),
|
hir::ExprMatch(..) => Sugg::MaybeParen(snippet),
|
||||||
hir::ExprAgain(..) |
|
hir::ExprAgain(..) |
|
||||||
|
hir::ExprYield(..) |
|
||||||
hir::ExprArray(..) |
|
hir::ExprArray(..) |
|
||||||
hir::ExprBlock(..) |
|
hir::ExprBlock(..) |
|
||||||
hir::ExprBreak(..) |
|
hir::ExprBreak(..) |
|
||||||
|
@ -106,6 +107,7 @@ impl<'a> Sugg<'a> {
|
||||||
ast::ExprKind::Call(..) |
|
ast::ExprKind::Call(..) |
|
||||||
ast::ExprKind::Catch(..) |
|
ast::ExprKind::Catch(..) |
|
||||||
ast::ExprKind::Continue(..) |
|
ast::ExprKind::Continue(..) |
|
||||||
|
ast::ExprKind::Yield(..) |
|
||||||
ast::ExprKind::Field(..) |
|
ast::ExprKind::Field(..) |
|
||||||
ast::ExprKind::ForLoop(..) |
|
ast::ExprKind::ForLoop(..) |
|
||||||
ast::ExprKind::Index(..) |
|
ast::ExprKind::Index(..) |
|
||||||
|
|
Loading…
Reference in a new issue