Skip to content

Commit c6e2967

Browse files
committed
rustup to rustc 1.15.0-dev (3b248a184 2016-12-05)
1 parent 2e63a56 commit c6e2967

Some content is hidden

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

71 files changed

+517
-335
lines changed

clippy_lints/src/approx_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl LintPass for Pass {
6060
}
6161

6262
impl LateLintPass for Pass {
63-
fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
63+
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
6464
if let ExprLit(ref lit) = e.node {
6565
check_lit(cx, lit, e);
6666
}

clippy_lints/src/arithmetic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl LintPass for Arithmetic {
4848
}
4949

5050
impl LateLintPass for Arithmetic {
51-
fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) {
51+
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
5252
if self.span.is_some() {
5353
return;
5454
}
@@ -82,7 +82,7 @@ impl LateLintPass for Arithmetic {
8282
}
8383
}
8484

85-
fn check_expr_post(&mut self, _: &LateContext, expr: &hir::Expr) {
85+
fn check_expr_post<'a, 'tcx: 'a>(&mut self, _: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
8686
if Some(expr.span) == self.span {
8787
self.span = None;
8888
}

clippy_lints/src/array_indexing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl LintPass for ArrayIndexing {
5656
}
5757

5858
impl LateLintPass for ArrayIndexing {
59-
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
59+
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
6060
if let hir::ExprIndex(ref array, ref index) = e.node {
6161
// Array with known size can be checked statically
6262
let ty = cx.tcx.tables().expr_ty(array);

clippy_lints/src/assign_ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl LintPass for AssignOps {
6767
}
6868

6969
impl LateLintPass for AssignOps {
70-
fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) {
70+
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
7171
match expr.node {
7272
hir::ExprAssignOp(op, ref lhs, ref rhs) => {
7373
span_lint_and_then(cx, ASSIGN_OPS, expr.span, "assign operation detected", |db| {

clippy_lints/src/attrs.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl LintPass for AttrPass {
8282
}
8383

8484
impl LateLintPass for AttrPass {
85-
fn check_attribute(&mut self, cx: &LateContext, attr: &Attribute) {
85+
fn check_attribute<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, attr: &'tcx Attribute) {
8686
if let MetaItemKind::List(ref items) = attr.value.node {
8787
if items.is_empty() || attr.name() != "deprecated" {
8888
return;
@@ -99,7 +99,7 @@ impl LateLintPass for AttrPass {
9999
}
100100
}
101101

102-
fn check_item(&mut self, cx: &LateContext, item: &Item) {
102+
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
103103
if is_relevant_item(cx, item) {
104104
check_attrs(cx, item.span, &item.name, &item.attrs)
105105
}
@@ -138,38 +138,38 @@ impl LateLintPass for AttrPass {
138138
}
139139
}
140140

141-
fn check_impl_item(&mut self, cx: &LateContext, item: &ImplItem) {
141+
fn check_impl_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
142142
if is_relevant_impl(cx, item) {
143143
check_attrs(cx, item.span, &item.name, &item.attrs)
144144
}
145145
}
146146

147-
fn check_trait_item(&mut self, cx: &LateContext, item: &TraitItem) {
147+
fn check_trait_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
148148
if is_relevant_trait(cx, item) {
149149
check_attrs(cx, item.span, &item.name, &item.attrs)
150150
}
151151
}
152152
}
153153

154154
fn is_relevant_item(cx: &LateContext, item: &Item) -> bool {
155-
if let ItemFn(_, _, _, _, _, ref expr) = item.node {
156-
is_relevant_expr(cx, expr)
155+
if let ItemFn(_, _, _, _, _, eid) = item.node {
156+
is_relevant_expr(cx, cx.tcx.map.expr(eid))
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 expr) => is_relevant_expr(cx, expr),
164+
ImplItemKind::Method(_, eid) => is_relevant_expr(cx, cx.tcx.map.expr(eid)),
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 expr)) => is_relevant_expr(cx, expr),
172+
MethodTraitItem(_, Some(eid)) => is_relevant_expr(cx, cx.tcx.map.expr(eid)),
173173
_ => false,
174174
}
175175
}

clippy_lints/src/bit_mask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl LintPass for BitMask {
8080
}
8181

8282
impl LateLintPass for BitMask {
83-
fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
83+
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
8484
if let ExprBinary(ref cmp, ref left, ref right) = e.node {
8585
if cmp.node.is_comparison() {
8686
if let Some(cmp_opt) = fetch_int_literal(cx, right) {

clippy_lints/src/blacklisted_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl LintPass for BlackListedName {
3838
}
3939

4040
impl LateLintPass for BlackListedName {
41-
fn check_pat(&mut self, cx: &LateContext, pat: &Pat) {
41+
fn check_pat<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
4242
if let PatKind::Binding(_, _, ref ident, _) = pat.node {
4343
if self.blacklist.iter().any(|s| s == &*ident.node.as_str()) {
4444
span_lint(cx,

clippy_lints/src/block_in_if_condition.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc::lint::{LateLintPass, LateContext, LintArray, LintPass};
22
use rustc::hir::*;
3-
use rustc::hir::intravisit::{Visitor, walk_expr};
3+
use rustc::hir::intravisit::{Visitor, walk_expr, NestedVisitorMap};
44
use utils::*;
55

66
/// **What it does:** Checks for `if` conditions that use blocks to contain an
@@ -49,28 +49,33 @@ impl LintPass for BlockInIfCondition {
4949
}
5050
}
5151

52-
struct ExVisitor<'v> {
53-
found_block: Option<&'v Expr>,
52+
struct ExVisitor<'a, 'tcx: 'a> {
53+
found_block: Option<&'tcx Expr>,
54+
cx: &'a LateContext<'a, 'tcx>,
5455
}
5556

56-
impl<'v> Visitor<'v> for ExVisitor<'v> {
57-
fn visit_expr(&mut self, expr: &'v Expr) {
58-
if let ExprClosure(_, _, ref expr, _) = expr.node {
57+
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
58+
fn visit_expr(&mut self, expr: &'tcx Expr) {
59+
if let ExprClosure(_, _, eid, _) = expr.node {
60+
let expr = self.cx.tcx.map.expr(eid);
5961
if matches!(expr.node, ExprBlock(_)) {
6062
self.found_block = Some(expr);
6163
return;
6264
}
6365
}
6466
walk_expr(self, expr);
6567
}
68+
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
69+
NestedVisitorMap::All(&self.cx.tcx.map)
70+
}
6671
}
6772

6873
const BRACED_EXPR_MESSAGE: &'static str = "omit braces around single expression condition";
6974
const COMPLEX_BLOCK_MESSAGE: &'static str = "in an 'if' condition, avoid complex blocks or closures with blocks; \
7075
instead, move the block or closure higher and bind it with a 'let'";
7176

7277
impl LateLintPass for BlockInIfCondition {
73-
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
78+
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
7479
if let ExprIf(ref check, ref then, _) = expr.node {
7580
if let ExprBlock(ref block) = check.node {
7681
if block.rules == DefaultBlock {
@@ -105,7 +110,7 @@ impl LateLintPass for BlockInIfCondition {
105110
}
106111
}
107112
} else {
108-
let mut visitor = ExVisitor { found_block: None };
113+
let mut visitor = ExVisitor { found_block: None, cx: cx };
109114
walk_expr(&mut visitor, check);
110115
if let Some(block) = visitor.found_block {
111116
span_lint(cx, BLOCK_IN_IF_CONDITION_STMT, block.span, COMPLEX_BLOCK_MESSAGE);

clippy_lints/src/booleans.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ impl LintPass for NonminimalBool {
5454
}
5555

5656
impl LateLintPass for NonminimalBool {
57-
fn check_item(&mut self, cx: &LateContext, item: &Item) {
58-
NonminimalBoolVisitor(cx).visit_item(item)
57+
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
58+
NonminimalBoolVisitor { cx: cx }.visit_item(item)
5959
}
6060
}
6161

62-
struct NonminimalBoolVisitor<'a, 'tcx: 'a>(&'a LateContext<'a, 'tcx>);
62+
struct NonminimalBoolVisitor<'a, 'tcx: 'a> {
63+
cx: &'a LateContext<'a, 'tcx>,
64+
}
6365

6466
use quine_mc_cluskey::Bool;
6567
struct Hir2Qmm<'a, 'tcx: 'a, 'v> {
@@ -308,7 +310,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
308310
fn bool_expr(&self, e: &Expr) {
309311
let mut h2q = Hir2Qmm {
310312
terminals: Vec::new(),
311-
cx: self.0,
313+
cx: self.cx,
312314
};
313315
if let Ok(expr) = h2q.run(e) {
314316

@@ -343,7 +345,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
343345
continue 'simplified;
344346
}
345347
if stats.terminals[i] != 0 && simplified_stats.terminals[i] == 0 {
346-
span_lint_and_then(self.0,
348+
span_lint_and_then(self.cx,
347349
LOGIC_BUG,
348350
e.span,
349351
"this boolean expression contains a logic bug",
@@ -353,7 +355,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
353355
outer expression");
354356
db.span_suggestion(e.span,
355357
"it would look like the following",
356-
suggest(self.0, suggestion, &h2q.terminals));
358+
suggest(self.cx, suggestion, &h2q.terminals));
357359
});
358360
// don't also lint `NONMINIMAL_BOOL`
359361
return;
@@ -370,29 +372,29 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
370372
}
371373
}
372374
if !improvements.is_empty() {
373-
span_lint_and_then(self.0,
375+
span_lint_and_then(self.cx,
374376
NONMINIMAL_BOOL,
375377
e.span,
376378
"this boolean expression can be simplified",
377379
|db| {
378380
for suggestion in &improvements {
379-
db.span_suggestion(e.span, "try", suggest(self.0, suggestion, &h2q.terminals));
381+
db.span_suggestion(e.span, "try", suggest(self.cx, suggestion, &h2q.terminals));
380382
}
381383
});
382384
}
383385
}
384386
}
385387
}
386388

387-
impl<'a, 'v, 'tcx> Visitor<'v> for NonminimalBoolVisitor<'a, 'tcx> {
388-
fn visit_expr(&mut self, e: &'v Expr) {
389-
if in_macro(self.0, e.span) {
389+
impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
390+
fn visit_expr(&mut self, e: &'tcx Expr) {
391+
if in_macro(self.cx, e.span) {
390392
return;
391393
}
392394
match e.node {
393395
ExprBinary(binop, _, _) if binop.node == BiOr || binop.node == BiAnd => self.bool_expr(e),
394396
ExprUnary(UnNot, ref inner) => {
395-
if self.0.tcx.tables.borrow().node_types[&inner.id].is_bool() {
397+
if self.cx.tcx.tables.borrow().node_types[&inner.id].is_bool() {
396398
self.bool_expr(e);
397399
} else {
398400
walk_expr(self, e);
@@ -401,4 +403,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for NonminimalBoolVisitor<'a, 'tcx> {
401403
_ => walk_expr(self, e),
402404
}
403405
}
406+
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
407+
NestedVisitorMap::All(&self.cx.tcx.map)
408+
}
404409
}

clippy_lints/src/copies.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl LintPass for CopyAndPaste {
110110
}
111111

112112
impl LateLintPass for CopyAndPaste {
113-
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
113+
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
114114
if !in_macro(cx, expr.span) {
115115
// skip ifs directly in else, it will be checked in the parent if
116116
if let Some(&Expr { node: ExprIf(_, _, Some(ref else_expr)), .. }) = get_parent_expr(cx, expr) {

clippy_lints/src/cyclomatic_complexity.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc::cfg::CFG;
44
use rustc::lint::*;
55
use rustc::ty;
66
use rustc::hir::*;
7-
use rustc::hir::intravisit::{Visitor, walk_expr};
7+
use rustc::hir::intravisit::{Visitor, walk_expr, NestedVisitorMap};
88
use syntax::ast::Attribute;
99
use syntax::attr;
1010
use syntax::codemap::Span;
@@ -42,7 +42,7 @@ impl LintPass for CyclomaticComplexity {
4242
}
4343

4444
impl CyclomaticComplexity {
45-
fn check<'a, 'tcx>(&mut self, cx: &'a LateContext<'a, 'tcx>, expr: &Expr, span: Span) {
45+
fn check<'a, 'tcx: 'a>(&mut self, cx: &'a LateContext<'a, 'tcx>, expr: &'tcx Expr, span: Span) {
4646
if in_macro(cx, span) {
4747
return;
4848
}
@@ -60,7 +60,7 @@ impl CyclomaticComplexity {
6060
divergence: 0,
6161
short_circuits: 0,
6262
returns: 0,
63-
tcx: &cx.tcx,
63+
cx: cx,
6464
};
6565
helper.visit_expr(expr);
6666
let CCHelper { match_arms, divergence, short_circuits, returns, .. } = helper;
@@ -91,44 +91,44 @@ impl CyclomaticComplexity {
9191
}
9292

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

102-
fn check_impl_item(&mut self, cx: &LateContext, item: &ImplItem) {
103-
if let ImplItemKind::Method(_, ref expr) = item.node {
104-
self.check(cx, expr, item.span);
102+
fn check_impl_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
103+
if let ImplItemKind::Method(_, eid) = item.node {
104+
self.check(cx, cx.tcx.map.expr(eid), item.span);
105105
}
106106
}
107107

108-
fn check_trait_item(&mut self, cx: &LateContext, item: &TraitItem) {
109-
if let MethodTraitItem(_, Some(ref expr)) = item.node {
110-
self.check(cx, expr, item.span);
108+
fn check_trait_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
109+
if let MethodTraitItem(_, Some(eid)) = item.node {
110+
self.check(cx, cx.tcx.map.expr(eid), item.span);
111111
}
112112
}
113113

114-
fn enter_lint_attrs(&mut self, cx: &LateContext, attrs: &[Attribute]) {
114+
fn enter_lint_attrs<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, attrs: &'tcx [Attribute]) {
115115
self.limit.push_attrs(cx.sess(), attrs, "cyclomatic_complexity");
116116
}
117-
fn exit_lint_attrs(&mut self, cx: &LateContext, attrs: &[Attribute]) {
117+
fn exit_lint_attrs<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, attrs: &'tcx [Attribute]) {
118118
self.limit.pop_attrs(cx.sess(), attrs, "cyclomatic_complexity");
119119
}
120120
}
121121

122-
struct CCHelper<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
122+
struct CCHelper<'a, 'tcx: 'a> {
123123
match_arms: u64,
124124
divergence: u64,
125125
returns: u64,
126126
short_circuits: u64, // && and ||
127-
tcx: &'a ty::TyCtxt<'a, 'gcx, 'tcx>,
127+
cx: &'a LateContext<'a, 'tcx>,
128128
}
129129

130-
impl<'a, 'b, 'tcx, 'gcx> Visitor<'a> for CCHelper<'b, 'gcx, 'tcx> {
131-
fn visit_expr(&mut self, e: &'a Expr) {
130+
impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> {
131+
fn visit_expr(&mut self, e: &'tcx Expr) {
132132
match e.node {
133133
ExprMatch(_, ref arms, _) => {
134134
walk_expr(self, e);
@@ -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.tables().node_id_to_type(callee.id);
142+
let ty = self.cx.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 => {
@@ -160,6 +160,9 @@ impl<'a, 'b, 'tcx, 'gcx> Visitor<'a> for CCHelper<'b, 'gcx, 'tcx> {
160160
_ => walk_expr(self, e),
161161
}
162162
}
163+
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
164+
NestedVisitorMap::None
165+
}
163166
}
164167

165168
#[cfg(feature="debugging")]

clippy_lints/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl LintPass for Derive {
7171
}
7272

7373
impl LateLintPass for Derive {
74-
fn check_item(&mut self, cx: &LateContext, item: &Item) {
74+
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
7575
if let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node {
7676
let ty = cx.tcx.item_type(cx.tcx.map.local_def_id(item.id));
7777
let is_automatically_derived = is_automatically_derived(&*item.attrs);

0 commit comments

Comments
 (0)