Skip to content

Commit 90542ee

Browse files
committed
explain STACK_THRESHOLD value
1 parent d280f76 commit 90542ee

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

clippy_lints/src/let_arr_const.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ impl<'tcx> LateLintPass<'tcx> for LetArrConst {
4848
&& let Some(init) = local.init
4949
&& !init.span.from_expansion()
5050
{
51+
// LLVM optimizes the load of 16 byte as a single `mov`.
52+
// Bigger values make more `mov` instructions generated.
53+
// While changing code as this lint suggests, it becomes
54+
// a single load (`lea`) of an address in `.rodata`.
5155
const STACK_THRESHOLD: u64 = 16;
5256
// lint only `if size_of(init) > STACK_THRESHOLD`
5357
let ty = cx.typeck_results().expr_ty(init);

0 commit comments

Comments
 (0)