Skip to content

Commit 8b00f82

Browse files
committed
Merge branch 'master' into never_loop
2 parents 4f37482 + 55cb63a commit 8b00f82

Some content is hidden

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

46 files changed

+427
-408
lines changed

CHANGELOG.md

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

4-
## 0.0.136 - 2017-05-26
4+
## 0.0.139 — 2017-06-10
5+
* Update to *rustc 1.19.0-nightly (4bf5c99af 2017-06-10)*
6+
* Fix bugs with for loop desugaring
7+
* Check for AsRef/AsMut arguments in wrong_self_convention
8+
9+
## 0.0.138 — 2017-06-05
10+
* Update to *rustc 1.19.0-nightly (0418fa9d3 2017-06-04)*
11+
12+
## 0.0.137 — 2017-06-05
13+
* Update to *rustc 1.19.0-nightly (6684d176c 2017-06-03)*
14+
15+
## 0.0.136 — 2017—05—26
516
* Update to *rustc 1.19.0-nightly (557967766 2017-05-26)*
617

7-
## 0.0.135 - 2017-05-24
18+
## 0.0.135 2017—05—24
819
* Update to *rustc 1.19.0-nightly (5b13bff52 2017-05-23)*
920

10-
## 0.0.134 - 2017-05-19
21+
## 0.0.134 2017—05—19
1122
* Update to *rustc 1.19.0-nightly (0ed1ec9f9 2017-05-18)*
1223

13-
## 0.0.133 - 2017-05-14
24+
## 0.0.133 2017—05—14
1425
* Update to *rustc 1.19.0-nightly (826d8f385 2017-05-13)*
1526

16-
## 0.0.132 - 2017-05-05
27+
## 0.0.132 2017—05—05
1728
* Fix various bugs and some ices
1829

19-
## 0.0.131 - 2017-05-04
30+
## 0.0.131 2017—05—04
2031
* Update to *rustc 1.19.0-nightly (2d4ed8e0c 2017-05-03)*
2132

22-
## 0.0.130 - 2017-05-03
33+
## 0.0.130 2017—05—03
2334
* Update to *rustc 1.19.0-nightly (6a5fc9eec 2017-05-02)*
2435

2536
## 0.0.129 — 2017-05-01

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.136"
3+
version = "0.0.139"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",
@@ -31,7 +31,7 @@ test = false
3131

3232
[dependencies]
3333
# begin automatic update
34-
clippy_lints = { version = "0.0.136", path = "clippy_lints" }
34+
clippy_lints = { version = "0.0.139", path = "clippy_lints" }
3535
# end automatic update
3636
cargo_metadata = "0.2"
3737

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

