Skip to content

Commit a2580db

Browse files
committed
Use clippy_utils::std_or_core in manual slice size calculation lint
1 parent b8fee8b commit a2580db

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clippy_lints/src/manual_slice_size_calculation.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-rustfix
22
use clippy_utils::diagnostics::span_lint_and_sugg;
33
use clippy_utils::source::snippet_with_context;
4-
use clippy_utils::{expr_or_init, in_constant};
4+
use clippy_utils::{expr_or_init, in_constant, std_or_core};
55
use rustc_errors::Applicability;
66
use rustc_hir::{BinOpKind, Expr, ExprKind};
77
use rustc_lint::{LateContext, LateLintPass};
@@ -50,14 +50,15 @@ impl<'tcx> LateLintPass<'tcx> for ManualSliceSizeCalculation {
5050
let ctxt = expr.span.ctxt();
5151
let mut app = Applicability::MachineApplicable;
5252
let val_name = snippet_with_context(cx, receiver.span, ctxt, "slice", &mut app).0;
53+
let Some(sugg) = std_or_core(cx) else { return };
5354

5455
span_lint_and_sugg(
5556
cx,
5657
MANUAL_SLICE_SIZE_CALCULATION,
5758
expr.span,
5859
"manual slice size calculation",
5960
"try",
60-
format!("std::mem::size_of_val({val_name})"),
61+
format!("{sugg}::mem::size_of_val({val_name})"),
6162
Applicability::MachineApplicable,
6263
);
6364
}

0 commit comments

Comments
 (0)