Skip to content

Commit ef7ff03

Browse files
authored
Merge pull request #1715 from Manishearth/rustup
Update to latest nightly
2 parents 676fff3 + 1522a49 commit ef7ff03

Some content is hidden

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

44 files changed

+393
-1101
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.130 - 2017-05-01
5+
* Update to *rustc 1.19.0-nightly (6a5fc9eec 2017-05-02)*
6+
47
## 0.0.129 — 2017-05-01
58
* Update to *rustc 1.19.0-nightly (06fb4d256 2017-04-30)*
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.129"
3+
version = "0.0.130"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",
@@ -30,7 +30,7 @@ test = false
3030

3131
[dependencies]
3232
# begin automatic update
33-
clippy_lints = { version = "0.0.129", path = "clippy_lints" }
33+
clippy_lints = { version = "0.0.130", path = "clippy_lints" }
3434
# end automatic update
3535
cargo_metadata = "0.1.1"
3636

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

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/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
299299
tcx: self.tcx,
300300
tables: self.tcx.typeck_tables_of(def_id),
301301
needed_resolution: false,
302-
substs,
302+
substs: substs,
303303
};
304304
let body = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
305305
self.tcx.mir_const_qualif(def_id);

clippy_lints/src/eq_op.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
5454
if let ExprBinary(ref op, ref left, ref right) = e.node {
5555
if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) {
5656
span_lint(cx,
57-
EQ_OP,
58-
e.span,
59-
&format!("equal expressions as operands to `{}`", op.node.as_str()));
57+
EQ_OP,
58+
e.span,
59+
&format!("equal expressions as operands to `{}`", op.node.as_str()));
6060
return;
6161
}
6262
let (trait_id, requires_ref) = match op.node {
@@ -91,32 +91,30 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
9191
// either operator autorefs or both args are copyable
9292
if (requires_ref || (lcpy && rcpy)) && implements_trait(cx, lty, trait_id, &[rty], None) {
9393
span_lint_and_then(cx,
94-
OP_REF,
95-
e.span,
96-
"needlessly taken reference of both operands",
97-
|db| {
94+
OP_REF,
95+
e.span,
96+
"needlessly taken reference of both operands",
97+
|db| {
9898
let lsnip = snippet(cx, l.span, "...").to_string();
9999
let rsnip = snippet(cx, r.span, "...").to_string();
100100
multispan_sugg(db,
101-
"use the values directly".to_string(),
102-
vec![(left.span, lsnip),
101+
"use the values directly".to_string(),
102+
vec![(left.span, lsnip),
103103
(right.span, rsnip)]);
104104
})
105-
} else if lcpy && !rcpy && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
106-
span_lint_and_then(cx,
107-
OP_REF,
108-
e.span,
109-
"needlessly taken reference of left operand",
110-
|db| {
105+
} else if lcpy && !rcpy &&
106+
implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
107+
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
111108
let lsnip = snippet(cx, l.span, "...").to_string();
112109
db.span_suggestion(left.span, "use the left value directly", lsnip);
113110
})
114-
} else if !lcpy && rcpy && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) {
111+
} else if !lcpy && rcpy &&
112+
implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) {
115113
span_lint_and_then(cx,
116-
OP_REF,
117-
e.span,
118-
"needlessly taken reference of right operand",
119-
|db| {
114+
OP_REF,
115+
e.span,
116+
"needlessly taken reference of right operand",
117+
|db| {
120118
let rsnip = snippet(cx, r.span, "...").to_string();
121119
db.span_suggestion(right.span, "use the right value directly", rsnip);
122120
})
@@ -126,7 +124,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
126124
(&ExprAddrOf(_, ref l), _) => {
127125
let lty = cx.tables.expr_ty(l);
128126
let lcpy = is_copy(cx, lty, parent);
129-
if (requires_ref || lcpy) && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
127+
if (requires_ref || lcpy) &&
128+
implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
130129
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
131130
let lsnip = snippet(cx, l.span, "...").to_string();
132131
db.span_suggestion(left.span, "use the left value directly", lsnip);
@@ -137,10 +136,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
137136
(_, &ExprAddrOf(_, ref r)) => {
138137
let rty = cx.tables.expr_ty(r);
139138
let rcpy = is_copy(cx, rty, parent);
140-
if (requires_ref || rcpy) && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) {
139+
if (requires_ref || rcpy) &&
140+
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: 3 additions & 2 deletions
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
}
@@ -199,7 +199,8 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
199199

200200
/// Check the inherent impl's items for an `is_empty(self)` method.
201201
fn has_is_empty_impl(cx: &LateContext, id: DefId) -> bool {
202-
cx.tcx.inherent_impls(id)
202+
cx.tcx
203+
.inherent_impls(id)
203204
.iter()
204205
.any(|imp| cx.tcx.associated_items(*imp).any(|item| is_is_empty(cx, &item)))
205206
}

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
}}

0 commit comments

Comments
 (0)