From 26b48bbdfc7aa1e8d4d10b13e7b63e981704f932 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Sun, 13 May 2018 10:44:57 +0200 Subject: [PATCH 1/2] Rustup to 2018-05-13 --- clippy_lints/src/array_indexing.rs | 2 +- clippy_lints/src/consts.rs | 8 ++++---- clippy_lints/src/loops.rs | 8 ++++---- clippy_lints/src/methods.rs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/clippy_lints/src/array_indexing.rs b/clippy_lints/src/array_indexing.rs index e07804468..b51a9209c 100644 --- a/clippy_lints/src/array_indexing.rs +++ b/clippy_lints/src/array_indexing.rs @@ -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) { diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 3668f5232..a078fde47 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -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)) @@ -415,9 +415,9 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { } pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'tcx>) -> Option { - 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))), @@ -425,7 +425,7 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<' // 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 diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 50e6e4c3b..a7ca0d27e 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -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 { @@ -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) || @@ -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, } } diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 212310a0f..c7702e6bc 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1299,7 +1299,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: Ty) -> Option 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, } From a8d7e5a1f231a80a5d6a86de97ff705c64ef4c3e Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Sun, 13 May 2018 11:16:07 +0200 Subject: [PATCH 2/2] Version bump --- CHANGELOG.md | 3 +++ Cargo.toml | 4 ++-- clippy_lints/Cargo.toml | 2 +- min_version.txt | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bde6136f..1cb596d81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## 0.0.199 +* Rustup to *rustc 1.27.0-nightly (ff2ac35db 2018-05-12)* + ## 0.0.198 * Rustup to *rustc 1.27.0-nightly (acd3871ba 2018-05-10)* diff --git a/Cargo.toml b/Cargo.toml index 083565d34..a200a6710 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.198" +version = "0.0.199" authors = [ "Manish Goregaokar ", "Andre Bogus ", @@ -37,7 +37,7 @@ path = "src/driver.rs" [dependencies] # begin automatic update -clippy_lints = { version = "0.0.198", path = "clippy_lints" } +clippy_lints = { version = "0.0.199", path = "clippy_lints" } # end automatic update regex = "1" semver = "0.9" diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index cc5d36ff1..284f7e75c 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "clippy_lints" # begin automatic update -version = "0.0.198" +version = "0.0.199" # end automatic update authors = [ "Manish Goregaokar ", diff --git a/min_version.txt b/min_version.txt index a2e0b6f19..9d1de5e2c 100644 --- a/min_version.txt +++ b/min_version.txt @@ -1,7 +1,7 @@ -rustc 1.27.0-nightly (acd3871ba 2018-05-10) +rustc 1.27.0-nightly (ff2ac35db 2018-05-12) binary: rustc -commit-hash: acd3871ba17316419c644e17547887787628ec2f -commit-date: 2018-05-10 +commit-hash: ff2ac35db93a80b2de5daa4f280bf1503d62c164 +commit-date: 2018-05-12 host: x86_64-unknown-linux-gnu release: 1.27.0-nightly LLVM version: 6.0