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;
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(),