X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=clippy_lints%2Fsrc%2Flarge_const_arrays.rs;h=48dc5fefe99784d9e98f66994a069c478921f075;hb=b094bb1bd7f1cc702823c91ca509f338fedee24a;hp=4c3030cf2e7c443892539caa1ba1dc5a5b17c6b4;hpb=2538e6388590fe592cd41c7d38bb1ade63f7d309;p=rust.git diff --git a/clippy_lints/src/large_const_arrays.rs b/clippy_lints/src/large_const_arrays.rs index 4c3030cf2e7..48dc5fefe99 100644 --- a/clippy_lints/src/large_const_arrays.rs +++ b/clippy_lints/src/large_const_arrays.rs @@ -1,5 +1,5 @@ use crate::rustc_target::abi::LayoutOf; -use crate::utils::span_lint_and_then; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind}; @@ -45,15 +45,14 @@ pub fn new(maximum_allowed_size: u64) -> Self { impl_lint_pass!(LargeConstArrays => [LARGE_CONST_ARRAYS]); -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeConstArrays { - fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) { +impl<'tcx> LateLintPass<'tcx> for LargeConstArrays { + fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) { if_chain! { if !item.span.from_expansion(); 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(val) = cst.val; - if let ConstValue::Scalar(element_count) = val; + if let ty::Array(element_type, cst) = ty.kind(); + if let ConstKind::Value(ConstValue::Scalar(element_count)) = cst.val; if let Ok(element_count) = element_count.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; @@ -70,8 +69,8 @@ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) { LARGE_CONST_ARRAYS, item.span, "large array defined as const", - |db| { - db.span_suggestion( + |diag| { + diag.span_suggestion( sugg_span, "make this a static item", "static".to_string(),