Skip to content

Commit

Permalink
Rustup (fixes #2002)
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Aug 30, 2017
1 parent c99b67c commit 9d6c0fe
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
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
* Update to *rustc 1.21.0-nightly (2c0558f63 2017-08-24)*
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.154"
version = "0.0.155"
authors = [
"Manish Goregaokar <[email protected]>",
"Andre Bogus <[email protected]>",
Expand Down Expand Up @@ -31,7 +31,7 @@ path = "src/main.rs"

[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.154", path = "clippy_lints" }
clippy_lints = { version = "0.0.155", path = "clippy_lints" }
# end automatic update
cargo_metadata = "0.2"

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "clippy_lints"
# begin automatic update
version = "0.0.154"
version = "0.0.155"
# end automatic update
authors = [
"Manish Goregaokar <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/block_in_if_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct ExVisitor<'a, 'tcx: 'a> {

impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
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 ex = &body.value;
if matches!(ex.node, ExprBlock(_)) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
let ExprMethodCall(ref filter, _, ref filter_args) = count_args[0].node,
filter.name == "filter",
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);
if_let_chain!([
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/cyclomatic_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> {
_ => (),
}
},
ExprClosure(..) => (),
ExprClosure(.., _) => (),
ExprBinary(op, _, _) => {
walk_expr(self, e);
match op.node {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaPass {
}

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 ex = &body.value;
if let ExprCall(ref caller, ref args) = ex.node {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/eval_order_dependence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct DivergenceVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
fn maybe_walk_expr(&mut self, e: &'tcx Expr) {
match e.node {
ExprClosure(..) => {},
ExprClosure(.., _) => {},
ExprMatch(ref e, ref arms, _) => {
self.visit_expr(e);
for arm in arms {
Expand Down Expand Up @@ -239,7 +239,7 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St
walk_expr(vis, expr);
}
},
ExprClosure(_, _, _, _) => {
ExprClosure(_, _, _, _, _) => {
// Either
//
// * `var` is defined in the closure body, in which case we've
Expand Down Expand Up @@ -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
// if) the closure will be evaluated, any reads in it might not
// 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
// only to have its address taken, so we stop here. Technically,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/infinite_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn is_infinite(cx: &LateContext, expr: &Expr) -> Finiteness {
}
}
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);
return is_infinite(cx, &body.value);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/map_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
if let ExprMethodCall(ref method, _, ref args) = expr.node {
if method.name == "map" && args.len() == 2 {
match args[1].node {
ExprClosure(_, ref decl, closure_eid, _) => {
ExprClosure(_, ref decl, closure_eid, _, _) => {
let body = cx.tcx.hir.body(closure_eid);
let closure_expr = remove_blocks(&body.value);
let ty = cx.tables.pat_ty(&body.arguments[0].pat);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/no_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn has_no_effect(cx: &LateContext, expr: &Expr) -> bool {
}
match expr.node {
Expr_::ExprLit(..) |
Expr_::ExprClosure(..) |
Expr_::ExprClosure(.., _) |
Expr_::ExprPath(..) => true,
Expr_::ExprIndex(ref a, ref b) |
Expr_::ExprBinary(_, ref a, ref b) => has_no_effect(cx, a) && has_no_effect(cx, b),
Expand Down
10 changes: 8 additions & 2 deletions clippy_lints/src/utils/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,16 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
println!("Match(ref expr, ref arms, ref desugaring) = {},", current);
println!(" // unimplemented: `ExprMatch` is not further destructured at the moment");
},
Expr_::ExprClosure(ref _capture_clause, ref _func, _, _) => {
println!("Closure(ref capture_clause, ref func, _, _) = {},", current);
Expr_::ExprClosure(ref _capture_clause, ref _func, _, _, _) => {
println!("Closure(ref capture_clause, ref func, _, _, _) = {},", current);
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) => {
let block_pat = self.next("block");
println!("Block(ref {}) = {},", block_pat, current);
Expand Down
9 changes: 7 additions & 2 deletions clippy_lints/src/utils/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
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) => {
let c: fn(_, _) -> _ = ExprAssign;
c.hash(&mut self.s);
Expand Down Expand Up @@ -373,8 +378,8 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
self.hash_expr(e);
// TODO: _ty
},
ExprClosure(cap, _, eid, _) => {
let c: fn(_, _, _, _) -> _ = ExprClosure;
ExprClosure(cap, _, eid, _, _) => {
let c: fn(_, _, _, _, _) -> _ = ExprClosure;
c.hash(&mut self.s);
cap.hash(&mut self.s);
self.hash_expr(&self.cx.tcx.hir.body(eid).value);
Expand Down
6 changes: 5 additions & 1 deletion clippy_lints/src/utils/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,14 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) {
print_expr(cx, cond, indent + 1);
println!("{}source: {:?}", ind, source);
},
hir::ExprClosure(ref clause, _, _, _) => {
hir::ExprClosure(ref clause, _, _, _, _) => {
println!("{}Closure", ind);
println!("{}clause: {:?}", ind, clause);
},
hir::ExprYield(ref sub) => {
println!("{}Yield", ind);
print_expr(cx, sub, indent + 1);
}
hir::ExprBlock(_) => {
println!("{}Block", ind);
},
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool {
pub fn in_constant(cx: &LateContext, id: NodeId) -> bool {
let parent_id = cx.tcx.hir.get_parent(id);
match MirSource::from_node(cx.tcx, parent_id) {
MirSource::GeneratorDrop(_) |
MirSource::Fn(_) => false,
MirSource::Const(_) |
MirSource::Static(..) |
Expand Down
4 changes: 3 additions & 1 deletion clippy_lints/src/utils/sugg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ impl<'a> Sugg<'a> {
match expr.node {
hir::ExprAddrOf(..) |
hir::ExprBox(..) |
hir::ExprClosure(..) |
hir::ExprClosure(.., _) |
hir::ExprIf(..) |
hir::ExprUnary(..) |
hir::ExprMatch(..) => Sugg::MaybeParen(snippet),
hir::ExprAgain(..) |
hir::ExprYield(..) |
hir::ExprArray(..) |
hir::ExprBlock(..) |
hir::ExprBreak(..) |
Expand Down Expand Up @@ -106,6 +107,7 @@ impl<'a> Sugg<'a> {
ast::ExprKind::Call(..) |
ast::ExprKind::Catch(..) |
ast::ExprKind::Continue(..) |
ast::ExprKind::Yield(..) |
ast::ExprKind::Field(..) |
ast::ExprKind::ForLoop(..) |
ast::ExprKind::Index(..) |
Expand Down

0 comments on commit 9d6c0fe

Please sign in to comment.