Skip to content

Commit 26b48bb

Browse files
committed
Rustup to 2018-05-13
1 parent 18a5b90 commit 26b48bb

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

clippy_lints/src/array_indexing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing {
6161
// Array with known size can be checked statically
6262
let ty = cx.tables.expr_ty(array);
6363
if let ty::TyArray(_, size) = ty.sty {
64-
let size = size.val.to_raw_bits().unwrap();
64+
let size = size.assert_usize(cx.tcx).unwrap().into();
6565

6666
// Index is a constant uint
6767
if let Some((Constant::Int(const_index), _)) = constant(cx, index) {

clippy_lints/src/consts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
209209
ExprTup(ref tup) => self.multi(tup).map(Constant::Tuple),
210210
ExprRepeat(ref value, _) => {
211211
let n = match self.tables.expr_ty(e).sty {
212-
ty::TyArray(_, n) => n.val.to_raw_bits().expect("array length"),
212+
ty::TyArray(_, n) => n.assert_usize(self.tcx).expect("array length"),
213213
_ => span_bug!(e.span, "typeck error"),
214214
};
215215
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n as u64))
@@ -415,17 +415,17 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
415415
}
416416

417417
pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'tcx>) -> Option<Constant> {
418-
use rustc::mir::interpret::{Value, PrimVal};
418+
use rustc::mir::interpret::{PrimVal, ConstValue};
419419
match result.val {
420-
ConstVal::Value(Value::ByVal(PrimVal::Bytes(b))) => match result.ty.sty {
420+
ConstVal::Value(ConstValue::ByVal(PrimVal::Bytes(b))) => match result.ty.sty {
421421
ty::TyBool => Some(Constant::Bool(b == 1)),
422422
ty::TyUint(_) | ty::TyInt(_) => Some(Constant::Int(b)),
423423
ty::TyFloat(FloatTy::F32) => Some(Constant::F32(f32::from_bits(b as u32))),
424424
ty::TyFloat(FloatTy::F64) => Some(Constant::F64(f64::from_bits(b as u64))),
425425
// FIXME: implement other conversion
426426
_ => None,
427427
},
428-
ConstVal::Value(Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(n))) => match result.ty.sty {
428+
ConstVal::Value(ConstValue::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(n))) => match result.ty.sty {
429429
ty::TyRef(_, tam, _) => match tam.sty {
430430
ty::TyStr => {
431431
let alloc = tcx

clippy_lints/src/loops.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
12231223
match cx.tables.expr_ty(&args[0]).sty {
12241224
// If the length is greater than 32 no traits are implemented for array and
12251225
// therefore we cannot use `&`.
1226-
ty::TypeVariants::TyArray(_, size) if size.val.to_raw_bits().expect("array size") > 32 => (),
1226+
ty::TypeVariants::TyArray(_, size) if size.assert_usize(cx.tcx).expect("array size") > 32 => (),
12271227
_ => lint_iter_method(cx, args, arg, method_name),
12281228
};
12291229
} else {
@@ -1784,7 +1784,7 @@ fn is_ref_iterable_type(cx: &LateContext, e: &Expr) -> bool {
17841784
// no walk_ptrs_ty: calling iter() on a reference can make sense because it
17851785
// will allow further borrows afterwards
17861786
let ty = cx.tables.expr_ty(e);
1787-
is_iterable_array(ty) ||
1787+
is_iterable_array(ty, cx) ||
17881788
match_type(cx, ty, &paths::VEC) ||
17891789
match_type(cx, ty, &paths::LINKED_LIST) ||
17901790
match_type(cx, ty, &paths::HASHMAP) ||
@@ -1795,10 +1795,10 @@ fn is_ref_iterable_type(cx: &LateContext, e: &Expr) -> bool {
17951795
match_type(cx, ty, &paths::BTREESET)
17961796
}
17971797

1798-
fn is_iterable_array(ty: Ty) -> bool {
1798+
fn is_iterable_array(ty: Ty, cx: &LateContext) -> bool {
17991799
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
18001800
match ty.sty {
1801-
ty::TyArray(_, n) => (0..=32).contains(&n.val.to_raw_bits().expect("array length")),
1801+
ty::TyArray(_, n) => (0..=32).contains(&n.assert_usize(cx.tcx).expect("array length")),
18021802
_ => false,
18031803
}
18041804
}

clippy_lints/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: Ty) -> Option<sugg::S
12991299
ty::TySlice(_) => true,
13001300
ty::TyAdt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
13011301
ty::TyAdt(..) => match_type(cx, ty, &paths::VEC),
1302-
ty::TyArray(_, size) => size.val.to_raw_bits().expect("array length") < 32,
1302+
ty::TyArray(_, size) => size.assert_usize(cx.tcx).expect("array length") < 32,
13031303
ty::TyRef(_, inner, _) => may_slice(cx, inner),
13041304
_ => false,
13051305
}

0 commit comments

Comments
 (0)