Problem
Clippy reports a false positive large_stack_arrays lint when using the vec![] macro to create vectors of ServiceTopology items in tests.
Error Message
error: allocating a local array larger than 16384 bytes
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#large_stack_arrays
= note: `-D clippy::large-stack-arrays` implied by `-D clippy::pedantic`
= help: to override `-D clippy::pedantic` add `#[allow(clippy::large_stack_arrays)]`
Root Cause
This is a known clippy bug where the vec![] macro is incorrectly flagged for creating a large stack array. The vec![] macro creates a Vec<T> which allocates on the heap, not the stack. The lint is a false positive.
Upstream Issue: rust-lang/rust-clippy#12586
Affected Code
Tests in src/domain/topology/aggregate.rs that create vectors of ServiceTopology:
let topology = DockerComposeTopology::new(vec![
ServiceTopology::with_networks(Service::Tracker, vec![Network::Database]),
ServiceTopology::with_networks(Service::MySQL, vec![Network::Database]),
])
.unwrap();
Current Workaround
Crate-level #![allow(clippy::large_stack_arrays)] in src/lib.rs.
Local suppression methods (module-level, function-level) don't work because the lint fires during macro expansion before the allow attributes are processed.
Potential Regression
The upstream fix (PR #12624) was merged April 27, 2024 and should be in Rust 1.80.0+. However, we're still seeing this error on Rust 1.93.0 (January 2026). This suggests either:
- Regression: The bug may have regressed in a later clippy version
- Different code pattern: Our
vec![] with ServiceTopology (large struct with EnumSet fields) might trigger a variant not covered by the original fix
- CI environment: Some discrepancy in the clippy version used in CI
Acceptance Criteria
References
Problem
Clippy reports a false positive
large_stack_arrayslint when using thevec![]macro to create vectors ofServiceTopologyitems in tests.Error Message
Root Cause
This is a known clippy bug where the
vec![]macro is incorrectly flagged for creating a large stack array. Thevec![]macro creates aVec<T>which allocates on the heap, not the stack. The lint is a false positive.Upstream Issue: rust-lang/rust-clippy#12586
Affected Code
Tests in
src/domain/topology/aggregate.rsthat create vectors ofServiceTopology:Current Workaround
Crate-level
#![allow(clippy::large_stack_arrays)]insrc/lib.rs.Local suppression methods (module-level, function-level) don't work because the lint fires during macro expansion before the allow attributes are processed.
Potential Regression
The upstream fix (PR #12624) was merged April 27, 2024 and should be in Rust 1.80.0+. However, we're still seeing this error on Rust 1.93.0 (January 2026). This suggests either:
vec![]withServiceTopology(large struct withEnumSetfields) might trigger a variant not covered by the original fixAcceptance Criteria
References
clippy::large_stack_arraysreportsvec!literals and provides a useless suggestion rust-lang/rust-clippy#12586large_stack_arrays] linting invecmacro rust-lang/rust-clippy#12624docs/issues/302-clippy-large-stack-arrays-false-positive.md