Skip to content

Commit ea0227f

Browse files
authored
Merge pull request #1373 from Manishearth/rustup
WIP: rustup
2 parents f9fe50d + 4fcefe2 commit ea0227f

Some content is hidden

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

80 files changed

+1038
-797
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.104 — 2016-12-15
5+
* Update to *rustc 1.15.0-nightly (8f02c429a 2016-12-15)*
6+
47
## 0.0.103 — 2016-11-25
58
* Update to *rustc 1.15.0-nightly (d5814b03e 2016-11-23)*
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.103"
3+
version = "0.0.104"
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.103", path = "clippy_lints" }
28+
clippy_lints = { version = "0.0.104", 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.103"
4+
version = "0.0.104"
55
# end automatic update
66
authors = [
77
"Manish Goregaokar <[email protected]>",

clippy_lints/src/approx_const.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ impl LintPass for Pass {
5959
}
6060
}
6161

62-
impl LateLintPass for Pass {
63-
fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
62+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
63+
fn check_expr(&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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ impl LintPass for Arithmetic {
4747
}
4848
}
4949

50-
impl LateLintPass for Arithmetic {
51-
fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) {
50+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
51+
fn check_expr(&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(&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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ impl LintPass for ArrayIndexing {
5555
}
5656
}
5757

58-
impl LateLintPass for ArrayIndexing {
59-
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
58+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing {
59+
fn check_expr(&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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ impl LintPass for AssignOps {
6666
}
6767
}
6868

69-
impl LateLintPass for AssignOps {
70-
fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) {
69+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
70+
fn check_expr(&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: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ impl LintPass for AttrPass {
8181
}
8282
}
8383

84-
impl LateLintPass for AttrPass {
85-
fn check_attribute(&mut self, cx: &LateContext, attr: &Attribute) {
84+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
85+
fn check_attribute(&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,21 +99,21 @@ impl LateLintPass for AttrPass {
9999
}
100100
}
101101

102-
fn check_item(&mut self, cx: &LateContext, item: &Item) {
102+
fn check_item(&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
}
106106
match item.node {
107107
ItemExternCrate(_) |
108-
ItemUse(_) => {
108+
ItemUse(_, _) => {
109109
for attr in &item.attrs {
110110
if let MetaItemKind::List(ref lint_list) = attr.value.node {
111111
match &*attr.name().as_str() {
112112
"allow" | "warn" | "deny" | "forbid" => {
113113
// whitelist `unused_imports`
114114
for lint in lint_list {
115115
if is_word(lint, "unused_imports") {
116-
if let ItemUse(_) = item.node {
116+
if let ItemUse(_, _) = item.node {
117117
return;
118118
}
119119
}
@@ -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(&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(&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
}
@@ -193,8 +193,8 @@ fn is_relevant_expr(cx: &LateContext, expr: &Expr) -> bool {
193193
ExprRet(Some(ref e)) => is_relevant_expr(cx, e),
194194
ExprRet(None) | ExprBreak(_, None) => false,
195195
ExprCall(ref path_expr, _) => {
196-
if let ExprPath(..) = path_expr.node {
197-
let fun_id = resolve_node(cx, path_expr.id).expect("function should be resolved").def_id();
196+
if let ExprPath(ref qpath) = path_expr.node {
197+
let fun_id = resolve_node(cx, qpath, path_expr.id).def_id();
198198
!match_def_path(cx, fun_id, &paths::BEGIN_PANIC)
199199
} else {
200200
true

clippy_lints/src/bit_mask.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc::hir::*;
2-
use rustc::hir::def::{Def, PathResolution};
2+
use rustc::hir::def::Def;
33
use rustc::lint::*;
44
use rustc_const_eval::lookup_const_by_id;
55
use syntax::ast::LitKind;
@@ -79,8 +79,8 @@ impl LintPass for BitMask {
7979
}
8080
}
8181

82-
impl LateLintPass for BitMask {
83-
fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
82+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
83+
fn check_expr(&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) {
@@ -245,18 +245,13 @@ fn fetch_int_literal(cx: &LateContext, lit: &Expr) -> Option<u64> {
245245
None
246246
}
247247
}
248-
ExprPath(_, _) => {
249-
{
250-
// Important to let the borrow expire before the const lookup to avoid double
251-
// borrowing.
252-
let def_map = cx.tcx.def_map.borrow();
253-
match def_map.get(&lit.id) {
254-
Some(&PathResolution { base_def: Def::Const(def_id), .. }) => Some(def_id),
255-
_ => None,
256-
}
248+
ExprPath(ref qpath) => {
249+
let def = cx.tcx.tables().qpath_def(qpath, lit.id);
250+
if let Def::Const(def_id) = def {
251+
lookup_const_by_id(cx.tcx, def_id, None).and_then(|(l, _ty)| fetch_int_literal(cx, l))
252+
} else {
253+
None
257254
}
258-
.and_then(|def_id| lookup_const_by_id(cx.tcx, def_id, None))
259-
.and_then(|(l, _ty)| fetch_int_literal(cx, l))
260255
}
261256
_ => None,
262257
}

clippy_lints/src/blacklisted_name.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ impl LintPass for BlackListedName {
3737
}
3838
}
3939

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

0 commit comments

Comments
 (0)