clippy::large_stack_arrays
reports vec!
literals and provides a useless suggestion
#12586
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
When the
array-size-threshold
configuration value is small or the array elements are large,clippy::large_stack_arrays
will lint on avec!
expression. It then proposes usingvec![...].into_boxed_slice()
, which is unhelpful: the boxed slice in question is itself inside thevec!
macro expansion, so continuing to usevec![]
but with more conversions won't do anything.Additionally, this suggestion seems like it cannot help even a normal array construction, since even if this were a literal array, switching to
vec![]
would not take it off the stack totally, just after construction, so the lint would continue to fire (correctly) — unless we are using[value; len]
syntax. In that case only, changing tovec!
would avoid putting any large array on the stack.Lint Name
large_stack_arrays
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen: Either no recommendation, or a recommendation that actually avoids the array going on the stack.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: