Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustup to rustc 1.15.0-nightly (0ed951993 2016-11-14) and bump to 0.0.99 #1344

Merged
merged 5 commits into from
Nov 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.99 — 2016-11-18
* Update to rustc 1.15.0-nightly (0ed951993 2016-11-14)

## 0.0.98 — 2016-11-08
* Fixes a an issue due to a change in how cargo handles `--sysroot`, which broke `cargo clippy`

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.98"
version = "0.0.99"
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",
"Andre Bogus <bogusandre@gmail.com>",
Expand All @@ -25,7 +25,7 @@ test = false

[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.98", path = "clippy_lints" }
clippy_lints = { version = "0.0.99", path = "clippy_lints" }
# end automatic update

[dev-dependencies]
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.98"
version = "0.0.99"
# end automatic update
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl LateLintPass for Arithmetic {
hir::BiShr | hir::BiEq | hir::BiLt | hir::BiLe | hir::BiNe | hir::BiGe | hir::BiGt => return,
_ => (),
}
let (l_ty, r_ty) = (cx.tcx.expr_ty(l), cx.tcx.expr_ty(r));
let (l_ty, r_ty) = (cx.tcx.tables().expr_ty(l), cx.tcx.tables().expr_ty(r));
if l_ty.is_integral() && r_ty.is_integral() {
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
self.span = Some(expr.span);
Expand All @@ -69,7 +69,7 @@ impl LateLintPass for Arithmetic {
}
}
hir::ExprUnary(hir::UnOp::UnNeg, ref arg) => {
let ty = cx.tcx.expr_ty(arg);
let ty = cx.tcx.tables().expr_ty(arg);
if ty.is_integral() {
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
self.span = Some(expr.span);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/array_indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl LateLintPass for ArrayIndexing {
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
if let hir::ExprIndex(ref array, ref index) = e.node {
// Array with known size can be checked statically
let ty = cx.tcx.expr_ty(array);
let ty = cx.tcx.tables().expr_ty(array);
if let ty::TyArray(_, size) = ty.sty {
let size = ConstInt::Infer(size as u64);

Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/assign_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ impl LateLintPass for AssignOps {
if let hir::ExprBinary(binop, ref l, ref r) = rhs.node {
if op.node == binop.node {
let lint = |assignee: &hir::Expr, rhs: &hir::Expr| {
let ty = cx.tcx.expr_ty(assignee);
let ty = cx.tcx.tables().expr_ty(assignee);
if ty.walk_shallow().next().is_some() {
return; // implements_trait does not work with generics
}
let rty = cx.tcx.expr_ty(rhs);
let rty = cx.tcx.tables().expr_ty(rhs);
if rty.walk_shallow().next().is_some() {
return; // implements_trait does not work with generics
}
Expand Down Expand Up @@ -116,11 +116,11 @@ impl LateLintPass for AssignOps {
hir::ExprAssign(ref assignee, ref e) => {
if let hir::ExprBinary(op, ref l, ref r) = e.node {
let lint = |assignee: &hir::Expr, rhs: &hir::Expr| {
let ty = cx.tcx.expr_ty(assignee);
let ty = cx.tcx.tables().expr_ty(assignee);
if ty.walk_shallow().next().is_some() {
return; // implements_trait does not work with generics
}
let rty = cx.tcx.expr_ty(rhs);
let rty = cx.tcx.tables().expr_ty(rhs);
if rty.walk_shallow().next().is_some() {
return; // implements_trait does not work with generics
}
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,24 +152,24 @@ impl LateLintPass for AttrPass {
}

fn is_relevant_item(cx: &LateContext, item: &Item) -> bool {
if let ItemFn(_, _, _, _, _, ref block) = item.node {
is_relevant_block(cx, block)
if let ItemFn(_, _, _, _, _, ref expr) = item.node {
is_relevant_expr(cx, expr)
} else {
false
}
}

fn is_relevant_impl(cx: &LateContext, item: &ImplItem) -> bool {
match item.node {
ImplItemKind::Method(_, ref block) => is_relevant_block(cx, block),
ImplItemKind::Method(_, ref expr) => is_relevant_expr(cx, expr),
_ => false,
}
}

fn is_relevant_trait(cx: &LateContext, item: &TraitItem) -> bool {
match item.node {
MethodTraitItem(_, None) => true,
MethodTraitItem(_, Some(ref block)) => is_relevant_block(cx, block),
MethodTraitItem(_, Some(ref expr)) => is_relevant_expr(cx, expr),
_ => false,
}
}
Expand Down
17 changes: 3 additions & 14 deletions clippy_lints/src/block_in_if_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,8 @@ struct ExVisitor<'v> {

impl<'v> Visitor<'v> for ExVisitor<'v> {
fn visit_expr(&mut self, expr: &'v Expr) {
if let ExprClosure(_, _, ref block, _) = expr.node {
let complex = {
if block.stmts.is_empty() {
if let Some(ref ex) = block.expr {
matches!(ex.node, ExprBlock(_))
} else {
false
}
} else {
true
}
};
if complex {
if let ExprClosure(_, _, ref expr, _) = expr.node {
if matches!(expr.node, ExprBlock(_)) {
self.found_block = Some(expr);
return;
}
Expand Down Expand Up @@ -119,7 +108,7 @@ impl LateLintPass for BlockInIfCondition {
let mut visitor = ExVisitor { found_block: None };
walk_expr(&mut visitor, check);
if let Some(block) = visitor.found_block {
span_help_and_lint(cx, BLOCK_IN_IF_CONDITION_STMT, block.span, COMPLEX_BLOCK_MESSAGE, "");
span_lint(cx, BLOCK_IN_IF_CONDITION_STMT, block.span, COMPLEX_BLOCK_MESSAGE);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for NonminimalBoolVisitor<'a, 'tcx> {
match e.node {
ExprBinary(binop, _, _) if binop.node == BiOr || binop.node == BiAnd => self.bool_expr(e),
ExprUnary(UnNot, ref inner) => {
if self.0.tcx.node_types()[&inner.id].is_bool() {
if self.0.tcx.tables.borrow().node_types[&inner.id].is_bool() {
self.bool_expr(e);
} else {
walk_expr(self, e);
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ impl LateLintPass for CopyAndPaste {
}

let (conds, blocks) = if_sequence(expr);
lint_same_then_else(cx, blocks.as_slice());
lint_same_cond(cx, conds.as_slice());
lint_same_then_else(cx, &blocks);
lint_same_cond(cx, &conds);
lint_match_arms(cx, expr);
}
}
Expand Down Expand Up @@ -219,8 +219,8 @@ fn lint_match_arms(cx: &LateContext, expr: &Expr) {
/// Eg. would return `([a, b], [c, d, e])` for the expression
/// `if a { c } else if b { d } else { e }`.
fn if_sequence(mut expr: &Expr) -> (SmallVector<&Expr>, SmallVector<&Block>) {
let mut conds = SmallVector::zero();
let mut blocks = SmallVector::zero();
let mut conds = SmallVector::new();
let mut blocks = SmallVector::new();

while let ExprIf(ref cond, ref then_block, ref else_expr) = expr.node {
conds.push(&**cond);
Expand Down Expand Up @@ -256,7 +256,7 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<Interned
}
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));
v.insert(cx.tcx.tables().pat_ty(pat));
}
if let Some(ref as_pat) = *as_pat {
bindings_impl(cx, as_pat, map);
Expand Down
22 changes: 11 additions & 11 deletions clippy_lints/src/cyclomatic_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ impl LintPass for CyclomaticComplexity {
}

impl CyclomaticComplexity {
fn check<'a, 'tcx>(&mut self, cx: &'a LateContext<'a, 'tcx>, block: &Block, span: Span) {
fn check<'a, 'tcx>(&mut self, cx: &'a LateContext<'a, 'tcx>, expr: &Expr, span: Span) {
if in_macro(cx, span) {
return;
}

let cfg = CFG::new(cx.tcx, block);
let cfg = CFG::new(cx.tcx, expr);
let n = cfg.graph.len_nodes() as u64;
let e = cfg.graph.len_edges() as u64;
if e + 2 < n {
Expand All @@ -62,9 +62,9 @@ impl CyclomaticComplexity {
returns: 0,
tcx: &cx.tcx,
};
helper.visit_block(block);
helper.visit_expr(expr);
let CCHelper { match_arms, divergence, short_circuits, returns, .. } = helper;
let ret_ty = cx.tcx.node_id_to_type(block.id);
let ret_ty = cx.tcx.tables().node_id_to_type(expr.id);
let ret_adjust = if match_type(cx, ret_ty, &paths::RESULT) {
returns
} else {
Expand Down Expand Up @@ -92,22 +92,22 @@ impl CyclomaticComplexity {

impl LateLintPass for CyclomaticComplexity {
fn check_item(&mut self, cx: &LateContext, item: &Item) {
if let ItemFn(_, _, _, _, _, ref block) = item.node {
if let ItemFn(_, _, _, _, _, ref expr) = item.node {
if !attr::contains_name(&item.attrs, "test") {
self.check(cx, block, item.span);
self.check(cx, expr, item.span);
}
}
}

fn check_impl_item(&mut self, cx: &LateContext, item: &ImplItem) {
if let ImplItemKind::Method(_, ref block) = item.node {
self.check(cx, block, item.span);
if let ImplItemKind::Method(_, ref expr) = item.node {
self.check(cx, expr, item.span);
}
}

fn check_trait_item(&mut self, cx: &LateContext, item: &TraitItem) {
if let MethodTraitItem(_, Some(ref block)) = item.node {
self.check(cx, block, item.span);
if let MethodTraitItem(_, Some(ref expr)) = item.node {
self.check(cx, expr, item.span);
}
}

Expand Down Expand Up @@ -139,7 +139,7 @@ impl<'a, 'b, 'tcx, 'gcx> Visitor<'a> for CCHelper<'b, 'gcx, 'tcx> {
}
ExprCall(ref callee, _) => {
walk_expr(self, e);
let ty = self.tcx.node_id_to_type(callee.id);
let ty = self.tcx.tables().node_id_to_type(callee.id);
match ty.sty {
ty::TyFnDef(_, _, ty) |
ty::TyFnPtr(ty) if ty.sig.skip_binder().output.sty == ty::TyNever => {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl LintPass for Derive {
impl LateLintPass for Derive {
fn check_item(&mut self, cx: &LateContext, item: &Item) {
if let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node {
let ty = cx.tcx.lookup_item_type(cx.tcx.map.local_def_id(item.id)).ty;
let ty = cx.tcx.item_type(cx.tcx.map.local_def_id(item.id));
let is_automatically_derived = is_automatically_derived(&*item.attrs);

check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/drop_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl LateLintPass for Pass {
}

fn check_drop_arg(cx: &LateContext, call_span: Span, arg: &Expr) {
let arg_ty = cx.tcx.expr_ty(arg);
let arg_ty = cx.tcx.tables().expr_ty(arg);
if let ty::TyRef(..) = arg_ty.sty {
span_note_and_lint(cx,
DROP_REF,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn check_cond<'a, 'tcx, 'b>(cx: &'a LateContext<'a, 'tcx>, check: &'b Expr) -> O
let ExprAddrOf(_, ref key) = params[1].node
], {
let map = &params[0];
let obj_ty = walk_ptrs_ty(cx.tcx.expr_ty(map));
let obj_ty = walk_ptrs_ty(cx.tcx.tables().expr_ty(map));

return if match_type(cx, obj_ty, &paths::BTREEMAP) {
Some(("BTreeMap", map, key))
Expand Down
20 changes: 11 additions & 9 deletions clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use rustc::infer::InferCtxt;
use rustc::lint::*;
use rustc::middle::expr_use_visitor::*;
use rustc::middle::mem_categorization::{cmt, Categorization};
use rustc::ty::adjustment::AutoAdjustment;
use rustc::ty;
use rustc::ty::layout::TargetDataLayout;
use rustc::util::nodemap::NodeSet;
Expand Down Expand Up @@ -62,7 +61,7 @@ impl LintPass for Pass {
}

impl LateLintPass for Pass {
fn check_fn(&mut self, cx: &LateContext, _: visit::FnKind, decl: &FnDecl, body: &Block, _: Span, id: NodeId) {
fn check_fn(&mut self, cx: &LateContext, _: visit::FnKind, decl: &FnDecl, body: &Expr, _: Span, id: NodeId) {
let param_env = ty::ParameterEnvironment::for_item(cx.tcx, id);

let infcx = cx.tcx.borrowck_fake_infer_ctxt(param_env);
Expand Down Expand Up @@ -146,32 +145,35 @@ impl<'a, 'tcx: 'a+'gcx, 'gcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx, 'g
}
fn borrow(&mut self, borrow_id: NodeId, _: Span, cmt: cmt<'tcx>, _: &ty::Region, _: ty::BorrowKind,
loan_cause: LoanCause) {
use rustc::ty::adjustment::Adjust;

if let Categorization::Local(lid) = cmt.cat {
if self.set.contains(&lid) {
if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.tcx
if let Some(&Adjust::DerefRef { autoderefs, .. }) = self.tcx
.tables
.borrow()
.adjustments
.get(&borrow_id) {
.get(&borrow_id)
.map(|a| &a.kind) {
if LoanCause::AutoRef == loan_cause {
// x.foo()
if adj.autoderefs == 0 {
if autoderefs == 0 {
self.set.remove(&lid); // Used without autodereffing (i.e. x.clone())
}
} else {
span_bug!(cmt.span, "Unknown adjusted AutoRef");
}
} else if LoanCause::AddrOf == loan_cause {
// &x
if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.tcx
if let Some(&Adjust::DerefRef { autoderefs, .. }) = self.tcx
.tables
.borrow()
.adjustments
.get(&self.tcx
.map
.get_parent_node(borrow_id)) {
if adj.autoderefs <= 1 {
.map
.get_parent_node(borrow_id))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indent here.

.map(|a| &a.kind) {
if autoderefs <= 1 {
// foo(&x) where no extra autoreffing is happening
self.set.remove(&lid);
}
Expand Down
Loading