Skip to content

Commit 32a9394

Browse files
committed
Rustup
1 parent b7222be commit 32a9394

File tree

19 files changed

+118
-81
lines changed

19 files changed

+118
-81
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.160
5+
* Update to *rustc 1.22.0-nightly (dd08c3070 2017-09-12)*
6+
47
## 0.0.159
58
* Update to *rustc 1.22.0-nightly (eba374fb2 2017-09-11)*
69
* New lint: [`clone_on_ref_ptr`]

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.159"
3+
version = "0.0.160"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",
@@ -31,7 +31,7 @@ path = "src/main.rs"
3131

3232
[dependencies]
3333
# begin automatic update
34-
clippy_lints = { version = "0.0.159", path = "clippy_lints" }
34+
clippy_lints = { version = "0.0.160", 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.159"
4+
version = "0.0.160"
55
# end automatic update
66
authors = [
77
"Manish Goregaokar <[email protected]>",

clippy_lints/src/array_indexing.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_const_math::{ConstInt, ConstIsize, ConstUsize};
77
use rustc::hir;
88
use syntax::ast::RangeLimits;
99
use utils::{self, higher};
10+
use utils::const_to_u64;
1011

1112
/// **What it does:** Checks for out of bounds array indexing with a constant
1213
/// index.
@@ -63,21 +64,22 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing {
6364
let ty = cx.tables.expr_ty(array);
6465
if let ty::TyArray(_, size) = ty.sty {
6566
let size = ConstInt::Usize(
66-
ConstUsize::new(size as u64, cx.sess().target.uint_type).expect("array size is invalid"),
67+
ConstUsize::new(const_to_u64(size), cx.sess().target.usize_ty).expect("array size is invalid"),
6768
);
6869
let parent_item = cx.tcx.hir.get_parent(e.id);
6970
let parent_def_id = cx.tcx.hir.local_def_id(parent_item);
7071
let substs = Substs::identity_for_item(cx.tcx, parent_def_id);
7172
let constcx = ConstContext::new(cx.tcx, cx.param_env.and(substs), cx.tables);
7273

7374
// Index is a constant uint
74-
let const_index = constcx.eval(index);
75-
if let Ok(ConstVal::Integral(const_index)) = const_index {
76-
if size <= const_index {
77-
utils::span_lint(cx, OUT_OF_BOUNDS_INDEXING, e.span, "const index is out of bounds");
78-
}
75+
if let Ok(const_index) = constcx.eval(index) {
76+
if let ConstVal::Integral(const_index) = const_index.val {
77+
if size <= const_index {
78+
utils::span_lint(cx, OUT_OF_BOUNDS_INDEXING, e.span, "const index is out of bounds");
79+
}
7980

80-
return;
81+
return;
82+
}
8183
}
8284

8385
// Index is a constant range
@@ -112,19 +114,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing {
112114
/// Returns an option containing a tuple with the start and end (exclusive) of
113115
/// the range.
114116
fn to_const_range(
115-
start: &Option<Option<ConstVal>>,
116-
end: &Option<Option<ConstVal>>,
117+
start: &Option<Option<&ty::Const>>,
118+
end: &Option<Option<&ty::Const>>,
117119
limits: RangeLimits,
118120
array_size: ConstInt,
119121
) -> Option<(ConstInt, ConstInt)> {
120122
let start = match *start {
121-
Some(Some(ConstVal::Integral(x))) => x,
123+
Some(Some(&ty::Const { val: ConstVal::Integral(x), .. })) => x,
122124
Some(_) => return None,
123125
None => ConstInt::U8(0),
124126
};
125127

126128
let end = match *end {
127-
Some(Some(ConstVal::Integral(x))) => if limits == RangeLimits::Closed {
129+
Some(Some(&ty::Const { val: ConstVal::Integral(x), .. })) => if limits == RangeLimits::Closed {
128130
match x {
129131
ConstInt::U8(_) => (x + ConstInt::U8(1)),
130132
ConstInt::U16(_) => (x + ConstInt::U16(1)),

clippy_lints/src/consts.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::mem;
1414
use std::rc::Rc;
1515
use syntax::ast::{FloatTy, LitKind, StrStyle};
1616
use syntax::ptr::P;
17+
use utils::const_to_u64;
1718

1819
#[derive(Debug, Copy, Clone)]
1920
pub enum FloatWidth {
@@ -49,7 +50,7 @@ pub enum Constant {
4950
/// an array of constants
5051
Vec(Vec<Constant>),
5152
/// also an array, but with only one constant, repeated N times
52-
Repeat(Box<Constant>, usize),
53+
Repeat(Box<Constant>, u64),
5354
/// a tuple of constants
5455
Tuple(Vec<Constant>),
5556
}
@@ -175,10 +176,10 @@ pub fn lit_to_constant<'a, 'tcx>(lit: &LitKind, tcx: TyCtxt<'a, 'tcx, 'tcx>, mut
175176
LitKind::Char(c) => Constant::Char(c),
176177
LitKind::Int(n, hint) => match (&ty.sty, hint) {
177178
(&ty::TyInt(ity), _) | (_, Signed(ity)) => {
178-
Constant::Int(ConstInt::new_signed_truncating(n as i128, ity, tcx.sess.target.int_type))
179+
Constant::Int(ConstInt::new_signed_truncating(n as i128, ity, tcx.sess.target.isize_ty))
179180
},
180181
(&ty::TyUint(uty), _) | (_, Unsigned(uty)) => {
181-
Constant::Int(ConstInt::new_unsigned_truncating(n as u128, uty, tcx.sess.target.uint_type))
182+
Constant::Int(ConstInt::new_unsigned_truncating(n as u128, uty, tcx.sess.target.usize_ty))
182183
},
183184
_ => bug!(),
184185
},
@@ -249,7 +250,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
249250
ExprTup(ref tup) => self.multi(tup).map(Constant::Tuple),
250251
ExprRepeat(ref value, _) => {
251252
let n = match self.tables.expr_ty(e).sty {
252-
ty::TyArray(_, n) => n,
253+
ty::TyArray(_, n) => const_to_u64(n),
253254
_ => span_bug!(e.span, "typeck error"),
254255
};
255256
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n))

clippy_lints/src/derive.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,8 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
143143
// Some types are not Clone by default but could be cloned “by hand” if necessary
144144
ty::TyAdt(def, substs) => for variant in &def.variants {
145145
for field in &variant.fields {
146-
match field.ty(cx.tcx, substs).sty {
147-
ty::TyArray(_, size) if size > 32 => {
148-
return;
149-
},
150-
ty::TyFnPtr(..) => {
151-
return;
152-
},
153-
ty::TyTuple(tys, _) if tys.len() > 12 => {
154-
return;
155-
},
156-
_ => (),
146+
if let ty::TyFnDef(..) = field.ty(cx.tcx, substs).sty {
147+
return;
157148
}
158149
}
159150
},

clippy_lints/src/enum_clike.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
5555
.at(expr.span)
5656
.const_eval(param_env.and((did, substs)))
5757
{
58-
Ok(ConstVal::Integral(Usize(Us64(i)))) => u64::from(i as u32) != i,
59-
Ok(ConstVal::Integral(Isize(Is64(i)))) => i64::from(i as i32) != i,
58+
Ok(&ty::Const { val: ConstVal::Integral(Usize(Us64(i))), .. }) => u64::from(i as u32) != i,
59+
Ok(&ty::Const { val: ConstVal::Integral(Isize(Is64(i))), .. }) => i64::from(i as i32) != i,
6060
_ => false,
6161
};
6262
if bad {

clippy_lints/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![feature(slice_patterns)]
99
#![feature(stmt_expr_attributes)]
1010
#![feature(conservative_impl_trait)]
11+
#![feature(inclusive_range_syntax, range_contains)]
1112
#![allow(unknown_lints, indexing_slicing, shadow_reuse, missing_docs_in_private_items)]
1213

1314
#[macro_use]

clippy_lints/src/loops.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc_const_eval::ConstContext;
1313
use std::collections::{HashMap, HashSet};
1414
use syntax::ast;
1515
use utils::sugg;
16+
use utils::const_to_u64;
1617

1718
use utils::{get_enclosing_block, get_parent_expr, higher, in_external_macro, is_integer_literal, is_refutable,
1819
last_path_segment, match_trait_method, match_type, multispan_sugg, snippet, snippet_opt,
@@ -969,7 +970,7 @@ fn is_len_call(expr: &Expr, var: &Name) -> bool {
969970
false
970971
}
971972

972-
fn check_for_loop_reverse_range(cx: &LateContext, arg: &Expr, expr: &Expr) {
973+
fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx Expr, expr: &'tcx Expr) {
973974
// if this for loop is iterating over a two-sided range...
974975
if let Some(higher::Range {
975976
start: Some(start),
@@ -989,7 +990,7 @@ fn check_for_loop_reverse_range(cx: &LateContext, arg: &Expr, expr: &Expr) {
989990
// who think that this will iterate from the larger value to the
990991
// smaller value.
991992
let (sup, eq) = match (start_idx, end_idx) {
992-
(ConstVal::Integral(start_idx), ConstVal::Integral(end_idx)) => {
993+
(&ty::Const{ val: ConstVal::Integral(start_idx), .. }, &ty::Const{ val: ConstVal::Integral(end_idx), .. }) => {
993994
(start_idx > end_idx, start_idx == end_idx)
994995
},
995996
_ => (false, false),
@@ -1461,7 +1462,7 @@ fn is_ref_iterable_type(cx: &LateContext, e: &Expr) -> bool {
14611462
fn is_iterable_array(ty: Ty) -> bool {
14621463
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
14631464
match ty.sty {
1464-
ty::TyArray(_, 0...32) => true,
1465+
ty::TyArray(_, n) => (0...32).contains(const_to_u64(n)),
14651466
_ => false,
14661467
}
14671468
}

0 commit comments

Comments
 (0)