clippy_lints/src/assign_ops.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
8282
if let hir::ExprBinary(binop, ref l, ref r) = rhs.node {
8383
if op.node == binop.node {
8484
let lint = |assignee: &hir::Expr, rhs: &hir::Expr| {
85-
let ty = cx.tables.expr_ty(assignee);
86-
if ty.walk_shallow().next().is_some() {
87-
return; // implements_trait does not work with generics
88-
}
89-
let rty = cx.tables.expr_ty(rhs);
90-
if rty.walk_shallow().next().is_some() {
91-
return; // implements_trait does not work with generics
92-
}
9385
span_lint_and_then(cx,
9486
MISREFACTORED_ASSIGN_OP,
9587
expr.span,
@@ -120,13 +112,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
120112
#[allow(cyclomatic_complexity)]
121113
let lint = |assignee: &hir::Expr, rhs: &hir::Expr| {
122114
let ty = cx.tables.expr_ty(assignee);
123-
if ty.walk_shallow().next().is_some() {
124-
return; // implements_trait does not work with generics
125-
}
126115
let rty = cx.tables.expr_ty(rhs);
127-
if rty.walk_shallow().next().is_some() {
128-
return; // implements_trait does not work with generics
129-
}
130116
macro_rules! ops {
131117
($op:expr,
132118
$cx:expr,
@@ -152,7 +138,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
152138
let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = item.node,
153139
trait_ref.path.def.def_id() == trait_id
154140
], { return; }}
155-
implements_trait($cx, $ty, trait_id, &[$rty], None)
141+
implements_trait($cx, $ty, trait_id, &[$rty])
156142
},)*
157143
_ => false,
158144
}

clippy_lints/src/attrs.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use reexport::*;
44
use rustc::lint::*;
55
use rustc::hir::*;
6-
use rustc::ty;
6+
use rustc::ty::{self, TyCtxt};
77
use semver::Version;
88
use syntax::ast::{Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
99
use syntax::codemap::Span;
@@ -158,22 +158,22 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
158158
}
159159
}
160160

161-
fn is_relevant_item(tcx: ty::TyCtxt, item: &Item) -> bool {
161+
fn is_relevant_item(tcx: TyCtxt, item: &Item) -> bool {
162162
if let ItemFn(_, _, _, _, _, eid) = item.node {
163163
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
164164
} else {
165165
false
166166
}
167167
}
168168

169-
fn is_relevant_impl(tcx: ty::TyCtxt, item: &ImplItem) -> bool {
169+
fn is_relevant_impl(tcx: TyCtxt, item: &ImplItem) -> bool {
170170
match item.node {
171171
ImplItemKind::Method(_, eid) => is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value),
172172
_ => false,
173173
}
174174
}
175175

176-
fn is_relevant_trait(tcx: ty::TyCtxt, item: &TraitItem) -> bool {
176+
fn is_relevant_trait(tcx: TyCtxt, item: &TraitItem) -> bool {
177177
match item.node {
178178
TraitItemKind::Method(_, TraitMethod::Required(_)) => true,
179179
TraitItemKind::Method(_, TraitMethod::Provided(eid)) => {
@@ -183,7 +183,7 @@ fn is_relevant_trait(tcx: ty::TyCtxt, item: &TraitItem) -> bool {
183183
}
184184
}
185185

186-
fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::TypeckTables, block: &Block) -> bool {
186+
fn is_relevant_block(tcx: TyCtxt, tables: &ty::TypeckTables, block: &Block) -> bool {
187187
if let Some(stmt) = block.stmts.first() {
188188
match stmt.node {
189189
StmtDecl(_, _) => true,
@@ -195,7 +195,7 @@ fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::TypeckTables, block: &Block)
195195
}
196196
}
197197

198-
fn is_relevant_expr(tcx: ty::TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool {
198+
fn is_relevant_expr(tcx: TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool {
199199
match expr.node {
200200
ExprBlock(ref block) => is_relevant_block(tcx, tables, block),
201201
ExprRet(Some(ref e)) => is_relevant_expr(tcx, tables, e),

clippy_lints/src/booleans.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,12 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
385385
e.span,
386386
"this boolean expression can be simplified",
387387
|db| {
388-
db.span_suggestions(e.span, "try", improvements.into_iter().map(|suggestion| {
389-
suggest(self.cx, suggestion, &h2q.terminals)
390-
}).collect());
391-
});
388+
db.span_suggestions(e.span,
389+
"try",
390+
improvements.into_iter()
391+
.map(|suggestion| suggest(self.cx, suggestion, &h2q.terminals))
392+
.collect());
393+
});
392394
}
393395
}
394396
}

clippy_lints/src/consts.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc::hir::def::Def;
55
use rustc_const_eval::lookup_const_by_id;
66
use rustc_const_math::ConstInt;
77
use rustc::hir::*;
8-
use rustc::ty::{self, TyCtxt};
8+
use rustc::ty::{self, TyCtxt, Ty};
99
use rustc::ty::subst::{Substs, Subst};
1010
use std::cmp::Ordering::{self, Equal};
1111
use std::cmp::PartialOrd;
@@ -161,7 +161,7 @@ impl PartialOrd for Constant {
161161

162162
/// parse a `LitKind` to a `Constant`
163163
#[allow(cast_possible_wrap)]
164-
pub fn lit_to_constant<'a, 'tcx>(lit: &LitKind, tcx: TyCtxt<'a, 'tcx, 'tcx>, mut ty: ty::Ty<'tcx>) -> Constant {
164+
pub fn lit_to_constant<'a, 'tcx>(lit: &LitKind, tcx: TyCtxt<'a, 'tcx, 'tcx>, mut ty: Ty<'tcx>) -> Constant {
165165
use syntax::ast::*;
166166
use syntax::ast::LitIntType::*;
167167
use rustc::ty::util::IntTypeExt;
@@ -286,9 +286,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
286286
match def {
287287
Def::Const(def_id) |
288288
Def::AssociatedConst(def_id) => {
289-
let substs = self.tables
290-
.node_id_item_substs(id)
291-
.unwrap_or_else(|| self.tcx.intern_substs(&[]));
289+
let substs = self.tables.node_substs(id);
292290
let substs = if self.substs.is_empty() {
293291
substs
294292
} else {

clippy_lints/src/copies.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc::lint::*;
2-
use rustc::ty;
2+
use rustc::ty::Ty;
33
use rustc::hir::*;
44
use std::collections::HashMap;
55
use std::collections::hash_map::Entry;
@@ -251,12 +251,8 @@ fn if_sequence(mut expr: &Expr) -> (SmallVector<&Expr>, SmallVector<&Block>) {
251251
}
252252

253253
/// Return the list of bindings in a pattern.
254-
fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<InternedString, ty::Ty<'tcx>> {
255-
fn bindings_impl<'a, 'tcx>(
256-
cx: &LateContext<'a, 'tcx>,
257-
pat: &Pat,
258-
map: &mut HashMap<InternedString, ty::Ty<'tcx>>
259-
) {
254+
fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<InternedString, Ty<'tcx>> {
255+
fn bindings_impl<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat, map: &mut HashMap<InternedString, Ty<'tcx>>) {
260256
match pat.node {
261257
PatKind::Box(ref pat) |
262258
PatKind::Ref(ref pat, _) => bindings_impl(cx, pat, map),

clippy_lints/src/derive.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc::lint::*;
2-
use rustc::ty::TypeVariants;
3-
use rustc::ty;
2+
use rustc::ty::{self, Ty};
43
use rustc::hir::*;
54
use syntax::codemap::Span;
65
use utils::paths;
@@ -89,7 +88,7 @@ fn check_hash_peq<'a, 'tcx>(
8988
cx: &LateContext<'a, 'tcx>,
9089
span: Span,
9190
trait_ref: &TraitRef,
92-
ty: ty::Ty<'tcx>,
91+
ty: Ty<'tcx>,
9392
hash_is_automatically_derived: bool
9493
) {
9594
if_let_chain! {[
@@ -134,28 +133,27 @@ fn check_hash_peq<'a, 'tcx>(
134133
}
135134

136135
/// Implementation of the `EXPL_IMPL_CLONE_ON_COPY` lint.
137-
fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref: &TraitRef, ty: ty::Ty<'tcx>) {
136+
fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref: &TraitRef, ty: Ty<'tcx>) {
138137
if match_path_old(&trait_ref.path, &paths::CLONE_TRAIT) {
139-
let def_id = cx.tcx.hir.local_def_id(item.id);
140-
if !is_copy(cx, ty, def_id) {
138+
if !is_copy(cx, ty) {
141139
return;
142140
}
143141

144142
match ty.sty {
145-
TypeVariants::TyAdt(def, _) if def.is_union() => return,
143+
ty::TyAdt(def, _) if def.is_union() => return,
146144

147145
// Some types are not Clone by default but could be cloned “by hand” if necessary
148-
TypeVariants::TyAdt(def, substs) => {
146+
ty::TyAdt(def, substs) => {
149147
for variant in &def.variants {
150148
for field in &variant.fields {
151149
match field.ty(cx.tcx, substs).sty {
152-
TypeVariants::TyArray(_, size) if size > 32 => {
150+
ty::TyArray(_, size) if size > 32 => {
153151
return;
154152
},
155-
TypeVariants::TyFnPtr(..) => {
153+
ty::TyFnPtr(..) => {
156154
return;
157155
},
158-
TypeVariants::TyTuple(tys, _) if tys.len() > 12 => {
156+
ty::TyTuple(tys, _) if tys.len() > 12 => {
159157
return;
160158
},
161159
_ => (),

clippy_lints/src/drop_forget_ref.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
135135
expr.span,
136136
&msg,
137137
arg.span,
138-
&format!("argument has type {}", arg_ty.sty));
139-
} else if is_copy(cx, arg_ty, cx.tcx.hir.local_def_id(cx.tcx.hir.get_parent(arg.id))) {
138+
&format!("argument has type {}", arg_ty));
139+
} else if is_copy(cx, arg_ty) {
140140
if match_def_path(cx.tcx, def_id, &paths::DROP) {
141141
lint = DROP_COPY;
142142
msg = DROP_COPY_SUMMARY.to_string();
@@ -151,7 +151,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
151151
expr.span,
152152
&msg,
153153
arg.span,
154-
&format!("argument has type {}", arg_ty.sty));
154+
&format!("argument has type {}", arg_ty));
155155
}
156156
}}
157157
}

clippy_lints/src/enum_glob_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EnumGlobUse {
3636
fn check_mod(&mut self, cx: &LateContext<'a, 'tcx>, m: &'tcx Mod, _: Span, _: NodeId) {
3737
// only check top level `use` statements
3838
for item in &m.item_ids {
39-
self.lint_item(cx, cx.krate.item(item.id));
39+
self.lint_item(cx, cx.tcx.hir.expect_item(item.id));
4040
}
4141
}
4242
}

clippy_lints/src/eq_op.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
7575
BiNe | BiEq => (cx.tcx.lang_items.eq_trait(), true),
7676
BiLt | BiLe | BiGe | BiGt => (cx.tcx.lang_items.ord_trait(), true),
7777
};
78-
let parent = cx.tcx.hir.get_parent(e.id);
79-
let parent = cx.tcx.hir.local_def_id(parent);
8078
if let Some(trait_id) = trait_id {
8179
#[allow(match_same_arms)]
8280
match (&left.node, &right.node) {
@@ -87,10 +85,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
8785
(&ExprAddrOf(_, ref l), &ExprAddrOf(_, ref r)) => {
8886
let lty = cx.tables.expr_ty(l);
8987
let rty = cx.tables.expr_ty(r);
90-
let lcpy = is_copy(cx, lty, parent);
91-
let rcpy = is_copy(cx, rty, parent);
88+
let lcpy = is_copy(cx, lty);
89+
let rcpy = is_copy(cx, rty);
9290
// either operator autorefs or both args are copyable
93-
if (requires_ref || (lcpy && rcpy)) && implements_trait(cx, lty, trait_id, &[rty], None) {
91+
if (requires_ref || (lcpy && rcpy)) && implements_trait(cx, lty, trait_id, &[rty]) {
9492
span_lint_and_then(cx,
9593
OP_REF,
9694
e.span,
@@ -100,17 +98,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
10098
let rsnip = snippet(cx, r.span, "...").to_string();
10199
multispan_sugg(db,
102100
"use the values directly".to_string(),
103-
vec![(left.span, lsnip),
104-
(right.span, rsnip)]);
101+
vec![(left.span, lsnip), (right.span, rsnip)]);
105102
})
106-
} else if lcpy && !rcpy &&
107-
implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
103+
} else if lcpy && !rcpy && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)]) {
108104
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
109105
let lsnip = snippet(cx, l.span, "...").to_string();
110106
db.span_suggestion(left.span, "use the left value directly", lsnip);
111107
})
112-
} else if !lcpy && rcpy &&
113-
implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) {
108+
} else if !lcpy && rcpy && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty]) {
114109
span_lint_and_then(cx,
115110
OP_REF,
116111
e.span,
@@ -124,9 +119,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
124119
// &foo == bar
125120
(&ExprAddrOf(_, ref l), _) => {
126121
let lty = cx.tables.expr_ty(l);
127-
let lcpy = is_copy(cx, lty, parent);
128-
if (requires_ref || lcpy) &&
129-
implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
122+
let lcpy = is_copy(cx, lty);
123+
if (requires_ref || lcpy) && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)]) {
130124
span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
131125
let lsnip = snippet(cx, l.span, "...").to_string();
132126
db.span_suggestion(left.span, "use the left value directly", lsnip);
@@ -136,9 +130,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
136130
// foo == &bar
137131
(_, &ExprAddrOf(_, ref r)) => {
138132
let rty = cx.tables.expr_ty(r);
139-
let rcpy = is_copy(cx, rty, parent);
140-
if (requires_ref || rcpy) &&
141-
implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) {
133+
let rcpy = is_copy(cx, rty);
134+
if (requires_ref || rcpy) && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty]) {
142135
span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |db| {
143136
let rsnip = snippet(cx, r.span, "...").to_string();
144137
db.span_suggestion(right.span, "use the right value directly", rsnip);

0 commit comments

Comments
 (0)