Skip to content

Commit a6c8464

Browse files
committed
Update to rustc 1.19.0-nightly (6a5fc9e 2017-05-02)
1 parent b84e71c commit a6c8464

38 files changed

+299
-987
lines changed

clippy_lints/src/booleans.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
386386
"this boolean expression can be simplified",
387387
|db| for suggestion in &improvements {
388388
db.span_suggestion(e.span, "try", suggest(self.cx, suggestion, &h2q.terminals));
389+
break; // FIXME: multiple suggestions in rustc are broken
389390
});
390391
}
391392
}

clippy_lints/src/eq_op.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
140140
if (requires_ref || rcpy) && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) {
141141
span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |db| {
142142
let rsnip = snippet(cx, r.span, "...").to_string();
143-
db.span_suggestion(left.span, "use the right value directly", rsnip);
143+
db.span_suggestion(right.span, "use the right value directly", rsnip);
144144
})
145145
}
146146
},

clippy_lints/src/escape.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
6565
_: &'tcx FnDecl,
6666
body: &'tcx Body,
6767
_: Span,
68-
_id: NodeId
68+
node_id: NodeId
6969
) {
7070
// we store the infcx because it is expensive to recreate
7171
// the context each time.
@@ -78,8 +78,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
7878
};
7979

8080
let infcx = cx.tcx.borrowck_fake_infer_ctxt(body.id());
81+
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
82+
let region_maps = &cx.tcx.region_maps(fn_def_id);
8183
{
82-
let mut vis = ExprUseVisitor::new(&mut v, &infcx);
84+
let mut vis = ExprUseVisitor::new(&mut v, region_maps, &infcx);
8385
vis.consume_body(body);
8486
}
8587

@@ -150,7 +152,7 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
150152
borrow_id: NodeId,
151153
_: Span,
152154
cmt: cmt<'tcx>,
153-
_: &ty::Region,
155+
_: ty::Region,
154156
_: ty::BorrowKind,
155157
loan_cause: LoanCause
156158
) {

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ fn check_len_zero(cx: &LateContext, span: Span, name: Name, args: &[Expr], lit:
173173
if name == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) {
174174
span_lint_and_then(cx, LEN_ZERO, span, "length comparison to zero", |db| {
175175
db.span_suggestion(span,
176-
"consider using `is_empty`",
176+
"using `is_empty` is more concise:",
177177
format!("{}{}.is_empty()", op, snippet(cx, args[0].span, "_")));
178178
});
179179
}

clippy_lints/src/loops.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,11 @@ fn check_for_loop_range<'a, 'tcx>(
509509

510510
// ensure that the indexed variable was declared before the loop, see #601
511511
if let Some(indexed_extent) = indexed_extent {
512-
let pat_extent = cx.tcx.region_maps.var_scope(pat.id);
513-
if cx.tcx.region_maps.is_subscope_of(indexed_extent, pat_extent) {
512+
let parent_id = cx.tcx.hir.get_parent(expr.id);
513+
let parent_def_id = cx.tcx.hir.local_def_id(parent_id);
514+
let region_maps = cx.tcx.region_maps(parent_def_id);
515+
let pat_extent = region_maps.var_scope(pat.id);
516+
if region_maps.is_subscope_of(indexed_extent, pat_extent) {
514517
return;
515518
}
516519
}
@@ -872,7 +875,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
872875
struct VarVisitor<'a, 'tcx: 'a> {
873876
cx: &'a LateContext<'a, 'tcx>, // context reference
874877
var: DefId, // var name to look for as index
875-
indexed: HashMap<Name, Option<CodeExtent>>, // indexed variables, the extent is None for global
878+
indexed: HashMap<Name, Option<CodeExtent<'tcx>>>, // indexed variables, the extent is None for global
876879
nonindex: bool, // has the var been used otherwise?
877880
}
878881

@@ -895,7 +898,9 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
895898
let def_id = def.def_id();
896899
let node_id = self.cx.tcx.hir.as_local_node_id(def_id).expect("local/upvar are local nodes");
897900

898-
let extent = self.cx.tcx.region_maps.var_scope(node_id);
901+
let parent_id = self.cx.tcx.hir.get_parent(expr.id);
902+
let parent_def_id = self.cx.tcx.hir.local_def_id(parent_id);
903+
let extent = self.cx.tcx.region_maps(parent_def_id).var_scope(node_id);
899904
self.indexed.insert(seqvar.segments[0].name, Some(extent));
900905
return; // no need to walk further
901906
}

clippy_lints/src/misc_early.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ impl EarlyLintPass for MiscEarly {
335335
"if you mean to use a decimal constant, remove the `0` to remove confusion:",
336336
src[1..].to_string(),
337337
);
338-
db.span_suggestion(
338+
/*db.span_suggestion(
339339
lit.span,
340340
"if you mean to use an octal constant, use `0o`:",
341341
format!("0o{}", &src[1..]),
342-
);
342+
); FIXME: rustc doesn't support multiple suggestions anymore */
343343
});
344344
}
345345
}}

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,20 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
8686
.collect()
8787
};
8888

