-
Notifications
You must be signed in to change notification settings - Fork 0
Description
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![]withServiceTopology(large struct withEnumSetfields) might trigger a variant not covered by the original fix - CI environment: Some discrepancy in the clippy version used in CI
Acceptance Criteria
- Investigate if this is a regression in clippy
- Report upstream if confirmed as regression
- Remove crate-level allow once upstream fix is available
References
- Upstream clippy issue:
clippy::large_stack_arraysreportsvec!literals and provides a useless suggestion rust-lang/rust-clippy#12586 - Fix PR: fix [
large_stack_arrays] linting invecmacro rust-lang/rust-clippy#12624 - Local documentation:
docs/issues/302-clippy-large-stack-arrays-false-positive.md - Related PR: refactor(infrastructure): [#301] Phase 4 - Extract ServiceTopology shared type #303 (Phase 4 Service Topology DDD Alignment)