Skip to content

Commit 276e85b

Browse files
authored
Merge pull request #1344 from Manishearth/rustup
[WIP] Rustup to rustc 1.15.0-nightly (0ed9519 2016-11-14)
2 parents bad26a5 + 1176242 commit 276e85b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+271
-255
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 0.0.99 — 2016-11-18
5+
* Update to rustc 1.15.0-nightly (0ed951993 2016-11-14)
6+
47
## 0.0.98 — 2016-11-08
58
* Fixes a an issue due to a change in how cargo handles `--sysroot`, which broke `cargo clippy`
69

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.98"
3+
version = "0.0.99"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",
@@ -25,7 +25,7 @@ test = false
2525

2626
[dependencies]
2727
# begin automatic update
28-
clippy_lints = { version = "0.0.98", path = "clippy_lints" }
28+
clippy_lints = { version = "0.0.99", path = "clippy_lints" }
2929
# end automatic update
3030

3131
[dev-dependencies]

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.98"
4+
version = "0.0.99"
55
# end automatic update
66
authors = [
77
"Manish Goregaokar <[email protected]>",

clippy_lints/src/arithmetic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl LateLintPass for Arithmetic {
5959
hir::BiShr | hir::BiEq | hir::BiLt | hir::BiLe | hir::BiNe | hir::BiGe | hir::BiGt => return,
6060
_ => (),
6161
}
62-
let (l_ty, r_ty) = (cx.tcx.expr_ty(l), cx.tcx.expr_ty(r));
62+
let (l_ty, r_ty) = (cx.tcx.tables().expr_ty(l), cx.tcx.tables().expr_ty(r));
6363
if l_ty.is_integral() && r_ty.is_integral() {
6464
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
6565
self.span = Some(expr.span);
@@ -69,7 +69,7 @@ impl LateLintPass for Arithmetic {
6969
}
7070
}
7171
hir::ExprUnary(hir::UnOp::UnNeg, ref arg) => {
72-
let ty = cx.tcx.expr_ty(arg);
72+
let ty = cx.tcx.tables().expr_ty(arg);
7373
if ty.is_integral() {
7474
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
7575
self.span = Some(expr.span);

clippy_lints/src/array_indexing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl LateLintPass for ArrayIndexing {
5959
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
6060
if let hir::ExprIndex(ref array, ref index) = e.node {
6161
// Array with known size can be checked statically
62-
let ty = cx.tcx.expr_ty(array);
62+
let ty = cx.tcx.tables().expr_ty(array);
6363
if let ty::TyArray(_, size) = ty.sty {
6464
let size = ConstInt::Infer(size as u64);
6565

clippy_lints/src/assign_ops.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ impl LateLintPass for AssignOps {
8181
if let hir::ExprBinary(binop, ref l, ref r) = rhs.node {
8282
if op.node == binop.node {
8383
let lint = |assignee: &hir::Expr, rhs: &hir::Expr| {
84-
let ty = cx.tcx.expr_ty(assignee);
84+
let ty = cx.tcx.tables().expr_ty(assignee);
8585
if ty.walk_shallow().next().is_some() {
8686
return; // implements_trait does not work with generics
8787
}
88-
let rty = cx.tcx.expr_ty(rhs);
88+
let rty = cx.tcx.tables().expr_ty(rhs);
8989
if rty.walk_shallow().next().is_some() {
9090
return; // implements_trait does not work with generics
9191
}
@@ -116,11 +116,11 @@ impl LateLintPass for AssignOps {
116116
hir::ExprAssign(ref assignee, ref e) => {
117117
if let hir::ExprBinary(op, ref l, ref r) = e.node {
118118
let lint = |assignee: &hir::Expr, rhs: &hir::Expr| {
119-
let ty = cx.tcx.expr_ty(assignee);
119+
let ty = cx.tcx.tables().expr_ty(assignee);
120120
if ty.walk_shallow().next().is_some() {
121121
return; // implements_trait does not work with generics
122122
}
123-
let rty = cx.tcx.expr_ty(rhs);
123+
let rty = cx.tcx.tables().expr_ty(rhs);
124124
if rty.walk_shallow().next().is_some() {
125125
return; // implements_trait does not work with generics
126126
}

clippy_lints/src/attrs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,24 @@ impl LateLintPass for AttrPass {
152152
}
153153

154154
fn is_relevant_item(cx: &LateContext, item: &Item) -> bool {
155-
if let ItemFn(_, _, _, _, _, ref block) = item.node {
156-
is_relevant_block(cx, block)
155+
if let ItemFn(_, _, _, _, _, ref expr) = item.node {
156+
is_relevant_expr(cx, expr)
157157
} else {
158158
false
159159
}
160160
}
161161

162162
fn is_relevant_impl(cx: &LateContext, item: &ImplItem) -> bool {
163163
match item.node {
164-
ImplItemKind::Method(_, ref block) => is_relevant_block(cx, block),
164+
ImplItemKind::Method(_, ref expr) => is_relevant_expr(cx, expr),
165165
_ => false,
166166
}
167167
}
168168

169169
fn is_relevant_trait(cx: &LateContext, item: &TraitItem) -> bool {
170170
match item.node {
171171
MethodTraitItem(_, None) => true,
172-
MethodTraitItem(_, Some(ref block)) => is_relevant_block(cx, block),
172+
MethodTraitItem(_, Some(ref expr)) => is_relevant_expr(cx, expr),
173173
_ => false,
174174
}
175175
}

clippy_lints/src/block_in_if_condition.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,8 @@ struct ExVisitor<'v> {
5555

5656
impl<'v> Visitor<'v> for ExVisitor<'v> {
5757
fn visit_expr(&mut self, expr: &'v Expr) {
58-
if let ExprClosure(_, _, ref block, _) = expr.node {
59-
let complex = {
60-
if block.stmts.is_empty() {
61-
if let Some(ref ex) = block.expr {
62-
matches!(ex.node, ExprBlock(_))
63-
} else {
64-
false
65-
}
66-
} else {
67-
true
68-
}
69-
};
70-
if complex {
58+
if let ExprClosure(_, _, ref expr, _) = expr.node {
59+
if matches!(expr.node, ExprBlock(_)) {
7160
self.found_block = Some(expr);
7261
return;
7362
}
@@ -119,7 +108,7 @@ impl LateLintPass for BlockInIfCondition {
119108
let mut visitor = ExVisitor { found_block: None };
120109
walk_expr(&mut visitor, check);
121110
if let Some(block) = visitor.found_block {
122-
span_help_and_lint(cx, BLOCK_IN_IF_CONDITION_STMT, block.span, COMPLEX_BLOCK_MESSAGE, "");
111+
span_lint(cx, BLOCK_IN_IF_CONDITION_STMT, block.span, COMPLEX_BLOCK_MESSAGE);
123112
}
124113
}
125114
}

clippy_lints/src/booleans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for NonminimalBoolVisitor<'a, 'tcx> {
392392
match e.node {
393393
ExprBinary(binop, _, _) if binop.node == BiOr || binop.node == BiAnd => self.bool_expr(e),
394394
ExprUnary(UnNot, ref inner) => {
395-
if self.0.tcx.node_types()[&inner.id].is_bool() {
395+
if self.0.tcx.tables.borrow().node_types[&inner.id].is_bool() {
396396
self.bool_expr(e);
397397
} else {
398398
walk_expr(self, e);

clippy_lints/src/copies.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ impl LateLintPass for CopyAndPaste {
120120
}
121121

122122
let (conds, blocks) = if_sequence(expr);
123-
lint_same_then_else(cx, blocks.as_slice());
124-
lint_same_cond(cx, conds.as_slice());
123+
lint_same_then_else(cx, &blocks);
124+
lint_same_cond(cx, &conds);
125125
lint_match_arms(cx, expr);
126126
}
127127
}
@@ -219,8 +219,8 @@ fn lint_match_arms(cx: &LateContext, expr: &Expr) {
219219
/// Eg. would return `([a, b], [c, d, e])` for the expression
220220
/// `if a { c } else if b { d } else { e }`.
221221
fn if_sequence(mut expr: &Expr) -> (SmallVector<&Expr>, SmallVector<&Block>) {
222-
let mut conds = SmallVector::zero();
223-
let mut blocks = SmallVector::zero();
222+
let mut conds = SmallVector::new();
223+
let mut blocks = SmallVector::new();
224224

225225
while let ExprIf(ref cond, ref then_block, ref else_expr) = expr.node {
226226
conds.push(&**cond);
@@ -256,7 +256,7 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<Interned
256256
}
257257
PatKind::Binding(_, ref ident, ref as_pat) => {
258258
if let Entry::Vacant(v) = map.entry(ident.node.as_str()) {
259-
v.insert(cx.tcx.pat_ty(pat));
259+
v.insert(cx.tcx.tables().pat_ty(pat));
260260
}
261261
if let Some(ref as_pat) = *as_pat {
262262
bindings_impl(cx, as_pat, map);

clippy_lints/src/cyclomatic_complexity.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ impl LintPass for CyclomaticComplexity {
4242
}
4343

4444
impl CyclomaticComplexity {
45-
fn check<'a, 'tcx>(&mut self, cx: &'a LateContext<'a, 'tcx>, block: &Block, span: Span) {
45+
fn check<'a, 'tcx>(&mut self, cx: &'a LateContext<'a, 'tcx>, expr: &Expr, span: Span) {
4646
if in_macro(cx, span) {
4747
return;
4848
}
4949

50-
let cfg = CFG::new(cx.tcx, block);
50+
let cfg = CFG::new(cx.tcx, expr);
5151
let n = cfg.graph.len_nodes() as u64;
5252
let e = cfg.graph.len_edges() as u64;
5353
if e + 2 < n {
@@ -62,9 +62,9 @@ impl CyclomaticComplexity {
6262
returns: 0,
6363
tcx: &cx.tcx,
6464
};
65-
helper.visit_block(block);
65+
helper.visit_expr(expr);
6666
let CCHelper { match_arms, divergence, short_circuits, returns, .. } = helper;
67-
let ret_ty = cx.tcx.node_id_to_type(block.id);
67+
let ret_ty = cx.tcx.tables().node_id_to_type(expr.id);
6868
let ret_adjust = if match_type(cx, ret_ty, &paths::RESULT) {
6969
returns
7070
} else {
@@ -92,22 +92,22 @@ impl CyclomaticComplexity {
9292

9393
impl LateLintPass for CyclomaticComplexity {
9494
fn check_item(&mut self, cx: &LateContext, item: &Item) {
95-
if let ItemFn(_, _, _, _, _, ref block) = item.node {
95+
if let ItemFn(_, _, _, _, _, ref expr) = item.node {
9696
if !attr::contains_name(&item.attrs, "test") {
97-
self.check(cx, block, item.span);
97+
self.check(cx, expr, item.span);
9898
}
9999
}
100100
}
101101

102102
fn check_impl_item(&mut self, cx: &LateContext, item: &ImplItem) {
103-
if let ImplItemKind::Method(_, ref block) = item.node {
104-
self.check(cx, block, item.span);
103+
if let ImplItemKind::Method(_, ref expr) = item.node {
104+
self.check(cx, expr, item.span);
105105
}
106106
}
107107

108108
fn check_trait_item(&mut self, cx: &LateContext, item: &TraitItem) {
109-
if let MethodTraitItem(_, Some(ref block)) = item.node {
110-
self.check(cx, block, item.span);
109+
if let MethodTraitItem(_, Some(ref expr)) = item.node {
110+
self.check(cx, expr, item.span);
111111
}
112112
}
113113

@@ -139,7 +139,7 @@ impl<'a, 'b, 'tcx, 'gcx> Visitor<'a> for CCHelper<'b, 'gcx, 'tcx> {
139139
}
140140
ExprCall(ref callee, _) => {
141141
walk_expr(self, e);
142-
let ty = self.tcx.node_id_to_type(callee.id);
142+
let ty = self.tcx.tables().node_id_to_type(callee.id);
143143
match ty.sty {
144144
ty::TyFnDef(_, _, ty) |
145145
ty::TyFnPtr(ty) if ty.sig.skip_binder().output.sty == ty::TyNever => {

clippy_lints/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl LintPass for Derive {
7373
impl LateLintPass for Derive {
7474
fn check_item(&mut self, cx: &LateContext, item: &Item) {
7575
if let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node {
76-
let ty = cx.tcx.lookup_item_type(cx.tcx.map.local_def_id(item.id)).ty;
76+
let ty = cx.tcx.item_type(cx.tcx.map.local_def_id(item.id));
7777
let is_automatically_derived = is_automatically_derived(&*item.attrs);
7878

7979
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);

clippy_lints/src/drop_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl LateLintPass for Pass {
5252
}
5353

5454
fn check_drop_arg(cx: &LateContext, call_span: Span, arg: &Expr) {
55-
let arg_ty = cx.tcx.expr_ty(arg);
55+
let arg_ty = cx.tcx.tables().expr_ty(arg);
5656
if let ty::TyRef(..) = arg_ty.sty {
5757
span_note_and_lint(cx,
5858
DROP_REF,

clippy_lints/src/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn check_cond<'a, 'tcx, 'b>(cx: &'a LateContext<'a, 'tcx>, check: &'b Expr) -> O
8686
let ExprAddrOf(_, ref key) = params[1].node
8787
], {
8888
let map = &params[0];
89-
let obj_ty = walk_ptrs_ty(cx.tcx.expr_ty(map));
89+
let obj_ty = walk_ptrs_ty(cx.tcx.tables().expr_ty(map));
9090

9191
return if match_type(cx, obj_ty, &paths::BTREEMAP) {
9292
Some(("BTreeMap", map, key))

clippy_lints/src/escape.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc::infer::InferCtxt;
55
use rustc::lint::*;
66
use rustc::middle::expr_use_visitor::*;
77
use rustc::middle::mem_categorization::{cmt, Categorization};
8-
use rustc::ty::adjustment::AutoAdjustment;
98
use rustc::ty;
109
use rustc::ty::layout::TargetDataLayout;
1110
use rustc::util::nodemap::NodeSet;
@@ -62,7 +61,7 @@ impl LintPass for Pass {
6261
}
6362

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

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

150150
if let Categorization::Local(lid) = cmt.cat {
151151
if self.set.contains(&lid) {
152-
if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.tcx
152+
if let Some(&Adjust::DerefRef { autoderefs, .. }) = self.tcx
153153
.tables
154154
.borrow()
155155
.adjustments
156-
.get(&borrow_id) {
156+
.get(&borrow_id)
157+
.map(|a| &a.kind) {
157158
if LoanCause::AutoRef == loan_cause {
158159
// x.foo()
159-
if adj.autoderefs == 0 {
160+
if autoderefs == 0 {
160161
self.set.remove(&lid); // Used without autodereffing (i.e. x.clone())
161162
}
162163
} else {
163164
span_bug!(cmt.span, "Unknown adjusted AutoRef");
164165
}
165166
} else if LoanCause::AddrOf == loan_cause {
166167
// &x
167-
if let Some(&AutoAdjustment::AdjustDerefRef(adj)) = self.tcx
168+
if let Some(&Adjust::DerefRef { autoderefs, .. }) = self.tcx
168169
.tables
169170
.borrow()
170171
.adjustments
171172
.get(&self.tcx
172-
.map
173-
.get_parent_node(borrow_id)) {
174-
if adj.autoderefs <= 1 {
173+
.map
174+
.get_parent_node(borrow_id))
175+
.map(|a| &a.kind) {
176+
if autoderefs <= 1 {
175177
// foo(&x) where no extra autoreffing is happening
176178
self.set.remove(&lid);
177179
}

0 commit comments

Comments
 (0)