From 38251dccb0379493755377e568806741dea3a35d Mon Sep 17 00:00:00 2001 From: Enrico Schmitz Date: Wed, 1 Mar 2017 14:44:52 +0100 Subject: [PATCH] Array lengths are usize, so you need ConstInt::Usize(...) --- clippy_lints/src/array_indexing.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/array_indexing.rs b/clippy_lints/src/array_indexing.rs index f5902747d4f..727aef35ef1 100644 --- a/clippy_lints/src/array_indexing.rs +++ b/clippy_lints/src/array_indexing.rs @@ -2,7 +2,7 @@ use rustc::lint::*; use rustc::middle::const_val::ConstVal; use rustc::ty; use rustc_const_eval::ConstContext; -use rustc_const_math::ConstInt; +use rustc_const_math::{ConstUsize,ConstInt}; use rustc::hir; use syntax::ast::RangeLimits; use utils::{self, higher}; @@ -60,7 +60,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 = ConstInt::U128(size as u128); + let size = ConstInt::Usize(ConstUsize::new(size as u64, cx.sess().target.uint_type).unwrap()); let constcx = ConstContext::with_tables(cx.tcx, cx.tables); // Index is a constant uint