]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/large_const_arrays.rs
implement valtrees as the type-system representation for constant values
[rust.git] / src / tools / clippy / clippy_lints / src / large_const_arrays.rs
index ed47490e230cee6e7b78fbcf3aa35d9274e5b365..e10993ba7ddce0685ce140fc99547b72f2b9cd92 100644 (file)
@@ -3,7 +3,6 @@
 use rustc_errors::Applicability;
 use rustc_hir::{Item, ItemKind};
 use rustc_lint::{LateContext, LateLintPass};
-use rustc_middle::mir::interpret::ConstValue;
 use rustc_middle::ty::layout::LayoutOf;
 use rustc_middle::ty::{self, ConstKind};
 use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -53,8 +52,8 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
             if let ItemKind::Const(hir_ty, _) = &item.kind;
             let ty = hir_ty_to_ty(cx.tcx, hir_ty);
             if let ty::Array(element_type, cst) = ty.kind();
-            if let ConstKind::Value(ConstValue::Scalar(element_count)) = cst.kind();
-            if let Ok(element_count) = element_count.to_machine_usize(&cx.tcx);
+            if let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind();
+            if let Ok(element_count) = element_count.try_to_machine_usize(cx.tcx);
             if let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes());
             if self.maximum_allowed_size < element_count * element_size;