89+
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
90+
8991
// Collect moved variables and spans which will need dereferencings from the function body.
9092
let MovedVariablesCtxt { moved_vars, spans_need_deref, .. } = {
9193
let mut ctx = MovedVariablesCtxt::new(cx);
9294
let infcx = cx.tcx.borrowck_fake_infer_ctxt(body.id());
95+
let region_maps = &cx.tcx.region_maps(fn_def_id);
9396
{
94-
let mut v = euv::ExprUseVisitor::new(&mut ctx, &infcx);
97+
let mut v = euv::ExprUseVisitor::new(&mut ctx, region_maps, &infcx);
9598
v.consume_body(body);
9699
}
97100
ctx
98101
};
99102

100-
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
101103
let param_env = ty::ParameterEnvironment::for_item(cx.tcx, node_id);
102104
let fn_sig = cx.tcx.type_of(fn_def_id).fn_sig();
103105
let fn_sig = cx.tcx.liberate_late_bound_regions(param_env.free_id_outlive, &fn_sig);
@@ -146,15 +148,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
146148
], {
147149
let slice_ty = format!("&[{}]", snippet(cx, elem_ty.span, "_"));
148150
db.span_suggestion(input.span,
149-
&format!("consider changing the type to `{}`", slice_ty),
151+
"consider changing the type to",
150152
slice_ty);
151153
assert!(deref_span.is_none());
152154
return; // `Vec` and `String` cannot be destructured - no need for `*` suggestion
153155
}}
154156

