]> git.lizzy.rs Git - rust.git/commitdiff
Array lengths are usize, so you need ConstInt::Usize(...)
authorEnrico Schmitz <enrico@schmitz.link>
Wed, 1 Mar 2017 13:44:52 +0000 (14:44 +0100)
committerEnrico Schmitz <es@mdtm.de>
Wed, 1 Mar 2017 13:44:52 +0000 (14:44 +0100)
clippy_lints/src/array_indexing.rs

index f5902747d4f9e72c0993ef9073ea00d27188503b..727aef35ef1fe503414b6ed7d2639955b99a6c50 100644 (file)
@@ -2,7 +2,7 @@
 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 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
             // 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