Skip to content

Commit

Permalink
Rustup to 2018-05-13
Browse files Browse the repository at this point in the history
  • Loading branch information
phansch committed May 13, 2018
1 parent 18a5b90 commit 26b48bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/array_indexing.rs
Expand Up @@ -61,7 +61,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing {
// Array with known size can be checked statically
let ty = cx.tables.expr_ty(array);
if let ty::TyArray(_, size) = ty.sty {
let size = size.val.to_raw_bits().unwrap();
let size = size.assert_usize(cx.tcx).unwrap().into();

// Index is a constant uint
if let Some((Constant::Int(const_index), _)) = constant(cx, index) {
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/consts.rs
Expand Up @@ -209,7 +209,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
ExprTup(ref tup) => self.multi(tup).map(Constant::Tuple),
ExprRepeat(ref value, _) => {
let n = match self.tables.expr_ty(e).sty {
ty::TyArray(_, n) => n.val.to_raw_bits().expect("array length"),
ty::TyArray(_, n) => n.assert_usize(self.tcx).expect("array length"),
_ => span_bug!(e.span, "typeck error"),
};
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n as u64))
Expand Down Expand Up @@ -415,17 +415,17 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
}

pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'tcx>) -> Option<Constant> {
use rustc::mir::interpret::{Value, PrimVal};
use rustc::mir::interpret::{PrimVal, ConstValue};
match result.val {
ConstVal::Value(Value::ByVal(PrimVal::Bytes(b))) => match result.ty.sty {
ConstVal::Value(ConstValue::ByVal(PrimVal::Bytes(b))) => match result.ty.sty {
ty::TyBool => Some(Constant::Bool(b == 1)),
ty::TyUint(_) | ty::TyInt(_) => Some(Constant::Int(b)),
ty::TyFloat(FloatTy::F32) => Some(Constant::F32(f32::from_bits(b as u32))),
ty::TyFloat(FloatTy::F64) => Some(Constant::F64(f64::from_bits(b as u64))),
// FIXME: implement other conversion
_ => None,
},
ConstVal::Value(Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(n))) => match result.ty.sty {
ConstVal::Value(ConstValue::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(n))) => match result.ty.sty {
ty::TyRef(_, tam, _) => match tam.sty {
ty::TyStr => {
let alloc = tcx
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/loops.rs
Expand Up @@ -1223,7 +1223,7 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
match cx.tables.expr_ty(&args[0]).sty {
// If the length is greater than 32 no traits are implemented for array and
// therefore we cannot use `&`.
ty::TypeVariants::TyArray(_, size) if size.val.to_raw_bits().expect("array size") > 32 => (),
ty::TypeVariants::TyArray(_, size) if size.assert_usize(cx.tcx).expect("array size") > 32 => (),
_ => lint_iter_method(cx, args, arg, method_name),
};
} else {
Expand Down Expand Up @@ -1784,7 +1784,7 @@ fn is_ref_iterable_type(cx: &LateContext, e: &Expr) -> bool {
// no walk_ptrs_ty: calling iter() on a reference can make sense because it
// will allow further borrows afterwards
let ty = cx.tables.expr_ty(e);
is_iterable_array(ty) ||
is_iterable_array(ty, cx) ||
match_type(cx, ty, &paths::VEC) ||
match_type(cx, ty, &paths::LINKED_LIST) ||
match_type(cx, ty, &paths::HASHMAP) ||
Expand All @@ -1795,10 +1795,10 @@ fn is_ref_iterable_type(cx: &LateContext, e: &Expr) -> bool {
match_type(cx, ty, &paths::BTREESET)
}

fn is_iterable_array(ty: Ty) -> bool {
fn is_iterable_array(ty: Ty, cx: &LateContext) -> bool {
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
match ty.sty {
ty::TyArray(_, n) => (0..=32).contains(&n.val.to_raw_bits().expect("array length")),
ty::TyArray(_, n) => (0..=32).contains(&n.assert_usize(cx.tcx).expect("array length")),
_ => false,
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods.rs
Expand Up @@ -1299,7 +1299,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: Ty) -> Option<sugg::S
ty::TySlice(_) => true,
ty::TyAdt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
ty::TyAdt(..) => match_type(cx, ty, &paths::VEC),
ty::TyArray(_, size) => size.val.to_raw_bits().expect("array length") < 32,
ty::TyArray(_, size) => size.assert_usize(cx.tcx).expect("array length") < 32,
ty::TyRef(_, inner, _) => may_slice(cx, inner),
_ => false,
}
Expand Down

0 comments on commit 26b48bb

Please sign in to comment.