155157
if match_type(cx, ty, &paths::STRING) {
156158
db.span_suggestion(input.span,
157-
"consider changing the type to `&str`",
159+
"consider changing the type to",
158160
"&str".to_string());
159161
assert!(deref_span.is_none());
160162
return;
@@ -287,7 +289,7 @@ impl<'a, 'tcx: 'a> euv::Delegate<'tcx> for MovedVariablesCtxt<'a, 'tcx> {
287289
_: NodeId,
288290
_: Span,
289291
_: mc::cmt<'tcx>,
290-
_: &'tcx ty::Region,
292+
_: ty::Region,
291293
_: ty::BorrowKind,
292294
_: euv::LoanCause
293295
) {

tests/ui/assign_ops.stderr

Lines changed: 21 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,200 +2,139 @@ error: assign operation detected
22
--> $DIR/assign_ops.rs:8:5
33
|
44
8 | i += 2;
5-
| ^^^^^^
5+
| ^^^^^^ help: replace it with `i = i + 2`
66
|
77
note: lint level defined here
88
--> $DIR/assign_ops.rs:4:8
99
|
1010
4 | #[deny(assign_ops)]
1111
| ^^^^^^^^^^
12-
help: replace it with
13-
| i = i + 2;
1412

1513
error: assign operation detected
1614
--> $DIR/assign_ops.rs:11:5
1715
|
1816
11 | i += 2 + 17;
19-
| ^^^^^^^^^^^
20-
|
21-
help: replace it with
22-
| i = i + 2 + 17;
17+
| ^^^^^^^^^^^ help: replace it with `i = i + 2 + 17`
2318

2419
error: assign operation detected
2520
--> $DIR/assign_ops.rs:14:5
2621
|
2722
14 | i -= 6;
28-
| ^^^^^^
29-
|
30-
help: replace it with
31-
| i = i - 6;
23+
| ^^^^^^ help: replace it with `i = i - 6`
3224

3325
error: assign operation detected
3426
--> $DIR/assign_ops.rs:17:5
3527
|
3628
17 | i -= 2 - 1;
37-
| ^^^^^^^^^^
38-
|
39-
help: replace it with
40-
| i = i - (2 - 1);
29+
| ^^^^^^^^^^ help: replace it with `i = i - (2 - 1)`
4130

4231
error: assign operation detected
4332
--> $DIR/assign_ops.rs:21:5
4433
|
4534
21 | i *= 5;
46-
| ^^^^^^
47-
|
48-
help: replace it with
49-
| i = i * 5;
35+
| ^^^^^^ help: replace it with `i = i * 5`
5036

5137
error: assign operation detected
5238
--> $DIR/assign_ops.rs:24:5
5339
|
5440
24 | i *= 1+5;
55-
| ^^^^^^^^
56-
|
57-
help: replace it with
58-
| i = i * (1+5);
41+
| ^^^^^^^^ help: replace it with `i = i * (1+5)`
5942

6043
error: assign operation detected
6144
--> $DIR/assign_ops.rs:27:5
6245
|
6346
27 | i /= 32;
64-
| ^^^^^^^
65-
|
66-
help: replace it with
67-
| i = i / 32;
47+
| ^^^^^^^ help: replace it with `i = i / 32`
6848

6949
error: assign operation detected
7050
--> $DIR/assign_ops.rs:30:5
7151
|
7252
30 | i /= 32 | 5;
73-
| ^^^^^^^^^^^
74-
|
75-
help: replace it with
76-
| i = i / (32 | 5);
53+
| ^^^^^^^^^^^ help: replace it with `i = i / (32 | 5)`
7754

7855
error: assign operation detected
7956
--> $DIR/assign_ops.rs:33:5
8057
|
8158
33 | i /= 32 / 5;
82-
| ^^^^^^^^^^^
83-
|
84-
help: replace it with
85-
| i = i / (32 / 5);
59+
| ^^^^^^^^^^^ help: replace it with `i = i / (32 / 5)`
8660

8761
error: assign operation detected
8862
--> $DIR/assign_ops.rs:36:5
8963
|
9064
36 | i %= 42;
91-
| ^^^^^^^
92-
|
93-
help: replace it with
94-
| i = i % 42;
65+
| ^^^^^^^ help: replace it with `i = i % 42`
9566

9667
error: assign operation detected
9768
--> $DIR/assign_ops.rs:39:5
9869
|
9970
39 | i >>= i;
100-
| ^^^^^^^
101-
|
102-
help: replace it with
103-
| i = i >> i;
71+
| ^^^^^^^ help: replace it with `i = i >> i`
10472

10573
error: assign operation detected
10674
--> $DIR/assign_ops.rs:42:5
10775
|
10876
42 | i <<= 9 + 6 - 7;
109-
| ^^^^^^^^^^^^^^^
110-
|
111-
help: replace it with
112-
| i = i << (9 + 6 - 7);
77+
| ^^^^^^^^^^^^^^^ help: replace it with `i = i << (9 + 6 - 7)`
11378

11479
error: assign operation detected
11580
--> $DIR/assign_ops.rs:45:5
11681
|
11782
45 | i += 1 << 5;
118-
| ^^^^^^^^^^^
119-
|
120-
help: replace it with
121-
| i = i + (1 << 5);
83+
| ^^^^^^^^^^^ help: replace it with `i = i + (1 << 5)`
12284

12385
error: manual implementation of an assign operation
12486
--> $DIR/assign_ops.rs:55:5
12587
|
12688
55 | a = a + 1;
127-
| ^^^^^^^^^
89+
| ^^^^^^^^^ help: replace it with `a += 1`
12890
|
12991
note: lint level defined here
13092
--> $DIR/assign_ops.rs:52:8
13193
|
13294
52 | #[deny(assign_op_pattern)]
13395
| ^^^^^^^^^^^^^^^^^
134-
help: replace it with
135-
| a += 1;
13696

13797
error: manual implementation of an assign operation
13898
--> $DIR/assign_ops.rs:58:5
13999
|
140100
58 | a = 1 + a;
141-
| ^^^^^^^^^
142-
|
143-
help: replace it with
144-
| a += 1;
101+
| ^^^^^^^^^ help: replace it with `a += 1`
145102

146103
error: manual implementation of an assign operation
147104
--> $DIR/assign_ops.rs:61:5
148105
|
149106
61 | a = a - 1;
150-
| ^^^^^^^^^
151-
|
152-
help: replace it with
153-
| a -= 1;
107+
| ^^^^^^^^^ help: replace it with `a -= 1`
154108

155109
error: manual implementation of an assign operation
156110
--> $DIR/assign_ops.rs:64:5
157111
|
158112
64 | a = a * 99;
159-
| ^^^^^^^^^^
160-
|
161-
help: replace it with
162-
| a *= 99;
113+
| ^^^^^^^^^^ help: replace it with `a *= 99`
163114

164115
error: manual implementation of an assign operation
165116
--> $DIR/assign_ops.rs:67:5
166117
|
167118
67 | a = 42 * a;
168-
| ^^^^^^^^^^
169-
|
170-
help: replace it with
171-
| a *= 42;
119+
| ^^^^^^^^^^ help: replace it with `a *= 42`
172120

173121
error: manual implementation of an assign operation
174122
--> $DIR/assign_ops.rs:70:5
175123
|
176124
70 | a = a / 2;
177-
| ^^^^^^^^^
178-
|
179-
help: replace it with
180-
| a /= 2;
125+
| ^^^^^^^^^ help: replace it with `a /= 2`
181126

182127
error: manual implementation of an assign operation
183128
--> $DIR/assign_ops.rs:73:5
184129
|
185130
73 | a = a % 5;
186-
| ^^^^^^^^^
187-
|
188-
help: replace it with
189-
| a %= 5;
131+
| ^^^^^^^^^ help: replace it with `a %= 5`
190132

191133
error: manual implementation of an assign operation
192134
--> $DIR/assign_ops.rs:76:5
193135
|
194136
76 | a = a & 1;
195-
| ^^^^^^^^^
196-
|
197-
help: replace it with
198-
| a &= 1;
137+
| ^^^^^^^^^ help: replace it with `a &= 1`
199138

200139
error: aborting due to 21 previous errors
201140

0 commit comments

Comments
 (0)